日期:2014-05-17  浏览次数:20608 次

关于wcf静态变量的问题
在Nunit调用Wcf的方法,该方法最终会调用另外一个程序集的静态方法CreateSession。方法如下:

 public class NHibernateHelper
    {
        private static ISessionFactory _sessionFactory;
        private static object _sessionFactoryObj = new object();
        private static ValidatorEngine _tor;
        private static object _torObj = new object();
 
        private NHibernateHelper() { }
        static NHibernateHelper()
        {
            log4net.Config.XmlConfigurator.Configure();
 
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            logger.Info("自定义记录错误日志:11111111111111111111111111111111111111111111111" + DateTime.Now.ToString());
        }
 
        private static ISessionFactory SessionFactory
        {
            get
            {
                if (_sessionFactory == null)
                {
                    lock (_sessionFactoryObj)
                    {
                        if (_sessionFactory == null)
                        {
                            NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
                            cfg.AddAssembly("Com.Richfit.A1.DMS.DataProvider.DataAccess");
                            _sessionFactory = cfg.BuildSessionFactory();
                        }
                    }
                }
 
                return _sessionFactory;
      &n