public void TestMethod() { var config = new ContextConfiguration <EuropaContext>() .WithConnection("server=(local);database=BitDiamondDb;user id=sa;password=developer;Max Pool Size=1000;Min Pool Size=10;pooling=true;multipleactiveresultsets=True;") .WithEFConfiguraton(_efc => { _efc.LazyLoadingEnabled = false; _efc.ProxyCreationEnabled = false; }) .WithInitializer(new System.Data.Entity.DropCreateDatabaseIfModelChanges <EuropaContext>()) .UsingModule(new IdentityAccessModuleConfig()) .UsingModule(new AuthenticationAccessModuleConfig()) .UsingModule(new RBACAccessModuleConfig()) .UsingModule(new BitDiamondModuleConfig()); var cxt = new EuropaContext(config); var q = new BitLevelQuery(cxt, new ReferralQuery(cxt)); var x = q.BaseBitLevelQuery().Where(_jo => _jo.Level.UserId == "*****@*****.**"); Console.WriteLine(x.ToArray().Length); var r = x.AsEnumerable(); var u = r.Select(_r => _r.ToBitLevel()); var uar = u.ToArray(); Console.WriteLine(uar.Length); }
public void TestMethod1() { var config = new ContextConfiguration <EuropaContext>() .WithConnection("server=(local);database=BitDiamondDb;user id=sa;password=developer;Max Pool Size=1000;Min Pool Size=10;pooling=true;multipleactiveresultsets=True;") .WithEFConfiguraton(_efc => { _efc.LazyLoadingEnabled = false; _efc.ProxyCreationEnabled = false; }) .WithInitializer(new System.Data.Entity.DropCreateDatabaseIfModelChanges <EuropaContext>()) .UsingModule(new IdentityAccessModuleConfig()) .UsingModule(new AuthenticationAccessModuleConfig()) .UsingModule(new RBACAccessModuleConfig()) .UsingModule(new BitDiamondModuleConfig()); var cxt = new EuropaContext(config); var bcQuery = new BlockChainQuery(cxt); var start = DateTime.Now; var r = bcQuery.GetPagedOutgoingUserTransactions(new User { EntityId = "*****@*****.**" }, 10, 0); Console.WriteLine(DateTime.Now - start); }
public static Container RegisterTypes(Container c) { var gen = new ProxyGenerator(); //proxy generator that enables lazy service loading var coreAssembly = typeof(BaseModel <>).Assembly; //register the container c.Register(() => c, Lifestyle.Singleton); #region infrastructure service registration var cache = new WeakCache(); c.Register <OwinContextProvider, OwinContextProvider>(Lifestyle.Scoped); c.Register <IStorageConnection>(() => new SqlServerStorage("HangfireDb").GetConnection(), Lifestyle.Scoped); c.RegisterLazyService <ICredentialHasher, DefaultHasher>(Lifestyle.Scoped); c.RegisterLazyService <IBlobStore, FileSystemBlobStore>(Lifestyle.Scoped); c.RegisterLazyService <IEmailPush, ElasticMailPushService>(Lifestyle.Singleton); c.RegisterLazyService <IAppUrlProvider, UrlProvider>(Lifestyle.Scoped); c.RegisterLazyService <IPersistenceCommands, SimplePersistenceCommands>(Lifestyle.Scoped); c.RegisterLazyService <IBackgroundOperationScheduler, Services.Hangfire.HangfireJobScheduler>(Lifestyle.Scoped); c.RegisterLazyService <IUserContext, UserContext>(Lifestyle.Scoped); #endregion #region domain/domain-service registration #region Jupiter //shared context configuration. var config = WebConstants.Misc_UniversalEuropaConfig; c.Register(() => config, Lifestyle.Singleton); //scoped europa context c.Register <IDataContext, EuropaContext>(Lifestyle.Scoped); //doesnt need lazy initialization #endregion #region queries c.RegisterLazyService <Core.Services.Query.IAccountQuery, Data.EF.Query.AccountQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IBlockChainQuery, Data.EF.Query.BlockChainQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IBitLevelQuery, Data.EF.Query.BitLevelQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IContextVerifierQuery, Data.EF.Query.ContextVerifierQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IReferralQuery, Data.EF.Query.ReferralQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.ISettingsQuery, Data.EF.Query.SettingsQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IUserContextQuery, Data.EF.Query.UserContextQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IUserNotifierQuery, Data.EF.Query.UserNotifierQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IPostQuery, Data.EF.Query.PostQuery>(Lifestyle.Scoped); #endregion #region Axis.Pollux.Identity #endregion #region Axis.Pollux.Authentication c.RegisterLazyService <ICredentialAuthentication, CredentialAuthentication>(Lifestyle.Scoped); #endregion #region Axis.Pollux.RBAC //5 stars for this, bruh!!! c.Register <IUserAuthorization>(() => { var europa = new EuropaContext(c.GetInstance <ContextConfiguration <EuropaContext> >()); return(new CachableRoleAuthority(europa)); }, Lifestyle.Singleton); #endregion #region BitDiamond.Core.Models/BitDiamond.Core.Services c.RegisterLazyService <IAccountManager, AccountManager>(Lifestyle.Scoped); c.RegisterLazyService <IBitLevelManager, BitLevelManager>(Lifestyle.Scoped); c.RegisterLazyService <IBlockChainService, BlockChainService>(Lifestyle.Scoped); c.RegisterLazyService <IContextVerifier, ContextVerifier>(Lifestyle.Scoped); c.RegisterLazyService <IReferralManager, ReferralManager>(Lifestyle.Scoped); c.RegisterLazyService <ISettingsManager, SettingsManager>(Lifestyle.Scoped); c.RegisterLazyService <IPostService, PostService>(Lifestyle.Scoped); c.RegisterLazyService <IUserNotifier, UserNotifier>(Lifestyle.Scoped); #endregion #endregion #region webapi controller registration var wapict = typeof(ApiController); typeof(DIRegistrations).Assembly.GetTypes() .Where(_t => _t.BaseTypes().Contains(wapict)) .ForAll((_cnt, _t) => c.Register(_t, _t, Lifestyle.Scoped)); #endregion #region mvc controller registration var webct = typeof(Controller); typeof(DIRegistrations).Assembly.GetTypes() .Where(_t => _t.BaseTypes().Contains(webct)) .ForAll((_cnt, _t) => c.Register(_t, _t, Lifestyle.Scoped)); #endregion return(c); }
public static Container RegisterTypes(Container c) { var gen = new ProxyGenerator(); //proxy generator that enables lazy service loading var coreAssembly = typeof(BaseModel <>).Assembly; //register the container c.Register(() => c, Lifestyle.Singleton); #region infrastructure service registration var cache = new WeakCache(); //authorization server is a special case where it is created in the singleton scope, but relies on some services that are registered in ScopedLifeStyles... //thus we explicitly create the instance of the authorization server. //c.Register<IOAuthAuthorizationServerProvider>(() => c.GetInstance<AuthorizationServer>()); //c.Register(() => //{ // var europa = new EuropaContext(c.GetInstance<ContextConfiguration<EuropaContext>>()); // var credentialAuthenticator = new CredentialAuthentication(europa, new DefaultHasher()); // return new AuthorizationServer(credentialAuthenticator, europa, cache); //}, Lifestyle.Singleton); ////bearer authentication provider is a special case where it is created in the singleton scope, but relies on some services that are registered in ScopedLifeStyles... ////thus we explicitly create the instance of the authentication provider. //c.Register<IOAuthBearerAuthenticationProvider>(() => c.GetInstance<BearerAuthenticationProvider>()); //c.Register(() => //{ // return new BearerAuthenticationProvider(cache); //}, Lifestyle.Singleton); c.Register <OwinContextProvider, OwinContextProvider>(Lifestyle.Scoped); c.RegisterLazyService <ICredentialHasher, DefaultHasher>(Lifestyle.Scoped); c.RegisterLazyService <IBlobStore, FileSystemBlobStore>(Lifestyle.Scoped); c.RegisterLazyService <IEmailPush, ElasticMailPushService>(Lifestyle.Singleton); c.RegisterLazyService <IAppUrlProvider, UrlProvider>(Lifestyle.Scoped); c.RegisterLazyService <IPersistenceCommands, SimplePersistenceCommands>(Lifestyle.Scoped); c.RegisterLazyService <IUserContext, _UserContext>(Lifestyle.Scoped); #endregion #region domain/domain-service registration #region Jupiter //shared context configuration. var config = WebConstants.Misc_UniversalEuropaConfig; c.Register(() => config, Lifestyle.Singleton); //scoped europa context c.Register <IDataContext, EuropaContext>(Lifestyle.Scoped); //doesnt need lazy initialization #endregion #region queries c.RegisterLazyService <Core.Services.Query.IAccountQuery, Data.EF.Query.AccountQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IBlockChainQuery, Data.EF.Query.BlockChainQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IBitLevelQuery, Data.EF.Query.BitLevelQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IContextVerifierQuery, Data.EF.Query.ContextVerifierQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IReferralQuery, Data.EF.Query.ReferralQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.ISettingsQuery, Data.EF.Query.SettingsQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IUserContextQuery, Data.EF.Query.UserContextQuery>(Lifestyle.Scoped); c.RegisterLazyService <Core.Services.Query.IUserNotifierQuery, Data.EF.Query.UserNotifierQuery>(Lifestyle.Scoped); #endregion #region Axis.Pollux.Identity #endregion #region Axis.Pollux.Authentication c.RegisterLazyService <ICredentialAuthentication, CredentialAuthentication>(Lifestyle.Scoped); #endregion #region Axis.Pollux.RBAC c.Register <IUserAuthorization>(() => { var europa = new EuropaContext(c.GetInstance <ContextConfiguration <EuropaContext> >()); return(new CachableRoleAuthority(europa)); }, Lifestyle.Singleton); #endregion #region BitDiamond.Core.Models/BitDiamond.Core.Services c.RegisterLazyService <IAccountManager, Core.Services.AccountManager>(Lifestyle.Scoped); c.RegisterLazyService <IBitLevelManager, BitLevelManager>(Lifestyle.Scoped); c.RegisterLazyService <IBlockChainService, BlockChainService>(Lifestyle.Scoped); c.RegisterLazyService <IContextVerifier, ContextVerifier>(Lifestyle.Scoped); c.RegisterLazyService <IReferralManager, ReferralManager>(Lifestyle.Scoped); c.RegisterLazyService <ISettingsManager, SettingsManager>(Lifestyle.Scoped); c.RegisterLazyService <IUserNotifier, UserNotifier>(Lifestyle.Scoped); #endregion #endregion #region webapi controller registration var wapict = typeof(ApiController); typeof(DIRegistrations).Assembly.GetTypes() .Where(_t => _t.BaseTypes().Contains(wapict)) .ForAll((_cnt, _t) => c.Register(_t, _t, Lifestyle.Scoped)); #endregion #region mvc controller registration var webct = typeof(Controller); typeof(DIRegistrations).Assembly.GetTypes() .Where(_t => _t.BaseTypes().Contains(webct)) .ForAll((_cnt, _t) => c.Register(_t, _t, Lifestyle.Scoped)); #endregion return(c); }