コード例 #1
0
        /// <summary>
        /// 初始化程序(设置ServiceLocator,读取IDataBuffer)
        /// </summary>
        public static void InitProgram()
        {
            if (!m_init)
            {
#if DEBUG
                Console.WriteLine("Please press any key to continue...");
                Console.ReadLine();
#endif
                m_init = true;

                var p = DefaultServiceProvider.Instance;
                p.EnableLog();
                p.EnableNHibernate();
                p.EnableCache();
                p.EnableScript(false);

                Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(new Microsoft.Practices.ServiceLocation.ServiceLocatorProvider(
                                                                                          delegate()
                {
                    return(p);
                }));


                IDataBuffer db = ServiceProvider.GetService <IDataBuffer>();
                if (db != null)
                {
                    db.LoadData();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 初始化程序(设置ServiceLocator,读取IDataBuffer)
        /// </summary>
        public static void InitProgram()
        {
            if (!m_init)
            {
                m_init = true;

                Feng.Utils.XceedUtility.SetXceedLicense();
                log4net.Config.XmlConfigurator.Configure();
                //HibernatingRhinos.NHibernate.Profiler.Appender.NHibernateProfiler.Initialize();

                //if (Microsoft.Practices.ServiceLocation.ServiceLocator.Current == null) // throw null
                {
                    if (!SystemConfiguration.LiteMode)
                    {
                        SetSpringServiceLocator();
                    }

                    ServiceProvider.SetDefaultService <ILogger>(new log4netLogger());
                    ServiceProvider.SetDefaultService <IExceptionProcess>(new LoggerExceptionProcess());

                    ServiceProvider.SetDefaultService <Feng.NH.ISessionFactoryManager>(new Feng.NH.NHibernateSessionFactoryManager());
                    ServiceProvider.SetDefaultService <IRepositoryFactory>(new NH.RepositoryFactory());

                    IPersistentCache c = new PersistentHashtableCache();
                    ServiceProvider.SetDefaultService <ICache>(c);
                    ServiceProvider.SetDefaultService <IPersistentCache>(c);

                    Feng.DBDef def = new Feng.DBDef();
                    ServiceProvider.SetDefaultService <IDefinition>(def);

                    IDataBuffer buf = new Feng.DBDataBuffer();
                    ServiceProvider.SetDefaultService <IDataBuffer>(buf);

                    IDataBuffers bufs = new DataBuffers();
                    bufs.AddDataBuffer(new Cache());
                    bufs.AddDataBuffer(buf);
                    bufs.AddDataBuffer(def);
                    ServiceProvider.SetDefaultService <IDataBuffers>(bufs);

                    IEntityScript script = new PythonandEvalutionEngineScript();
                    ServiceProvider.SetDefaultService <IScript>(script);
                    ServiceProvider.SetDefaultService <IEntityScript>(script);

                    ServiceProvider.SetDefaultService <IMessageBox>(new EmptyMessageBox());

                    ServiceProvider.SetDefaultService <IControlCollectionFactory>(new Feng.ControlCollectionFactoryBase());

                    ServiceProvider.SetDefaultService <IManagerFactory>(new Feng.Utils.ManagerFactory());

                    IDataBuffer db = ServiceProvider.GetService <IDataBuffer>();
                    if (db != null)
                    {
                        db.LoadData();
                    }
                }
            }
        }
コード例 #3
0
        protected void Application_Start(object sender, EventArgs e)
        {
            IApplicationContext ctx = ContextRegistry.GetContext();

            Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(new Microsoft.Practices.ServiceLocation.ServiceLocatorProvider(
                                                                                      delegate()
            {
                return(new Microsoft.Practices.ServiceLocation.SpringAdapter.SpringServiceLocatorAdapter(ctx));
            }));

            // Spring.net 默认是Singleton的
            IDataBuffer db = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IDataBuffer>();

            if (db != null)
            {
                db.LoadData();
            }
        }
コード例 #4
0
        /// <summary>
        /// 初始化程序(设置ServiceLocator,读取IDataBuffer)
        /// </summary>
        public static void InitProgram()
        {
            if (!m_init)
            {
                m_init = true;
                if (Microsoft.Practices.ServiceLocation.ServiceLocator.Current == null)
                {
                    IApplicationContext ctx = ContextRegistry.GetContext();
                    Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(new Microsoft.Practices.ServiceLocation.ServiceLocatorProvider(
                                                                                              delegate()
                    {
                        return(new Microsoft.Practices.ServiceLocation.SpringAdapter.SpringServiceLocatorAdapter(ctx));
                    }));

                    // Spring.net 默认是Singleton的
                    IDataBuffer db = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IDataBuffer>();
                    if (db != null)
                    {
                        db.LoadData();
                    }
                }
            }
        }