本文整理汇总了C#中ISessionFactory类的典型用法代码示例。如果您正苦于以下问题:C# ISessionFactory类的具体用法?C# ISessionFactory怎么用?C# ISessionFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISessionFactory类属于命名空间,在下文中一共展示了ISessionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsDynamicComponentDictionaryGetter
public static bool IsDynamicComponentDictionaryGetter(MethodInfo method, Expression targetObject, IEnumerable<Expression> arguments, ISessionFactory sessionFactory, out string memberName)
{
memberName = null;
// A dynamic component must be an IDictionary with a string key.
if (method.Name != "get_Item" || !typeof(IDictionary).IsAssignableFrom(targetObject.Type))
return false;
var key = arguments.First() as ConstantExpression;
if (key == null || key.Type != typeof(string))
return false;
// The potential member name
memberName = (string)key.Value;
// Need the owning member (the dictionary).
var member = targetObject as MemberExpression;
if (member == null)
return false;
var metaData = sessionFactory.GetClassMetadata(member.Expression.Type);
if (metaData == null)
return false;
// IDictionary can be mapped as collection or component - is it mapped as a component?
var propertyType = metaData.GetPropertyType(member.Member.Name);
return (propertyType != null && propertyType.IsComponentType);
}
示例2: VartotojaiController
public VartotojaiController(IAuthenticationProvider authenticationProvider, ISessionFactory sessionFactory, [LoggedIn] UserInformation loggedInUser, HashAlgorithm hashAlgorithm)
{
_authenticationProvider = authenticationProvider;
_sessionFactory = sessionFactory;
_loggedInUser = loggedInUser;
_hashAlgorithm = hashAlgorithm;
}
示例3: ActionTransactionHelper
public ActionTransactionHelper(
ISessionFactory sessionFactory,
ICurrentSessionContextAdapter currentSessionContextAdapter)
{
_sessionFactory = sessionFactory;
_currentSessionContextAdapter = currentSessionContextAdapter;
}
示例4: UseNHibernate
public static void UseNHibernate(this AppConfigurator configurator, ISessionFactory sessionFactory)
{
var runtime = configurator.AppRuntime;
runtime.Container.Register<IDomainDbSession>(_ => new NhDomainDbSession(sessionFactory.OpenSession()));
runtime.Container.Register<IDomainRepository>(_ => new NhDomainRepository(_.Resolve<IDomainDbSession>(), _.Resolve<IRelayWorker>()));
}
示例5: Update
public static void Update(ISessionFactory sessionFactory)
{
var factory = (ISessionFactoryImplementor) sessionFactory;
var dialect = factory.Dialect;
var connectionHelper = new SuppliedConnectionProviderConnectionHelper(factory.ConnectionProvider);
factory.Dialect.Keywords.AddAll(GetReservedWords(dialect, connectionHelper));
}
示例6: Init
private static void Init()
{
nhConfiguration = new Configuration();
//nhConfiguration.Configure("NhibernateUtils/NHibernate.cfg.xml");
nhConfiguration.AddAssembly("Activos");
sessionFactory = nhConfiguration.BuildSessionFactory();
}
示例7: DestroySagaPersisterContext
public void DestroySagaPersisterContext()
{
SagaPersister = null;
SessionFactory.Dispose();
SessionFactory = null;
DeleteFile();
}
示例8: Open
public ISession Open()
{
if(_sessionFactory == null)
_sessionFactory = configureSessionFactory();
return _sessionFactory.OpenSession();
}
示例9: ExampleFactoryManager
public ExampleFactoryManager(string configSectionName = "ExampleDatabaseConnectionSettings")
{
var configuration = Fluently.Configure();
configuration.InitializeFromConfigMsSql(configSectionName);
configuration.AddMappingsFromAssemblyOf<UserMap>();
_instance = configuration.BuildSessionFactory();
}
示例10: TestClassSetup
public static void TestClassSetup(TestContext context)
{
_configuration = new Configuration();
_configuration.Configure();
_configuration.AddAssembly(typeof(Draft).Assembly);
_sessionFactory = _configuration.BuildSessionFactory();
}
示例11: Setup
public void Setup()
{
Configure.ConfigurationSource = new DefaultConfigurationSource();
NHibernateSettingRetriever.AppSettings = () => new NameValueCollection
{
{"NServiceBus/Persistence/NHibernate/dialect", dialect}
};
NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
{
new ConnectionStringSettings("NServiceBus/Persistence/NHibernate/Timeout", connectionString)
};
ConfigureNHibernate.Init();
Configure.With(Enumerable.Empty<Type>())
.DefineEndpointName("Foo")
.DefaultBuilder()
.UseNHibernateTimeoutPersister();
persister = Configure.Instance.Builder.Build<TimeoutStorage>();
sessionFactory = persister.SessionFactory;
new Installer.Installer().Install(WindowsIdentity.GetCurrent().Name);
}
示例12: CreateSessionFactory
private static void CreateSessionFactory()
{
// FluentNHibernate.Search Configuration
Configuration fnhscfg = FluentSearch.Configure()
.DefaultAnalyzer().Standard()
.DirectoryProvider().RAMDirectory()
.IndexingStrategy().Event()
.Listeners(ListenerConfiguration.Default)
.MappingClass<SearchMap>()
.BuildConfiguration();
// FluentNHibernate Configuration
Configuration fnhcfg = Fluently.Configure(fnhscfg)
.Database(SQLiteConfiguration.Standard.InMemory()
.Dialect<SQLiteDialect>()
.ConnectionString(ConnectionString)
.ProxyFactoryFactory<ProxyFactoryFactory>())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<AuthorMap>())
.ExposeConfiguration(cfg =>
{
cfg.SetListeners(ListenerType.PostInsert, new[] { new FullTextIndexEventListener() });
cfg.SetListeners(ListenerType.PostUpdate, new[] { new FullTextIndexEventListener() });
cfg.SetListeners(ListenerType.PostDelete, new[] { new FullTextIndexEventListener() });
cfg.SetListener(ListenerType.PostCollectionRecreate, new FullTextIndexCollectionEventListener());
cfg.SetListener(ListenerType.PostCollectionRemove, new FullTextIndexCollectionEventListener());
cfg.SetListener(ListenerType.PostCollectionUpdate, new FullTextIndexCollectionEventListener());
})
.BuildConfiguration();
_cfg = fnhcfg;
_sessionFactory = _cfg.BuildSessionFactory();
}
示例13: Initialize
/// <summary>
/// Called by the framework to initialize the persistent store.
/// </summary>
public void Initialize()
{
Platform.Log(LogLevel.Info, "Initializing NHibernate subsystem...");
// create the hibernate configuration
_cfg = new Configuration();
// this will automatically read from the app.config
_cfg.Configure();
Platform.Log(LogLevel.Debug, "NHibernate connection string: {0}", this.ConnectionString);
// add each assembly to the hibernate configuration
// this tells NHibernate to look for .hbm.xml embedded resources in these assemblies
// TODO: we should only scan plugins that are tied to this PersistentStore, but there is currently no way to know this
var orderer = new AssembliesHbmOrderer(Platform.PluginManager.Plugins);
orderer.AddToConfiguration(_cfg);
// setup default caching strategies for all classes/collections that don't have one explicitly
// specified in the mapping files
CreateDefaultCacheStrategies();
// create the session factory
_sessionFactory = _cfg.BuildSessionFactory();
Platform.Log(LogLevel.Info, "NHibernate initialization complete.");
}
示例14: Init
private static void Init()
{
var config = new Configuration();
config.Configure();
config.AddAssembly(Assembly.GetCallingAssembly());
_sessionFactory = config.BuildSessionFactory();
}
示例15: 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();
}