protected override void ApplicationStartup(Autofac.ILifetimeScope container, Nancy.Bootstrapper.IPipelines pipelines) { CookieBasedSessions.Enable(pipelines); base.ApplicationStartup(container, pipelines); GlobalHost.DependencyResolver = new AutofacDependencyResolver(container); RouteTable.Routes.MapHubs(); }
protected override void Load(Autofac.ContainerBuilder builder) { builder.RegisterType<ServiceClientFactory>().As<IServiceClientFactory>().SingleInstance(); builder.RegisterInstance(new ZmqClient(new ZMQ.Context(), "tcp://localhost:8001", "tcp://localhost:8002")) .As<IClient>().SingleInstance(); builder.Register<ICatalogService>(ctx => ctx.Resolve<IServiceClientFactory>().CreateServiceClient<ICatalogService>(15000)); builder.Register<IFooService>(ctx => ctx.Resolve<IServiceClientFactory>().CreateServiceClient<IFooService>(15000)); }
protected override void Load(ContainerBuilder builder) { var players = new[] { new Player("Red"), new Player("Blue") }; builder.Register(_ => players).As<Player[]>().SingleInstance(); builder.RegisterType<RoundRobinTurns>().AsImplementedInterfaces().SingleInstance(); }
protected override void Load(Autofac.ContainerBuilder builder) { base.Load(builder); builder.Register<IBridgePayWS>(ctx => { var moqBridgePayWS = new Mock<IBridgePayWS>(); moqBridgePayWS.Setup(b => b.CPSGetAccountPackages(It.IsAny<String>(), It.IsAny<String>())) .Returns(MockData.CPSGetAccountPackages()); moqBridgePayWS.Setup(b => b.CPSGetCurrentAccountPackage(It.IsAny<String>(), It.IsAny<String>())) .Returns(MockData.CPSGetCurrentAccountPackage()); moqBridgePayWS.Setup( b => b.CPSGetAvailableAddOns(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>())) .Returns(MockData.CPSGetAvailableAddOns()); moqBridgePayWS.Setup( b => b.ListCountries() ).Returns(MockData.ListCountries()); moqBridgePayWS.Setup(b => b.ListIndustries()).Returns(MockData.ListIndustries()); moqBridgePayWS.Setup(b => b.CPSGetContactInfo(It.IsAny<String>(), It.IsAny<String>())) .Returns(MockData.CPSGetContactInfo()); return moqBridgePayWS.Object; }).InstancePerHttpRequest(); }
protected override void Load(Autofac.ContainerBuilder builder) { builder.RegisterType<FaceComparer>() .As<FaceComparer>() .WithProperty("FaceAlignmentModelPath", GetAbsolutePath(Properties.Settings.Default.FaceAlignModelFile)) .WithProperty("FaceAlignClassifierPath", GetAbsolutePath(Properties.Settings.Default.FaceAlignClassifierFile)) .WithProperty("FaceRepositoryPath", GetAbsolutePath(Properties.Settings.Default.FaceRepositoryPath)) .WithProperty("IlluminateReferenceFilePath", GetAbsolutePath(Properties.Settings.Default.IlluminateRefFilePath)) .PropertiesAutowired(); if (EnableFaceComparer) { if (System.IO.Directory.Exists(PersonOfInterestLibraryPath)) { var personRepository = SuspectsRepositoryManager.LoadFrom(PersonOfInterestLibraryPath); builder.RegisterInstance(personRepository.Peoples) .As<IEnumerable<PersonOfInterest>>() .ExternallyOwned(); } } else { builder.Register(c => new PersonOfInterest[0]).SingleInstance(); builder.RegisterType<NullRepositoryFaceComparer>() .As<IRepositoryFaceComparer>(); } }
private static void SetupExtensibility(Autofac.ContainerBuilder builder, bool withAspects) { var dynamicProxy = new CastleDynamicProxyProvider(); var aopRepository = new AspectRepository(dynamicProxy); var assemblies = Revenj.Utility.AssemblyScanner.GetAssemblies().Where(it => it.FullName.StartsWith("Revenj.")); builder.RegisterInstance(new PluginsConfiguration { Assemblies = assemblies }); builder.RegisterType<SystemInitialization>(); builder.RegisterType<AutofacObjectFactory>().As<IObjectFactory>().SingleInstance(); builder.RegisterType<AutofacMefProvider>().As<IExtensibilityProvider>().SingleInstance(); builder.RegisterGeneric(typeof(PluginRepository<>)).As(typeof(IPluginRepository<>)).SingleInstance(); builder.RegisterInstance(aopRepository).As<IAspectRegistrator, IAspectComposer, IInterceptorRegistrator>(); builder.RegisterInstance(dynamicProxy).As<IMixinProvider, IDynamicProxyProvider>(); if (withAspects) { foreach (var m in AssemblyScanner.GetAllTypes()) { if (m.IsPublic && typeof(Autofac.Module).IsAssignableFrom(m) && m.GetConstructor(new Type[0]) != null) builder.RegisterModule((Autofac.Module)Activator.CreateInstance(m)); } builder.RegisterModule(new AspectsModule(aopRepository)); } }
protected override void ConfigureContainerBuilder(Autofac.ContainerBuilder builder) { base.ConfigureContainerBuilder(builder); builder.RegisterControllers(typeof(MvcApplication).Assembly); builder.RegisterViewModels(typeof(MvcApplication).Assembly); }
protected override void Load(Autofac.ContainerBuilder builder) { base.Load(builder); builder.RegisterType<PosixIdentitySource>() .AsImplementedInterfaces() .InstancePerLifetimeScope(); }
protected override void Register(Autofac.ContainerBuilder builder) { builder.RegisterType<PlacementFileParser>().As<IPlacementFileParser>(); builder.RegisterType<StubCacheManager>().As<ICacheManager>(); builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>(); builder.RegisterType<InMemoryWebSiteFolder>().As<IWebSiteFolder>() .As<InMemoryWebSiteFolder>().InstancePerLifetimeScope(); }
public static void RunShopifyFulfillmentEmail() { var orderId = CommandLineHelpers.SolicitOrderShopifyId(); var fulfillmentId = CommandLineHelpers.SolicitShopifyFulfillmentId(1767491698732); Autofac.RunInScope(scope => { var instanceContext = scope.Resolve <InstanceContext>(); var fulfillmentApi = scope.Resolve <FulfillmentApi>(); var json = new { fulfillment = new { id = fulfillmentId, notify_customer = true, }, tracking_numbers = new [] { "1ZY1234567890" } }.SerializeToJson(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); fulfillmentApi.Update(orderId, fulfillmentId, json); }); }
public override System.Collections.Generic.IEnumerable<JavaScriptModuleDescriptor> RegisterJavaScriptModules(Autofac.ContainerBuilder containerBuilder, ICmsConfiguration configuration) { return new[] { blogJavaScriptModuleDescriptor }; }
public static void RunShopifyOrderTimezoneTest() { Console.WriteLine( Environment.NewLine + "Enter Shopify Order ID (Default ID: 1778846826540)"); var shopifyOrderId = Console.ReadLine().IsNullOrEmptyAlt("1778846826540").ToLong(); Autofac.RunInScope(scope => { var instanceContext = scope.Resolve <InstanceContext>(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); var shopifyOrderGet = scope.Resolve <ShopifyOrderGet>(); var acumaticaTimeZone = scope.Resolve <AcumaticaTimeZoneService>(); var order = shopifyOrderGet.Run(shopifyOrderId).order; var createdAt = order.created_at; var createdAtUtc = order.created_at.ToUniversalTime(); var acumaticaTime = acumaticaTimeZone.ToAcumaticaTimeZone(createdAtUtc.DateTime); }); }
protected override void Load(Autofac.ContainerBuilder builder) { base.Load(builder); builder.RegisterType<HtpasswdIdentitySource>() .AsImplementedInterfaces() .SingleInstance(); }
public override System.Collections.Generic.IEnumerable<string> RegisterStyleSheetFiles(Autofac.ContainerBuilder containerBuilder, ICmsConfiguration configuration) { return new[] { "/file/bcms-blog/Content/Styles/bcms.blog.css" }; }
/// <summary> /// Registers the jq service. /// </summary> /// <param name="builder">The builder.</param> protected static void RegisterApplicationJqService(Autofac.ContainerBuilder builder) { builder.RegisterType<Miaow.Application.jq.Service.AddSortService>() .As<Miaow.Application.jq.Service.IAddSortService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.ArticleService>() .As<Miaow.Application.jq.Service.IArticleService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.HomeService>() .As<Miaow.Application.jq.Service.IHomeService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.PageService>() .As<Miaow.Application.jq.Service.IPageService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.PicInfoService>() .As<Miaow.Application.jq.Service.IPicInfoService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.SearchService>() .As<Miaow.Application.jq.Service.ISearchService>().InstancePerHttpRequest(); ; builder.RegisterType<Miaow.Application.jq.Service.SightInfoService>() .As<Miaow.Application.jq.Service.ISightInfoService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.SinaInfoService>() .As<Miaow.Application.jq.Service.ISinaInfoService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.TicketService>() .As<Miaow.Application.jq.Service.ITicketService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.TopClassService>() .As<Miaow.Application.jq.Service.ITopClassService>().InstancePerHttpRequest(); builder.RegisterType<Miaow.Application.jq.Service.VideoInfoService>() .As<Miaow.Application.jq.Service.IVideoInfoService>().InstancePerHttpRequest(); }
protected override void Load(Autofac.ContainerBuilder builder) { builder.RegisterType<RestApplication>().As<RestApplication, IRestApplication>(); builder.RegisterType<SoapApplication>().As<SoapApplication, ISoapApplication>(); builder.RegisterType<CommandConverter>().As<ICommandConverter>(); SetupExtensibility(builder); if (WithDatabase) SetupPostgres(builder); SetupPatterns(builder); SetupSerialization(builder); builder.RegisterType<RepositoryAuthentication>().As<IAuthentication>(); builder.RegisterType<RepositoryPrincipalFactory>().As<IPrincipalFactory>(); builder.RegisterType<PermissionManager>().As<IPermissionManager>().SingleInstance(); builder.RegisterType<LogFactory>().As<ILogFactory>().SingleInstance(); builder.RegisterType<NLogLogger>().As<ILogger>(); builder.RegisterType(typeof(ProcessingEngine)).As(typeof(IProcessingEngine)).SingleInstance(); builder.RegisterType<OnContainerBuild>().As<IStartable>(); base.Load(builder); }
/// <summary> /// Registers the jq service. /// </summary> /// <param name="builder">The builder.</param> protected static void RegisterApplicationJqService(Autofac.ContainerBuilder builder) { builder.RegisterType<iPow.Application.jq.Service.AddSortService>() .As<iPow.Application.jq.Service.IAddSortService>(); builder.RegisterType<iPow.Application.jq.Service.ArticleService>() .As<iPow.Application.jq.Service.IArticleService>(); builder.RegisterType<iPow.Application.jq.Service.HomeService>() .As<iPow.Application.jq.Service.IHomeService>(); builder.RegisterType<iPow.Application.jq.Service.PageService>() .As<iPow.Application.jq.Service.IPageService>(); builder.RegisterType<iPow.Application.jq.Service.PicInfoService>() .As<iPow.Application.jq.Service.IPicInfoService>(); builder.RegisterType<iPow.Application.jq.Service.SearchService>() .As<iPow.Application.jq.Service.ISearchService>(); builder.RegisterType<iPow.Application.jq.Service.SightInfoService>() .As<iPow.Application.jq.Service.ISightInfoService>(); builder.RegisterType<iPow.Application.jq.Service.SinaInfoService>() .As<iPow.Application.jq.Service.ISinaInfoService>(); builder.RegisterType<iPow.Application.jq.Service.TicketService>() .As<iPow.Application.jq.Service.ITicketService>(); builder.RegisterType<iPow.Application.jq.Service.TopClassService>() .As<iPow.Application.jq.Service.ITopClassService>(); builder.RegisterType<iPow.Application.jq.Service.VideoInfoService>() .As<iPow.Application.jq.Service.IVideoInfoService>(); //add 2012-4-28 JPomichael builder.RegisterType<iPow.Application.jq.Service.SightInfoSortService>() .As<iPow.Application.jq.Service.ISightInfoSortService>(); //end }
public static void RunAcumaticaSalesOrderRetrieve() { var defaultSalesOrderNbr = "000046"; Console.WriteLine(Environment.NewLine + $"Enter Acumatica Sales Order ID (Default ID: {defaultSalesOrderNbr})"); var orderNbr = Console.ReadLine().Trim().IsNullOrEmptyAlt(defaultSalesOrderNbr); Autofac.RunInScope(scope => { var instanceContext = scope.Resolve <InstanceContext>(); var salesOrderClient = scope.Resolve <SalesOrderClient>(); var acumaticaContext = scope.Resolve <AcumaticaHttpContext>(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); acumaticaContext.SessionRun(() => { var json = salesOrderClient .RetrieveSalesOrder(orderNbr, SalesOrderType.SO, Expand.Details_Totals); var salesOrderObj = json.ToSalesOrderObj(); var taxSnapshot = salesOrderObj.custom.Document.UsrTaxSnapshot; var taxJson = taxSnapshot.value.Unzip(); Console.WriteLine(taxJson); }); }); }
protected override void ConfigureRequestContainer(Autofac.ILifetimeScope existingContainer) { var builder = new ContainerBuilder(); builder.RegisterType<IdeastrikeContext>() .AsSelf() .SingleInstance(); builder.RegisterType<IdeaRepository>() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType<ActivityRepository>() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType<FeatureRepository>() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType<SettingsRepository>() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType<UserRepository>() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType<ImageRepository>() .AsImplementedInterfaces() .SingleInstance(); builder.Update(existingContainer.ComponentRegistry); }
/// <summary> /// Override to add registrations to the container. /// </summary> /// <param name="builder">The builder through which components can be /// registered.</param> /// <remarks> /// Note that the ContainerBuilder parameter is unique to this module. /// </remarks> protected override void Load(Autofac.ContainerBuilder builder) { var assemblies = Assembly.GetExecutingAssembly(); builder.RegisterAssemblyTypes(assemblies).As<IRunAfterEachRequest>().InstancePerRequest(); builder.RegisterAssemblyTypes(assemblies).As<IRunAtStartup>(); builder.RegisterAssemblyTypes(assemblies).As<IRunOnEachRequest>().InstancePerRequest(); builder.RegisterAssemblyTypes(assemblies).As<IRunOnError>(); }
protected override void Load(Autofac.ContainerBuilder builder) { builder.RegisterAssemblyTypes(Assembly.Load("EF-Learn.DAL")) .Where(t => t.Name.EndsWith("Dal")) .AsImplementedInterfaces() .InstancePerLifetimeScope(); base.Load(builder); }
protected override void Load(Autofac.ContainerBuilder builder) { base.Load(builder); builder.Register<FogBugzProblemReporter>(c => new FogBugzProblemReporter()) .As<IProblemReporter>() .SingleInstance(); }
public void CallInitializer() { dynamic factory = _container.Resolve<IShapeFactory>(); var bar = new {One = 1, Two = "two"}; var foo = factory.Foo(bar); Assert.That(foo.One, Is.EqualTo(1)); Assert.That(foo.Two, Is.EqualTo("two")); }
protected override void AttachToComponentRegistration(Autofac.Core.IComponentRegistry componentRegistry, Autofac.Core.IComponentRegistration registration) { if (typeof(IDataServicesProvider).IsAssignableFrom(registration.Activator.LimitType)) { var propertyInfo = registration.Activator.LimitType.GetProperty("ProviderName", BindingFlags.Static | BindingFlags.Public); if (propertyInfo != null) { registration.Metadata["ProviderName"] = propertyInfo.GetValue(null, null); } } }
protected override void Load(Autofac.ContainerBuilder builder) { base.Load(builder); builder .Register<DefaultFulltextSupport>(c => new DefaultFulltextSupport()) .As<IFulltextSupport>() .SingleInstance(); }
protected override void Load(Autofac.ContainerBuilder builder) { base.Load(builder); builder .RegisterType<MailtoMailSender>() .As<IMailSender>() .SingleInstance(); // Stateless }
public void CallInitializerWithBaseType() { dynamic factory = _container.Resolve<IShapeFactory>(); var bar = new { One = 1, Two = "two" }; var foo = factory.Foo(typeof(MyShape), bar); Assert.That(foo, Is.InstanceOf<MyShape>()); Assert.That(foo.One, Is.EqualTo(1)); Assert.That(foo.Two, Is.EqualTo("two")); }
protected override void SetupBuilder(Autofac.ContainerBuilder builder) { base.SetupBuilder(builder); builder.RegisterModule(new Zetbox.API.ApiModule()); builder.RegisterModule(new Zetbox.API.Client.ClientApiModule()); builder.RegisterModule(new Zetbox.API.Client.HttpClientModule()); builder.RegisterModule(new Zetbox.DalProvider.Memory.MemoryProvider()); }
public static void SetupServerDb(DB_TestingHelper dbTestingHelper, Autofac.IContainer autofacContainer) { //server sql dist TI.trace("Remove all tables from Server distributr"); dbTestingHelper.RemoveAllServerTables(); IInsertTestData td = autofacContainer.Resolve<IInsertTestData>(); CokeDataContext ctxServer = autofacContainer.Resolve<CokeDataContext>(); TI.trace("Run scripts and add data to server"); dbTestingHelper.SetupServerSql(true, ctxServer, td); }
//加载配置到ViewBag public static void LoadSetting(Autofac.Core.IActivatedEventArgs<object> handler) { ControllerBase controllerBase = handler.Instance as ControllerBase; IDictionary<string, string> settings = handler.Context.Resolve<ISettingService>().GetAllSetting(); foreach (var setting in settings) { controllerBase.ViewData[setting.Key] = setting.Value; } controllerBase.ViewData["User"] = handler.Context.Resolve<IUserService>().GetLoginUser(); }
protected override void Load(Autofac.ContainerBuilder builder) { RegisterCommands(builder); RegisterViewModels(builder); RegisterViews(builder); base.Load(builder); }
protected override void Load(Autofac.ContainerBuilder builder) { base.Load(builder); builder .RegisterType<CachingMetaDataResolver>() .As<CachingMetaDataResolver>() .As<IMetaDataResolver>() .SingleInstance(); }
protected override void ConfigureApplicationContainer(Autofac.ILifetimeScope existingContainer) { var builder = new ContainerBuilder(); builder.RegisterAssemblyModules(Assembly.GetExecutingAssembly()); builder.Update(existingContainer.ComponentRegistry); ServiceLocator.SetLocatorProvider(() => new AutofacServiceLocator(existingContainer)); }
public SpellMacroPage() { InitializeComponent(); ViewModel = Autofac.Resolve <SpellMacroViewModel>(); ViewModel.Prepare(); ViewModel.Initialize().SafeFireAndForget(); var applicationView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView(); }
public static void RunShopifyFulfillmentPut() { Autofac.RunInScope(scope => { var instanceContext = scope.Resolve <InstanceContext>(); var shopifyFulfillmentPut = scope.Resolve <ShopifyFulfillmentPut>(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); shopifyFulfillmentPut.Run(); }); }
public static void RunShopifyOrderGet() { Autofac.RunInScope(scope => { var instanceContext = scope.Resolve <InstanceContext>(); var shopifyOrderGet = scope.Resolve <ShopifyOrderGet>(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); shopifyOrderGet.RunAutomatic(); }); }
public static void RunAcumaticaOrderSync() { var shopifyOrderId = CommandLineHelpers.SolicitOrderShopifyId(); Autofac.RunInScope(scope => { var instanceContext = scope.Resolve <InstanceContext>(); var acumaticaContext = scope.Resolve <AcumaticaHttpContext>(); var orderSync = scope.Resolve <AcumaticaOrderPut>(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); acumaticaContext.SessionRun(() => orderSync.RunOrder(shopifyOrderId)); }); }
public static void RunAcumaticaOrderGet() { Autofac.RunInScope(scope => { var instanceContext = scope.Resolve <InstanceContext>(); var acumaticaOrderGet = scope.Resolve <AcumaticaOrderGet>(); var acumaticaContext = scope.Resolve <AcumaticaHttpContext>(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); acumaticaContext.SessionRun(() => { acumaticaOrderGet.RunAutomatic(); }); }); }
public static void RunShopifyOrderRetrieve() { Autofac.RunInScope(scope => { var id = CommandLineHelpers.SolicitOrderShopifyId(); var instanceContext = scope.Resolve <InstanceContext>(); var shopifyOrderApi = scope.Resolve <OrderApi>(); var logger = scope.Resolve <IPushLogger>(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); var json = shopifyOrderApi.Retrieve(id); var compressed = json.SerializeToJson(Formatting.None).ToBase64Zip(); logger.Info($"Shopify Order size: {json.Length} bytes - (compressed {compressed.Length} bytes)"); }); }
public static void RunAcumaticaPaymentGet() { Autofac.RunInScope(scope => { var instanceContext = scope.Resolve <InstanceContext>(); var acumaticaContext = scope.Resolve <AcumaticaHttpContext>(); var paymentClient = scope.Resolve <PaymentClient>(); var TestInstanceId = CommandLineHelpers.SolicitInstanceId(); instanceContext.Initialize(TestInstanceId); acumaticaContext.SessionRun(() => { var result = paymentClient.RetrievePayment("000014", "PMT"); // "ApplicationHistory"); // "DocumentsToApply"); }); }); }
public MacroSelectionPage() : base() { InitializeComponent(); ViewModel = Autofac.Resolve <MacroSelectionViewModel>(); }
public UbiquitiPollerHostedService(ILifetimeScope autofac) : base(autofac) { _ubiProvider = Autofac.Resolve <UbiquitiStatsProvider>(); }