public static void Configure(ISessionStorage storage)
        {
            var baseEntityToIgnore = new[] { 
                typeof(NHibernate.AspNet.Identity.DomainModel.EntityWithTypedId<int>), 
                typeof(NHibernate.AspNet.Identity.DomainModel.EntityWithTypedId<string>), 
            };

            var allEntities = new[] { 
                typeof(IdentityUser), 
                typeof(ApplicationUser), 
                typeof(IdentityRole), 
                typeof(IdentityUserLogin), 
                typeof(IdentityUserClaim), 
            };

            var mapper = new ConventionModelMapper();
            DefineBaseClass(mapper, baseEntityToIgnore);
            mapper.IsComponent((type, declared) => typeof(NHibernate.AspNet.Identity.DomainModel.ValueObject).IsAssignableFrom(type));

            mapper.AddMapping<IdentityUserMap>();
            mapper.AddMapping<IdentityRoleMap>();
            mapper.AddMapping<IdentityUserClaimMap>();

            var mapping = mapper.CompileMappingFor(allEntities);
            System.Diagnostics.Debug.WriteLine(mapping.AsString());

            var configuration = NHibernateSession.Init(storage, mapping);
            BuildSchema(configuration);
        }
        public void Init()
        {
            _sessionStorage = new SimpleSessionStorage();

            // news management config area
            _newsMgtConnectionString = "Server=localhost;database=ConfORMSample;Integrated Security=SSPI;";

            _newsMgtAssemblies = new List<string>
                              {
                                  "ConfORMSample.NewsMgt.Entities.dll"
                              };

            _newsMgtConfigBuilder = new Football.SqlServerConfORMConfigBuilder(_newsMgtAssemblies, "ConfORMSample.dbo");

            NHibernateSession.Init(_newsMgtConfigBuilder, _sessionStorage, _newsMgtConnectionString, "NewsMgt");

            // football management config area
            _footballConnectionString = "Server=localhost;database=ConfORMSample_FootballMsgt;Integrated Security=SSPI;";

            _footballAssemblies = new List<string>
                              {
                                  "ConfORMSample.Football.Entities.dll"
                              };

            _footballConfigBuilder = new Football.SqlServerConfORMConfigBuilder(_footballAssemblies, "ConfORMSample_FootballMsgt.dbo");

            NHibernateSession.Init(_footballConfigBuilder, _sessionStorage, _footballConnectionString, "FootballMgt");
        }
 public PrepareAuthenticationContext(ISessionStorage sessionStorage, Uri requestUri, string redirectPath, IDictionary<string, string> parameters)
 {
     RequestUri = requestUri;
     SessionStorage = sessionStorage;
     RedirectPath = redirectPath;
     Parameters = parameters;
 }
        public static INHibernateConfigurationService Init(ISessionStorage storage, INHibernateConfigurationService config)
        {
            Storage = storage;
            SessionFactory = config.CreateSessionFactory();

            return config;
        }
 public NHibernateSessionConfiguration(
     string sessionKey, 
     ISessionStorage sessionStorage, 
     IAutoPersistenceModelGenerator autoPersistenceModelGenerator) 
     : this(sessionKey, sessionStorage, autoPersistenceModelGenerator, new Dictionary<string, string>())
 {
 }
Beispiel #6
0
 public static void Init(Configuration configuration, ISessionStorage sessionStorage)
 {
     _sessionFactory = configuration.BuildSessionFactory();
     _sessionStorage = sessionStorage;
     #if DEBUG
     //            HibernatingRhinos.NHibernate.Profiler.Appender.NHibernateProfiler.Initialize();
     #endif
 }
		public static Configuration Init(
			ISessionStorage storage, 
			string[] mappingAssemblies,
			AutoPersistenceModel autoPersistenceModel,
			string cfgFile,
			string validatorCfgFile)
		{
			return Init(storage, mappingAssemblies, autoPersistenceModel, cfgFile, null, validatorCfgFile, null);
		}
 public void SetupMethod()
 {
     driver.Url = html5Page;
     hasWebStorageDriver = driver as IHasWebStorage;
     if (hasWebStorageDriver != null && hasWebStorageDriver.HasWebStorage)
     {
         storage = hasWebStorageDriver.WebStorage.SessionStorage;
     }
 }
 public NHibernateSessionConfiguration(
     string sessionKey, 
     ISessionStorage sessionStorage, 
     IAutoPersistenceModelGenerator autoPersistenceModelGenerator,
     IDictionary<string, string> nhibernateProperties)
 {
     this.SessionKey = sessionKey;
     this.SessionStorage = sessionStorage;
     this.AutoPersistenceModelGenerator = autoPersistenceModelGenerator;
     this.nhibernateConfigurationProperties = this.MergeWithDefaultPropertySet(nhibernateProperties);
 }
Beispiel #10
0
        public static void Configure(ISessionStorage storage)
        {
            var internalTypes = new[] { typeof(ApplicationUser) };

            var mapping = MappingHelper.GetIdentityMappings(internalTypes);
            //System.Diagnostics.Debug.WriteLine(mapping.AsString());

            var newMapping = mapping.AsString().Split(); // 6-16-14 added to handle error : RPA
            //var configuration = NHibernateSession.Init(storage, newMapping);
            //BuildSchema(configuration);
        }
Beispiel #11
0
 public static void Initialize(bool http)
 {
     if (http)
     {
         SessionSource = new HttpSessionSource();
     }
     else
     {
         SessionSource = new ThreadSessionSource();
     }
 }
        public static void Configure(ISessionStorage storage)
        {
            var internalTypes = new[] {
                typeof(ApplicationUser)
            };

            var mapping = MappingHelper.GetIdentityMappings(internalTypes);
            System.Diagnostics.Debug.WriteLine(mapping.AsString());

            var configuration = NHibernateSession.Init(storage, mapping);
            BuildSchema(configuration);
        }
		public static Configuration Init(
			ISessionStorage storage,
			string[] mappingAssemblies,
			AutoPersistenceModel autoPersistenceModel,
			string cfgFile,
			IDictionary<string, string> cfgProperties,
			string validatorCfgFile,
			IPersistenceConfigurer persistenceConfigurer)
		{
			InitStorage(storage);
			return AddConfiguration(DefaultFactoryKey, mappingAssemblies, autoPersistenceModel, cfgFile, cfgProperties, validatorCfgFile, persistenceConfigurer);
		}
Beispiel #14
0
        public static void InitialiseNHibernateSessions(ISessionStorage session)
        {
            var factory = Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("nhibernate-template")).ShowSql().AdoNetBatchSize(100))
                .Mappings(m => m.UsePersistenceModel(new AutoPersistenceModelGenerator().Generate()))
                .ExposeConfiguration(cfg =>
                {
                    cfg.SetProperty("connection.release_mode", "auto");
                })
                .BuildConfiguration();

            NHibernateSession.InitStorage(session);
            NHibernateSession.AddConfiguration(NHibernateSession.DefaultFactoryKey, factory.BuildSessionFactory(), factory, string.Empty);
        }
Beispiel #15
0
        public void InitDatalayer(ISessionStorage sessionStorage)
        {
            /*
             * Ugly hack?
             *  The thought was that if the file doesnt exist - use template for basic configuration,
             *  Then ask user to enter location of sql-server, username password etc.
             */
            var templateConfigFile = nHibernateConfig.Replace(".config", ".template.config");
            if (!File.Exists(nHibernateConfig) && File.Exists(templateConfigFile))
            {
                File.Copy(templateConfigFile, nHibernateConfig);
            }

            bootstrapper.InitNhibernateSession(sessionStorage, nHibernateConfig);
        }
Beispiel #16
0
        public void InitNhibernateSession(ISessionStorage sessionStorage, string nHibernateConfig)
        {
            var assembly = Assembly.GetAssembly(typeof(User));
            var mappingAssembly = assembly.CodeBase.ToLower();

            try {
                NHibernateSession.Init(sessionStorage,
                    new[] {mappingAssembly},
                    new AutoPersistenceModelGenerator().Generate(),
                    nHibernateConfig);
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
Beispiel #17
0
        public SessionManager(ISessionStorage storage)
        {
            _storage = storage;

            Configuration configuration = new Configuration().Configure();

            InitValidator(configuration);

            configuration.EventListeners.FlushEntityEventListeners = new IFlushEntityEventListener[] { new FlushEntityEventListener() };

            var validateFieldsEventListener = new ValidateFieldsEventListener(_validatorEngine);
            configuration.EventListeners.PreInsertEventListeners = new IPreInsertEventListener[] { validateFieldsEventListener, new ValidatePreInsertEventListener() };
            configuration.EventListeners.PreUpdateEventListeners = new IPreUpdateEventListener[] { validateFieldsEventListener, new ValidatePreUpdateEventListener() };

            _factory = InitFluentMappings(configuration).BuildSessionFactory();
        }
Beispiel #18
0
        public static void Configure(ISessionStorage storage)
        {
            var internalTypes = new[] {
                typeof(IdentityUser)
            };

            var mapping = MappingHelper.GetIdentityMappings(internalTypes);

            string[] mappings = new string[mapping.Items.Length];

            for (int i = 0; i < mapping.Items.Length; i++)
            {
                mappings[i] = mapping.Items[i].ToString();
            }

            NHibernateSession.Init(storage, mappings);
        }
Beispiel #19
0
        public WebNHUnitOfWork(ISessionStorage sessionStorage, ILog log)
        {
            if (sessionStorage == null)
            {
                throw Error.ArgumentNull("sessionStorage");
            }

            if (log == null)
            {
                throw Error.ArgumentNull("log");
            }

            Log = log;

            SessionStorage = sessionStorage;

            SubscribeToSessionAddedEvent();

            WrappedSessions = sessionStorage.GetAll().Select(s => new SessionUnitOfWork(s, Log)).ToList();
        }
Beispiel #20
0
        public SessionManager(ISessionStorage sessionStorage, ISessionFactoryManager sessionFactoryManager, ILog log)
        {
            if (sessionStorage == null)
            {
                throw Error.ArgumentNull("sessionStorage");
            }

            if (sessionFactoryManager == null)
            {
                throw Error.ArgumentNull("sessionFactoryManager");
            }

            if (log == null)
            {
                throw Error.ArgumentNull("log");
            }

            SessionStorage = sessionStorage;
            SessionFactoryManager = sessionFactoryManager;
            Log = log;
        }
Beispiel #21
0
        static Session()
        {
            try
            {
                System.Web.ProcessModelInfo.GetCurrentProcessInfo();
                http = true;
            }
            catch (System.Web.HttpException)
            {

            }
            catch (System.Security.SecurityException)
            {
                http = true;
            }

            if (http)
                _sessionsource = new HttpSessionSource();
            else
                _sessionsource = new ThreadSessionSource();
        }
Beispiel #22
0
 //public static void Initialize(ISessionStorage storage, IInterceptor interceptor)
 //{
 //    _sessionSource = storage;
 //    _sessionFactory = new SessionFactory(interceptor);
 //}
 public static void Initialize(ISessionStorage storage, SessionFactoryEventListeners eventListeners)
 {
     _sessionSource = storage;
     _sessionFactory = new SessionFactory(eventListeners);
 }
        /// <summary>
        ///     To facilitate unit testing, this method will reset this object back to its
        ///     original state before it was configured.
        /// </summary>
        public static void Reset()
        {
            if (Storage != null)
            {
                foreach (var session in Storage.GetAllSessions())
                {
                    session.Dispose();
                }
            }

            SessionFactories.Clear();

            Storage = null;
            registeredInterceptor = null;
            ConfigurationCache = null;
        }
 public static Configuration Init(
     ISessionStorage storage, 
     string[] mappingAssemblies, 
     AutoPersistenceModel autoPersistenceModel, 
     string cfgFile, 
     IDictionary<string, string> cfgProperties, 
     string validatorCfgFile, 
     IPersistenceConfigurer persistenceConfigurer)
 {
     InitStorage(storage);
     try
     {
         return AddConfiguration(
             DefaultFactoryKey, 
             mappingAssemblies, 
             autoPersistenceModel, 
             cfgFile, 
             cfgProperties, 
             validatorCfgFile, 
             persistenceConfigurer);
     }
     catch
     {
         // If this NHibernate config throws an exception, null the Storage reference so 
         // the config can be corrected without having to restart the web application.
         Storage = null;
         throw;
     }
 }
 public static Configuration Init(
     ISessionStorage storage, string[] mappingAssemblies, AutoPersistenceModel autoPersistenceModel)
 {
     return Init(storage, mappingAssemblies, autoPersistenceModel, null, null, null, null);
 }
 public static Configuration Init(ISessionStorage storage, string[] mappingAssemblies)
 {
     return Init(storage, mappingAssemblies, null, null, null, null, null);
 }
 public ProcessAuthenticationContext(IHttpRequest request, ISessionStorage sessionStorage)
 {
     Request        = request;
     SessionStorage = sessionStorage;
 }
Beispiel #28
0
 public static Configuration Init(
     ISessionStorage storage, string[] mappingAssemblies, string cfgFile, string validatorCfgFile)
 {
     return(Init(storage, mappingAssemblies, null, cfgFile, null, validatorCfgFile, null));
 }
Beispiel #29
0
 public void Init()
 {
     _sessionStorage = new SimpleSessionStorage();
     Util.InitStorage(_applicationStorage);
 }
Beispiel #30
0
 public static Configuration Init(
     ISessionStorage storage, string[] mappingAssemblies, AutoPersistenceModel autoPersistenceModel)
 {
     return(Init(storage, mappingAssemblies, autoPersistenceModel, null, null, null, null));
 }
Beispiel #31
0
 public static void InitStorage(ISessionStorage storage)
 {
     Check.Require(storage != null, "storage mechanism was null but must be provided");
     Check.Require(Storage == null, "A storage mechanism has already been configured for this application");
     Storage = storage;
 }
 public StatisticsService(ISessionStorage sessionStorage)
 {
     _sessionStorage = sessionStorage;
 }
Beispiel #33
0
 public SessionController(ISessionStorage storage)
 {
     _storage = storage;
 }
Beispiel #34
0
 public GameService(ISessionStorage <PlayerStats> sv, IEveryArea ea)
 {
     _sv   = sv;
     _ea   = ea;
     State = new PlayerStats();
 }
        /// <summary>
        /// Return value or throws exception.
        /// </summary>
        public static async Task <TValue> Get <TValue>(this ISessionStorage @this, string key)
        {
            var res = await @this.Get(typeof(TValue), key);

            return((TValue)res);
        }
Beispiel #36
0
 public static Configuration Init(
     ISessionStorage storage, string[] mappingAssemblies, IDictionary <string, string> cfgProperties)
 {
     return(Init(storage, mappingAssemblies, null, null, cfgProperties, null, null));
 }
 static SessionBuilder()
 {
     //if (SessionMode == "HttpSession") _sessionStorage = new HttpSessionStorage();
     //else _sessionStorage = new ThreadSessionStorage();
     _sessionStorage = SessionStorageFactory.SessionStorageInstance;
 }
Beispiel #38
0
 public static Configuration Init(ISessionStorage storage, string[] mappingAssemblies)
 {
     return(Init(storage, mappingAssemblies, null, null, null, null, null));
 }
 public static Configuration Init(
     ISessionStorage storage, string[] mappingAssemblies, string cfgFile, string validatorCfgFile)
 {
     return Init(storage, mappingAssemblies, null, cfgFile, null, validatorCfgFile, null);
 }
 public WcfSessionStorage(ISessionStorage fallbackSessionStorage)
 {
     this.FallbackSessionStorage = fallbackSessionStorage;
 }
 public static Configuration Init(
     ISessionStorage storage, 
     string[] mappingAssemblies, 
     AutoPersistenceModel autoPersistenceModel, 
     IDictionary<string, string> cfgProperties)
 {
     return Init(storage, mappingAssemblies, autoPersistenceModel, null, cfgProperties, null, null);
 }
Beispiel #42
0
 /// <summary>
 /// 使用Redis作为Session的存储方案
 /// </summary>
 public static void UseRedisSessionStorage()
 {
     Default = new RedisSessionStorage();
 }
 public static void InitStorage(ISessionStorage storage)
 {
     Check.Require(storage != null, "storage mechanism was null but must be provided");
     Check.Require(Storage == null, "A storage mechanism has already been configured for this application");
     Storage = storage;
 }
Beispiel #44
0
 /// <summary>
 /// 使用内存作为Session的存储方案
 /// </summary>
 public static void UseMemorySessionStorage()
 {
     Default = new MemorySessionStorage();
 }
Beispiel #45
0
 public SessionService(ISessionStorage storage)
 {
     _storage = storage;
 }
 public GameService(ISessionStorage <GameState> ss, ILocationProvider lp)
 {
     _ss   = ss;
     _lp   = lp;
     State = new GameState();
 }
 public HomeController(IUserService userService, ISessionStorage sessionStorage)
 {
     _userService = userService;
     _sessionStorage = sessionStorage;
 }
Beispiel #48
0
 public OrdersController(IOrdersService ordersService, IDishService dishService, ISessionStorage sessionStorage,
                         IOrderQueueService queueService)
 {
     this.queueService   = queueService;
     this.ordersService  = ordersService;
     this.dishService    = dishService;
     this.sessionStorage = sessionStorage;
 }
 public RoundService(ISessionStorage sessionStorage)
 {
     _sessionStorage = sessionStorage;
 }
 public TrapModel(ISessionStorage <GameState> ss, ILocationProvider lp)
 {
     _ss = ss;
     _lp = lp;
 }