当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.Proxy方法代码示例

本文整理汇总了C#中NHibernate.Cfg.Configuration.Proxy方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Proxy方法的具体用法?C# Configuration.Proxy怎么用?C# Configuration.Proxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NHibernate.Cfg.Configuration的用法示例。


在下文中一共展示了Configuration.Proxy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OpenSession

        public static ISession OpenSession()
        {
            if (sessionFactory == null)
            {
                System.Collections.Specialized.NameValueCollection sets = System.Configuration.ConfigurationManager.AppSettings;

                //获取连接字符串
                string server = Utilities.GetConfigValue("server");
                string pwd = VTMS.Common.Utilities.Base64Dencrypt(Utilities.GetConfigValue("DBPassword"));
                string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
                connectionString = string.Format(connectionString, server, pwd);

                try
                {
                    Configuration cfg = new Configuration().Configure();
                    cfg.Proxy(p => p.ProxyFactoryFactory<NHibernate.Bytecode.DefaultProxyFactoryFactory>());
                    cfg.DataBaseIntegration(db =>
                    {
                        db.ConnectionString = connectionString;
                    });

                    sessionFactory = cfg.BuildSessionFactory();
                }
                catch (Exception e)
                {
                    VTMS.Common.MessageUtil.ShowError("无法登陆服务器,请检查服务器IP设置是否正确,错误信息为:" + e.Message);
                }
            }
            return sessionFactory.OpenSession();
        }
开发者ID:jilichao,项目名称:vtms,代码行数:30,代码来源:SessionFactory.cs

示例2: BuildConfiguration

        public Configuration BuildConfiguration(string connectionString, string sessionFactoryName)
        {
            Contract.Requires(!string.IsNullOrEmpty(connectionString), "ConnectionString is null or empty");
            Contract.Requires(!string.IsNullOrEmpty(sessionFactoryName), "SessionFactory name is null or empty");
            Contract.Requires(!string.IsNullOrEmpty(_databaseSchema), "Database Schema is null or empty");
            Contract.Requires(_configurator != null, "Configurator is null");

            return CatchExceptionHelper.TryCatchFunction(
                () =>
                {
                    DomainTypes = GetTypeOfEntities(_assemblies);

                    if (DomainTypes == null)
                        throw new Exception("Type of domains is null");

                    var configure = new Configuration();
                    configure.SessionFactoryName(sessionFactoryName);

                    configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
                    configure.DataBaseIntegration(db => GetDatabaseIntegration(db, connectionString));

                    if (_configurator.GetAppSettingString("IsCreateNewDatabase").ConvertToBoolean())
                    {
                        configure.SetProperty("hbm2ddl.auto", "create-drop");
                    }

                    configure.Properties.Add("default_schema", _databaseSchema);
                    configure.AddDeserializedMapping(GetMapping(),
                                                     _configurator.GetAppSettingString("DocumentFileName"));

                    SchemaMetadataUpdater.QuoteTableAndColumns(configure);

                    return configure;
                }, Logger);
        }
开发者ID:ghy,项目名称:ConfORMSample,代码行数:35,代码来源:ConfORMConfigBuilder.cs

示例3: PrepareSessionFactory

        public void PrepareSessionFactory()
        {
            Configuration = new Configuration();
            Configuration.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
                .DataBaseIntegration(db =>
                                         {
                                             db.ConnectionStringName = "db";
                                             db.Dialect<MsSql2008Dialect>();
                                         });
            Configuration.SetProperty("show_sql", "true");
            Configuration.SetDefaultAssembly("NHibernateDeepDive");
            Configuration.SetDefaultNamespace("NHibernate_Deep_Dive.Entities");
            Configuration.AddXmlFile("ClearDatabaseScript.hbm.xml");
            foreach (var mappingFile in Directory.GetFiles(MappingsDirectory))
            {
                Configuration.AddXmlFile(mappingFile);
            }
            AdjustConfiguration(Configuration);
            Configuration.SessionFactory().GenerateStatistics();

            SessionFactory = Configuration.BuildSessionFactory();

            //new SchemaExport(Configuration).Drop(false, true);
            new SchemaExport(Configuration).Execute(false, true, false);

            BeforeTestRun();
            PopulateDatabase();

            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
        }
开发者ID:adymitruk,项目名称:NHibernate-Deep-Dive,代码行数:30,代码来源:SpecificationBase.cs

示例4: Initialize

        public static Configuration Initialize()
        {
            INHibernateConfigurationCache cache = new NHibernateConfigurationFileCache();

            var mappingAssemblies = new[] {
                typeof(ActionConfirmation<>).Assembly.GetName().Name
            };

            var configuration = cache.LoadConfiguration(CONFIG_CACHE_KEY, null, mappingAssemblies);

            if (configuration == null) {
                configuration = new Configuration();

                configuration
                    .Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
                    .DataBaseIntegration(db => {
                        db.ConnectionStringName = "DonSharpLiteConnectionString";
                        db.Dialect<MsSql2008Dialect>();
                    })
                    .AddAssembly(typeof(ActionConfirmation<>).Assembly)
                    .CurrentSessionContext<LazySessionContext>();

                var mapper = new ConventionModelMapper();
                mapper.WithConventions(configuration);

                cache.SaveConfiguration(CONFIG_CACHE_KEY, configuration);
            }

            return configuration;
        }
开发者ID:antgerasim,项目名称:DonSharpArchitecture,代码行数:30,代码来源:NHibernateInitializer.cs

示例5: Main

        private static void Main()
        {
            NHibernateProfiler.Initialize();

            var cfg = new Configuration();
            cfg.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
               .DataBaseIntegration(db => {
                                        db.ConnectionStringName = "scratch";
                                        db.Dialect<MsSql2008Dialect>();
                                        db.BatchSize = 500;
                                    })
                .AddAssembly(Assembly.GetExecutingAssembly())
                .SessionFactory().GenerateStatistics();

            new SchemaExport(cfg).Execute(script: false, export: true, justDrop: false);

            var sessionFactory = cfg.BuildSessionFactory();

            using(var session = sessionFactory.OpenSession())
            using(var tx = session.BeginTransaction()) {
                // NHibernate code goes here
                tx.Commit();
            }

            Console.WriteLine("Press <ENTER> to exit...");
            Console.ReadLine();
        }
开发者ID:JamesKovacs,项目名称:NH3Features,代码行数:27,代码来源:Program.cs

示例6: BasicConfiguration

		public BasicConfiguration(IConnectionString connectionString) {
			_configuration = new Configuration();
			_configuration.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
						  .DataBaseIntegration(db => {
							  db.ConnectionString = connectionString.FormattedConnectionString;
							  db.Dialect<MsSql2008Dialect>();
						  })
						  .AddAssembly(typeof(NHTestEntity).Assembly);
		}
开发者ID:tarwn,项目名称:StaticVoid.OrmPerformance,代码行数:9,代码来源:BasicConfiguration.cs

示例7: Apply

		public virtual void Apply(Configuration configuration, IDatabaseProvider databaseProvider)
		{
			configuration.CurrentSessionContext<CallSessionContext>();

			configuration.DataBaseIntegration(db => SetDatabase(db, databaseProvider, configuration));

			configuration.Cache(SetCache);

			configuration.Proxy(SetProxy);
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:10,代码来源:DefaultConfiguration.cs

示例8: ConfigureNHibernate

 public static Configuration ConfigureNHibernate()
 {
     var configure = new Configuration();
     configure.SessionFactoryName("Demo");
     configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
     configure.DataBaseIntegration(db =>
     {
         db.Dialect<MsSql2008Dialect>();
         db.Driver<SqlClientDriver>();
         db.ConnectionString = ConnectionString;
         db.LogSqlInConsole = true;//用于显示输出SQL
     });
     return configure;
 }
开发者ID:wgang10,项目名称:ZYWeb,代码行数:14,代码来源:NhConfig.cs

示例9: CreateConfiguration

        public static Configuration CreateConfiguration()
        {
            var configuration = new Configuration();

            configuration
                .Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
                .DataBaseIntegration(db => {
                    db.ConnectionStringName = "DefaultConnection";
                    db.Dialect<MsSql2008Dialect>();
                })
                .AddAssembly(typeof(Entity).Assembly)
                .CurrentSessionContext<LazySessionContext>();

            return configuration;
        }
开发者ID:ctrlpprint,项目名称:Congregation,代码行数:15,代码来源:NHibernateInitializer.cs

示例10: Initialize

        public static Configuration Initialize() {
            Configuration configuration = new Configuration();

            configuration
                .Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
                .DataBaseIntegration(db => {
                    db.ConnectionStringName = "CaTSConnectionString";
                    db.Dialect<MsSql2008Dialect>();
                })
                .AddAssembly(typeof(ActionConfirmation<>).Assembly)
                .CurrentSessionContext<LazySessionContext>();

            ConventionModelMapper mapper = new ConventionModelMapper();
            mapper.WithConventions(configuration);

            return configuration;
        }
开发者ID:transformersprimeabcxyz,项目名称:Sharp-Lite,代码行数:17,代码来源:NHibernateInitializer.cs

示例11: Init

        private static NHibernate.ISessionFactory Init()
        {
            var config = new Configuration();
            config.Proxy(proxy => proxy.ProxyFactoryFactory<DefaultProxyFactoryFactory>());
            config.DataBaseIntegration(db =>
            {
                db.Dialect<SQLiteDialect>();
                db.ConnectionString = @"Data Source=|DataDirectory|\Test.db";
                //db.Driver<SQLite20Driver>();
                db.SchemaAction = SchemaAutoAction.Create;
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
            });

            config.AddDeserializedMapping(InternalHelper.GetAllMapper(), "Models");

            return config.BuildSessionFactory();
        }
开发者ID:leejulee,项目名称:NhibernateTest,代码行数:17,代码来源:UnitTestNhibernate.cs

示例12: GetConfiguration

        public static Configuration GetConfiguration()
        {
            var configure = new Configuration();
            configure.SessionFactoryName("NHibernateDB");

            //Proxy扩展方法用于配置NHibernate延迟加载的字节码提供程序
            configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());

            configure.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2005Dialect>();
                db.Driver<SqlClientDriver>();
                db.ConnectionString = _ConnectionString;
            });

            return configure;
        }
开发者ID:wgang10,项目名称:ZYWeb,代码行数:17,代码来源:DBHelper.cs

示例13: BuildSessionFactory

        private ISessionFactory BuildSessionFactory()
        {
            var configuration = new Configuration();
            configuration.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2008Dialect>();
                db.ConnectionStringName = "NHibernate_CRUD";
            });
            configuration.Properties[Environment.CurrentSessionContextClass]
                            = typeof(LazySessionContext).AssemblyQualifiedName;

            configuration.Cache(c => c.UseQueryCache = false);

            configuration.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());

            configuration.AddAssembly(GetType().Assembly);

            return configuration.BuildSessionFactory();
        }
开发者ID:CezaryRynkowski,项目名称:NHibernateMVC,代码行数:19,代码来源:NHibernateInstaller.cs

示例14: Initialize

        private static NHibernate.ISessionFactory Initialize(Action<ModelMapper> action)
        {
            var config = new Configuration();
            config.Proxy(proxy => proxy.ProxyFactoryFactory<DefaultProxyFactoryFactory>());
            config.DataBaseIntegration(db =>
            {
                db.Dialect<SQLiteDialect>();
                db.ConnectionString = @"Data Source=|DataDirectory|\Test.db";
                //db.Driver<SQLite20Driver>();
                db.SchemaAction = SchemaAutoAction.Create;
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
            });

            var mapper = new ModelMapper();
            action(mapper);
            var maps = mapper.CompileMappingForAllExplicitlyAddedEntities();
            config.AddDeserializedMapping(maps, "Models");

            return config.BuildSessionFactory();
        }
开发者ID:leejulee,项目名称:NhibernateTest,代码行数:20,代码来源:UnitTestCascade.cs

示例15: Initialize

        public static Configuration Initialize()
        {
            var configuration = new Configuration();

            configuration
                .Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
                .DataBaseIntegration(db =>
                                         {
                                             db.ConnectionStringName = "DevelopmentStack";
                                             db.Dialect<MsSql2008Dialect>();
                                             db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                                         })
                .AddAssembly(typeof (Stack).Assembly)
                .CurrentSessionContext<LazySessionContext>();

            ConventionModelMapper mapper = new ConventionModelMapper();
            mapper.WithConventions(configuration);

            return configuration;
        }
开发者ID:feelexit,项目名称:DevelopmentStack,代码行数:20,代码来源:NHibernateInitializer.cs


注:本文中的NHibernate.Cfg.Configuration.Proxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。