标签:
using IBatisNet.Common.Utilities;
using IBatisNet.DataMapper;
using IBatisNet.DataMapper.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Dscf.Map
{
public class BaseBatis
{
public static ISqlMapper SqlMap; //SqlMap sqlMap
private static readonly object synobj = new object();
static BaseBatis()
{
if (SqlMap == null)
{
lock (synobj)
{
if (SqlMap == null)
{
Assembly assembly = Assembly.Load("Dscf.Map");
Stream stream = assembly.GetManifestResourceStream("Dscf.Map.sqlmap.config"); //TestMap.sqlmap.config
DomSqlMapBuilder builder = new DomSqlMapBuilder();//其作用是根据配置文件创建SqlMap实例。
try
{
SqlMap = builder.Configure(stream);
}
catch (Exception)
{
throw;
}
}
}
}
}
//public static ISqlMapper SqlMap; //SqlMap sqlMap
//private static ISqlMapper _instance = null;
////private static Hashtable sqlMappers = new Hashtable();
//public static ISqlMapper GetMapper()
//{
// if (_instance == null)
// {
// //_instance = Mapper.Get();
// //_instance.SessionStore = new HybridWebThreadSessionStore(_instance.Id);
// ConfigureHandler handler = new ConfigureHandler(Configure);
// DomSqlMapBuilder builder = new DomSqlMapBuilder();
// _instance = builder.ConfigureAndWatch("bin\\Dscf.Map\\Config", Configure);
// }
// return _instance;
// //return Mapper.Get();
//}
//protected static void Configure(object obj)
//{
// _instance = null;
//}
}
}
ibatis 基类生成
标签:
原文地址:http://www.cnblogs.com/dullbaby/p/4828473.html