示例#1
1
        static RequestContext RequestContextFactory(IComponentContext context)
        {
            var httpContextAccessor = context.Resolve<IHttpContextAccessor>();
            var httpContext = httpContextAccessor.Current();
            if (httpContext != null)
            {

                var mvcHandler = httpContext.Handler as MvcHandler;
                if (mvcHandler != null)
                {
                    return mvcHandler.RequestContext;
                }

                var hasRequestContext = httpContext.Handler as IHasRequestContext;
                if (hasRequestContext != null)
                {
                    if (hasRequestContext.RequestContext != null)
                        return hasRequestContext.RequestContext;
                }
            }
            else
            {
                httpContext = HttpContextBaseFactory(context);
            }

            return new RequestContext(httpContext, new RouteData());
        }
 public static BusBuilderConfiguration WithAutofacDefaults(this BusBuilderConfiguration configuration, IComponentContext componentContext)
 {
     return configuration
         .WithTypesFrom(componentContext.Resolve<ITypeProvider>())
         .WithDependencyResolver(componentContext.Resolve<IDependencyResolver>())
         ;
 }
        internal void Start(IComponentContext context)
        {
            var engine = context.Resolve<ClientEngine>();
            var dhtListner = context.Resolve<DhtListener>();
            var dht = context.Resolve<IDhtEngine>();
            var settingsUtility = context.Resolve<ISettingsUtility>();

            var port = settingsUtility.Read(ApplicationConstants.TorrentPortKey,
                   ApplicationConstants.DefaultTorrentPort);

          OpenPort(port);

            // register the dht engine
            engine.RegisterDht(dht);

            // start the dht listener
            dhtListner.Start();

            // annnnnddd start the dht engine
            engine.DhtEngine.Start();
            
            // clear up torrent folder
            Task.Factory.StartNew(async () =>
            {
                var torrentsFolder = engine.Settings.SaveFolder;
                await StorageHelper.DeleteFolderContentAsync(torrentsFolder);
            });
        }
示例#4
0
 private static ITwitterFeed OnStartupExtracted(IComponentContext ctx, bool useTwitter)
 {
     if (useTwitter)
         return ctx.Resolve<TwitterFeedAsync>();
     else
         return ctx.Resolve<FakeTwitterFeed>();
 }
示例#5
0
 public AgencyBanks(IComponentContext container)
 {
         this.iContainer = container;
         queueConfiguration = iContainer.Resolve<IQueueConfiguration>();
         publisher = iContainer.Resolve<IExchangePublisher<Job>>();
         publisher.Declare(queueConfiguration.ResponseExchangeName);
 }
示例#6
0
        private static ISessionFactory ConfigureSessionFactory(IComponentContext context)
        {
            var connectionStringProvider = context.Resolve<IConnectionStringProvider>();
            EntryMapping.CurrentSchema = connectionStringProvider.Schema;
            var databaseProvider = context.ResolveNamed<IDatabaseProvider>(connectionStringProvider.DatabaseProvider.ToLower());

            var databaseConfiguration = databaseProvider.GetDatabaseConfiguration(connectionStringProvider);
            var configuration =
                Fluently
                    .Configure()
                    .Database(databaseConfiguration)
                    .Mappings(m =>
                                  {
                                      m.FluentMappings.AddFromAssembly(System.Reflection.Assembly.GetExecutingAssembly());

                                      //Scan extensions for nHibernate mappings
                                      var extension = context.Resolve<IEnumerable<ScriptedExtension>>();
                                      foreach (var assembly in extension.Select(provider => provider.SourceAssembly))
                                      {
                                          m.FluentMappings.AddFromAssembly(assembly);
                                      }
                                  })
                    .ProxyFactoryFactory(typeof (DefaultProxyFactoryFactory));

            return configuration.BuildSessionFactory();
        }
 protected virtual ITransportMessages BuildTransport(IComponentContext c)
 {
     var threadSafeContext = c.Resolve<IComponentContext>();
     return new MessageQueueTransport(
         () => threadSafeContext.Resolve<IReceiveMessages>(),
         c.Resolve<ISendToEndpoints>(),
         this.maxThreads);
 }
示例#8
0
 private static IServiceRunner CreateRunner(RunMode mode, IComponentContext c)
 {
     if (mode == RunMode.Console)
     {
         return c.Resolve<ConsoleRunner>();
     }
     return c.Resolve<ServiceRunner>();
 }
示例#9
0
 static RuntimeProviders RuntimeProviders(IComponentContext c)
 {
     return CloudStorage
         .ForAzureAccount(c.Resolve<CloudStorageAccount>())
         .WithObserver(c.Resolve<ICloudStorageObserver>())
         .WithRuntimeFinalizer(c.ResolveOptional<IRuntimeFinalizer>())
         .BuildRuntimeProviders(c.ResolveOptional<ILog>());
 }
示例#10
0
 static IQueueStorageProvider QueueStorageProvider(IComponentContext c)
 {
     return CloudStorage
         .ForAzureAccount(c.Resolve<CloudStorageAccount>())
         .WithDataSerializer(c.Resolve<IDataSerializer>())
         .WithObserver(c.Resolve<IStorageObserver>())
         .BuildQueueStorage();
 }
 protected virtual IReceiveMessages BuildMessageReceiver(IComponentContext c)
 {
     var threadSafeContext = c.Resolve<IComponentContext>();
     return new MessageReceiverWorkerThread(
         c.Resolve<IReceiveFromEndpoints>(),
         () => threadSafeContext.Resolve<IRouteMessagesToHandlers>(),
         action => new BackgroundThread(() => action()));
 }
 public static BusBuilderConfiguration WithAutofacDefaults(this BusBuilderConfiguration configuration, IComponentContext componentContext)
 {
     return configuration
         .WithMulticastEventBroker(componentContext.Resolve<IMulticastEventBroker>())
         .WithCompetingEventBroker(componentContext.Resolve<ICompetingEventBroker>())
         .WithCommandBroker(componentContext.Resolve<ICommandBroker>())
         .WithRequestBroker(componentContext.Resolve<IRequestBroker>())
         .WithLogger(componentContext.Resolve<ILogger>());
 }
示例#13
0
 static IBlobStorageProvider BlobStorageProvider(IComponentContext c)
 {
     return CloudStorage
         .ForAzureAccount(c.Resolve<CloudStorageAccount>())
         .WithDataSerializer(c.Resolve<IDataSerializer>())
         .WithObserver(c.Resolve<ICloudStorageObserver>())
         .WithRuntimeFinalizer(c.ResolveOptional<IRuntimeFinalizer>())
         .BuildBlobStorage();
 }
        IMessageSender BuildDefaultMessageSender(IComponentContext c)
        {
            var observer = c.Resolve<ISystemObserver>();
            var registry = c.Resolve<QueueWriterRegistry>();

            var factory = registry.GetOrAdd(_endpoint, s => _construct(c, s));
            var queues = _queueNames.Select(factory.GetWriteQueue).ToArray();
            return new DefaultMessageSender(queues, observer, _keyGenerator);
        }
示例#15
0
		public ResGroup(IResourceManager resourceManager, IResourceFile resourceFile, IComponentContext context)
		{
			this.resourceManager = resourceManager;
			this.resourceFile = resourceFile;
			this.context = context;

			//TODO: make public properties read-only
			this.externalResources = context.Resolve<IList<IResourceFile>>();
			this.embeddedResources = context.Resolve<IList<Managed>>();
		}
示例#16
0
        public void populateNutrientRecommendationImporter(IComponentContext componentContext)
        {
            var nutrientRecommendationImporter = componentContext.Resolve<INutrientRecommendationImporter>();

            var nutrinetImporterAssembly = typeof(IIronRDIImporter).Assembly;
            var types = nutrinetImporterAssembly.GetExportedTypes().Where(t => typeof(INutrientRDIImporter).IsAssignableFrom(t)).ToList();
            var importerTypes = from t in types where t.IsInterface && t.Name != "INutrientRDIImporter" select t;
            foreach (var type in importerTypes) {
                nutrientRecommendationImporter.AddImporter(componentContext.Resolve(type) as INutrientRDIImporter);
            }
        }
        /// <summary>
        /// Create a Fake band object using the dependency injection container.
        /// </summary>
        /// <param name="container"></param>
        /// <returns></returns>
        private static Band CreateBand(IComponentContext container, string name)
        {
            var bandInfo = container.Resolve<IBandInfo>(
                new TypedParameter(typeof(BandConnectionType), BandConnectionType.Bluetooth),
                new NamedParameter("name", name),
                new TypedParameter(typeof(IComponentContext), container));

            var band = container.Resolve<Band>(
                new TypedParameter(typeof(IBandInfo), bandInfo));

            return band;
        }
示例#18
0
        /// <summary>
        /// Autofac will call this each time a class depends on ComicConfigRegistry
        /// </summary>
        /// <param name="componentRegistry"></param>
        /// <returns></returns>
        public static ComicConfigRegistry RegisterComics(IComponentContext componentRegistry)
        {
            var registry = new ComicConfigRegistry();

            registry.Add(
                new ComicConfig(ComicType.Dilbert, componentRegistry.Resolve<DilbertDownloader>()));
            registry.Add(
                new ComicConfig(ComicType.Explosm, componentRegistry.Resolve<ExplosmDownloader>()));
            registry.Add(
                new ComicConfig(ComicType.Pearls, componentRegistry.Resolve<PearlsDownloader>()));

            return registry;
        }
示例#19
0
 public static IEnumerable<ITransform> GetTransforms(IComponentContext ctx, Process process, Entity entity, IEnumerable<Field> fields) {
     var transforms = new List<ITransform>();
     foreach (var f in fields.Where(f => f.Transforms.Any())) {
         var field = f;
         if (field.RequiresCompositeValidator()) {
             transforms.Add(new CompositeValidator(
                 new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity, field),
                 field.Transforms.Select(t => SwitchTransform(ctx, new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity, field, t) { Activity = PipelineActivity.Transform }))
                 ));
         } else {
             transforms.AddRange(field.Transforms.Select(t => SwitchTransform(ctx, new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity, field, t) { Activity = PipelineActivity.Transform })));
         }
     }
     return transforms;
 }
 protected virtual IReceiveFromEndpoints BuildReceiverEndpoint(IComponentContext c)
 {
     return new MsmqReceiverEndpoint(
         MsmqConnector.OpenReceive(new MsmqAddress(this.receiverAddress), this.enlist),
         MsmqConnector.OpenSend(new MsmqAddress(this.poisonAddress), this.enlist),
         c.Resolve<ISerializeMessages>());
 }
        public void InjectProperties(IComponentContext context, object instance, bool overrideSetValues)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (instance == null) throw new ArgumentNullException("instance");

            var instanceType = instance.GetType();

            foreach (var property in instanceType
                .GetProperties(BindingFlags.Public | BindingFlags.Instance)
                .Where(pi => pi.CanWrite))
            {
                var propertyType = property.PropertyType;

                if (propertyType.IsValueType && !propertyType.IsEnum)
                    continue;

                if (property.GetIndexParameters().Length != 0)
                    continue;

                if (!context.IsRegistered(propertyType))
                    continue;

                var accessors = property.GetAccessors(false);
                if (accessors.Length == 1 && accessors[0].ReturnType != typeof(void))
                    continue;

                if (!overrideSetValues &&
                    accessors.Length == 2 &&
                    (property.GetValue(instance, null) != null))
                    continue;

                var propertyValue = context.Resolve(propertyType);
                property.SetValue(instance, propertyValue, null);
            }
        }
        public override void OnSuspending(IComponentContext context, Dictionary<string, object> state)
        {
            var service = context.Resolve<IPlayerService>();

            // Tell the background audio that the app is being suspended
            service.Suspending();
        }
示例#23
0
        private static async Task RunTestsAsync(IComponentContext componentContext)
        {
            var collection = componentContext.Resolve<IScriptCollection>();

            var executor = componentContext.Resolve<IConcurrentExecutor>();

            var tasks =
                collection.GetTestScripts()
                          .Select(
                              ts =>
                              executor.ExecuteAsync(
                                  componentContext.Resolve<ExecuteScriptWork>(new TypedParameter(typeof (IScript), ts))))
                          .ToList();

            await Task.WhenAll(tasks).ConfigureAwait(false);
        }
示例#24
0
 private static ILogger CreateLogger(IComponentContext context, IEnumerable<Parameter> parameters)
 {
     // return an ILogger in response to Resolve<ILogger>(componentTypeParameter)
     var loggerFactory = context.Resolve<ILoggerFactory>();
     var containingType = parameters.TypedAs<Type>();
     return loggerFactory.CreateLogger(containingType);
 }
示例#25
0
        static HttpContextBase HttpContextBaseFactory(IComponentContext context) {
            if (IsRequestValid()) {
                return new HttpContextWrapper(HttpContext.Current);
            }

            var siteService = context.Resolve<ISiteService>();

            // Wrapping the code accessing the SiteSettings in a function that will be executed later (in HttpContextPlaceholder),
            // so that the RequestContext will have been established when the time comes to actually load the site settings,
            // which requires activating the Site content item, which in turn requires a UrlHelper, which in turn requires a RequestContext,
            // thus preventing a StackOverflowException.
            var baseUrl = new Func<string>(() => siteService.GetSiteSettings().BaseUrl);
            var httpContextBase = context.Resolve<IHttpContextAccessor>().Current();
            context.Resolve<IWorkContextAccessor>().CreateWorkContextScope(httpContextBase);
            return httpContextBase;
        }
        public override void OnResuming(IComponentContext context)
        {
            var service = context.Resolve<IPlayerService>();

            // Tell the background audio that the app is being resumed
            service.Resuming();
        }
示例#27
0
        private ILogger CreateLogger(IComponentContext resolver)
        {
            var configurations = resolver.ResolveAll<LogSink.Configuration>();
            var baseConfiguration = resolver.Resolve<LoggerConfiguration>();

            return configurations.Aggregate(baseConfiguration, (_, configure) => configure(_)).CreateLogger();
        }
示例#28
0
        private object GetObjectMappers(IComponentContext resolveContext)
        {
            var mappers = new List<IObjectMapper>(resolveContext.Resolve<IEnumerable<IObjectMapper>>());
            mappers.AddRange(MapperRegistry.Mappers);

            return mappers;
        }
示例#29
0
 static CloudInfrastructureProviders CloudInfrastructureProviders(IComponentContext c)
 {
     return new CloudInfrastructureProviders(
         c.Resolve<CloudStorageProviders>(),
         c.ResolveOptional<IProvisioningProvider>(),
         c.ResolveOptional<ILog>());
 }
        public static void InjectProperties(IComponentContext context, object instance)
        {
            var properties = instance.GetType().GetFields(
                BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            foreach (var fieldInfo in properties)
            {
                var propertyType = fieldInfo.FieldType;
                if (propertyType.IsValueType || !context.IsRegistered(propertyType))
                {
                    continue;
                }

                if (HasImportAttribute(fieldInfo))
                {
                    if (fieldInfo.GetValue(instance) != null)
                    {
                        continue; // do not overwrite existing non-null values
                    }

                    var obj = context.Resolve(propertyType);
                    if (obj == null)
                    {
                        throw new DependencyResolutionException(
                            $"Unable to resolve dependency import on {instance.GetType()} -> {fieldInfo}");
                    }

                    fieldInfo.SetValue(instance, obj);
                }
            }
        }
 public object GetService(Type type)
 {
     return(_context.Resolve(type));
 }
 public override T Resolve <T>()
 {
     return(_componentContext.Resolve <T>());
 }
示例#33
0
 /// <summary>
 /// Gets the new data factory registered in DI
 /// </summary>
 /// <param name="componentContext">
 /// The component Context.
 /// </param>
 /// <param name="context">
 /// Current data context
 /// </param>
 /// <returns>
 /// The new data factory
 /// </returns>
 public static DataFactory <TContext, TObject, TId> CreateFactory(IComponentContext componentContext, TContext context)
 {
     return(componentContext.Resolve <DataFactory <TContext, TObject, TId> >(new TypedParameter(typeof(TContext), context)));
 }
        public static Localizer Resolve(IComponentContext context, string scope)
        {
            var text = context.Resolve <IText>(new NamedParameter("scope", scope));

            return(text.Get);
        }
示例#35
0
 public static T CreateRestClient <T>(this IComponentContext context, string baseUrl)
 {
     return(context.Resolve <IServiceProvider>().CreateRestClient <T>(baseUrl));
 }
示例#36
0
 static UrlHelper UrlHelperFactory(IComponentContext context)
 {
     return(new UrlHelper(context.Resolve <RequestContext>(), context.Resolve <RouteCollection>()));
 }
示例#37
0
 public T GetService <T>()
 {
     return(_context.Resolve <T>());
 }
示例#38
0
 public ApiBase(IComponentContext components)
 {
     _logger = components.Resolve <ILogger>();
 }
示例#39
0
 public object Resolve(Type type)
 {
     return(_context.Resolve(type));
 }
示例#40
0
        public static DeliveryCappingGroupValidator GetValidator(IComponentContext context)
        {
            var repository = context.Resolve <IDeliveryCappingGroupRepository>();

            return(new DeliveryCappingGroupValidator(GetValidation(repository)));
        }
示例#41
0
文件: App.cs 项目: yayaritaa/Europa
 private void Setup <TCommand>()
     where TCommand : class, ICommand
 {
     _logger.LogInformation($"Setting up to handle command {typeof(TCommand).Name}");
     _bus.Receive <TCommand>(typeof(TCommand).Name, request => _resolver.Resolve <ICommandExecutor>().ExecuteCommand(request));
 }
示例#42
0
 public T Resolve <T>()
 {
     return(_context.Resolve <T>());
 }
示例#43
0
        public void Dispatch <TParameter>(TParameter query) where TParameter : ICommand
        {
            var _handler = _Context.Resolve <ICommandHandler <TParameter> >();

            _handler.Execute(query);
        }
示例#44
0
 private IAzureEventStore GetEventStore(IComponentContext context)
 {
     return(new AzureEventStore(
                eventTable: _tableLazy.Value,
                serializer: context.Resolve <IMessageSerializer>()));
 }
示例#45
0
 public object GetRequiredService(Type serviceType)
 {
     return(_componentContext.Resolve(serviceType));
 }
示例#46
0
 public void Init()
 {
     _container = CreateComponentContext();
     _testee    = _container.Resolve <QueuedHostedService>();
     _testee.StartAsync(CancellationToken.None);
 }
示例#47
0
 public virtual IMapper <TSource, TDestination> Create <TSource, TDestination>()
 {
     return(componentContext.Resolve <IMapper <TSource, TDestination> >());
 }
示例#48
0
 public ILogLoaderDecorator Create()
 {
     return(ctx.Resolve <ILogLoaderDecorator>());
 }
示例#49
0
 public async Task SendAsync <T>(T command) where T : ICommand
 => await _context.Resolve <ICommandHandler <T> >().HandleAsync(command);
示例#50
0
 public SpecProvider <TEntityOrService> Get <TEntityOrService>()
 {
     return(_context.Resolve <SpecProvider <TEntityOrService> >());
 }
        public static void InjectProperties(IComponentContext context, object instance, bool overrideSetValues)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            var instanceType = instance.GetType();

            foreach (var property in instanceType
                     .GetProperties(BindingFlags.Public | BindingFlags.Instance)
                     .Where(pi => pi.CanWrite))
            {
                var propertyType = property.PropertyType;

                if (propertyType.IsValueType && !propertyType.IsEnum)
                {
                    continue;
                }

                if (propertyType.IsArray && propertyType.GetElementType().IsValueType)
                {
                    continue;
                }

                if (propertyType.IsGenericEnumerableInterfaceType() && propertyType.GetGenericArguments()[0].IsValueType)
                {
                    continue;
                }

                if (property.GetIndexParameters().Length != 0)
                {
                    continue;
                }

                if (!context.IsRegistered(propertyType))
                {
                    continue;
                }

                var accessors = property.GetAccessors(false);
                if (accessors.Length == 1 && accessors[0].ReturnType != typeof(void))
                {
                    continue;
                }

                if (!overrideSetValues &&
                    accessors.Length == 2 &&
                    (property.GetValue(instance, null) != null))
                {
                    continue;
                }

                var propertyValue = context.Resolve(propertyType);
                property.SetValue(instance, propertyValue, null);
            }
        }
 public WorkContextImplementation(IComponentContext componentContext)
 {
     _componentContext          = componentContext;
     _workContextStateProviders = componentContext.Resolve <IEnumerable <Lazy <IWorkContextStateProvider> > >();
 }
        public IObjectRepository ResolveRepository(Type changedItemType, Type changedItemIdentifierType)
        {
            var repository = _context.Resolve(typeof(IRepository <,>).MakeGenericType(changedItemType, changedItemIdentifierType));

            return((IObjectRepository)repository);
        }
示例#54
0
        private static IAction SwitchAction(IComponentContext ctx, Process process, Action action)
        {
            var context = new PipelineContext(ctx.Resolve <IPipelineLogger>(), process);

            switch (action.Type)
            {
            case "copy":
                return(action.InTemplate ? (IAction)
                       new ContentToFileAction(context, action) :
                       new FileCopyAction(context, action));

            case "move":
                return(new FileMoveAction(context, action));

            case "replace":
                return(new FileReplaceAction(context, action));

            case "print":
                return(new PrintAction(action));

            case "log":
                return(new LogAction(context, action));

            case "web":
                return(new WebAction(context, action));

            case "wait":
            case "sleep":
                return(new WaitAction(action));

            case "tfl":
                var cfg = string.IsNullOrEmpty(action.Url) ? action.File : action.Url;
                if (string.IsNullOrEmpty(cfg) && !string.IsNullOrEmpty(action.Body))
                {
                    cfg = action.Body;
                }

                var root = ctx.Resolve <Process>(new NamedParameter("cfg", cfg));

                foreach (var warning in root.Warnings())
                {
                    context.Warn(warning);
                }
                if (root.Errors().Any())
                {
                    context.Error(string.Format("TFL Pipeline Action '{0}' has errors!", cfg.Left(15) + "..." + cfg.Right(15)));
                    foreach (var error in root.Errors())
                    {
                        context.Error(error);
                    }
                    return(new NullAction());
                }

                var builder = new ContainerBuilder();

                // Register Orchard CMS Stuff
                builder.RegisterInstance(ctx.Resolve <IAppDataFolder>()).As <IAppDataFolder>();
                builder.RegisterInstance(ctx.Resolve <ITemplateProcessor>()).As <ITemplateProcessor>();
                builder.RegisterInstance(ctx.Resolve <INotifier>()).As <INotifier>();

                builder.RegisterInstance(context.Logger).As <IPipelineLogger>();
                builder.RegisterCallback(new RootModule().Configure);
                builder.RegisterCallback(new ContextModule(root).Configure);

                // providers
                builder.RegisterCallback(new AdoModule(root).Configure);
                builder.RegisterCallback(new SolrModule(root).Configure);
                builder.RegisterCallback(new ElasticModule(root).Configure);
                builder.RegisterCallback(new InternalModule(root).Configure);
                builder.RegisterCallback(new FileModule(ctx.Resolve <IAppDataFolder>()).Configure);
                builder.RegisterCallback(new ExcelModule().Configure);
                builder.RegisterCallback(new GeoJsonModule().Configure);
                builder.RegisterCallback(new KmlModule().Configure);

                builder.RegisterCallback(new TransformModule(root).Configure);
                builder.RegisterCallback(new MapModule(root).Configure);
                builder.RegisterCallback(new ActionModule(root).Configure);
                builder.RegisterCallback(new EntityPipelineModule(root).Configure);
                builder.RegisterCallback(new ProcessPipelineModule(root).Configure);
                builder.RegisterCallback(new ProcessControlModule(root).Configure);

                return(new PipelineAction(builder.Build(), root));

            case "run":
                var connection = process.Connections.First(c => c.Name == action.Connection);
                switch (connection.Provider)
                {
                case "mysql":
                case "postgresql":
                case "sqlite":
                case "sqlserver":
                    return(new AdoRunAction(context, action, ctx.ResolveNamed <IConnectionFactory>(connection.Key), new DefaultReader(new FileReader(), new WebReader())));

                default:
                    context.Error("{0} provider is not registered for run action.", connection.Provider);
                    return(new NullAction());
                }

            case "open":
                return(new OpenAction(action));

            default:
                context.Error("{0} action is not registered.", action.Type);
                return(new NullAction());
            }
        }
示例#55
0
 public async Task SendAsync <T>(T command) where T : ICommand
 => await _context.Resolve <ICommandHandler <T> >().HandleAsync(command, CorrelationContext.Empty);
示例#56
0
 internal Workflow(Assembly botAssembly, IComponentContext context)
 {
     this._controllersService = new ControllersService(context, botAssembly, context.Resolve <BotCommandsService>(), context.Resolve <CommandsContainer>());
 }
示例#57
0
        public IContentQuery <ContentItem> Query()
        {
            var query = _context.Resolve <IContentQuery>(TypedParameter.From <IContentManager>(this));

            return(query.ForPart <ContentItem>());
        }
 public static TConfiguration WithAutofac <TConfiguration>(this TConfiguration configuration, IComponentContext context)
     where TConfiguration : IMessagingConfiguration, IMessagingContainerConfiguration <TConfiguration>
 {
     return(configuration.WithContainer(new AutofacContainer(context.Resolve <ILifetimeScope>())));
 }
 /// <summary>
 ///     Create the command handlers for a given command type.
 /// </summary>
 /// <typeparam name="TCommand">
 ///     The command type.
 /// </typeparam>
 /// <returns>
 ///     The created command handlers.
 /// </returns>
 public IEnumerable <ICommandHandler> Create <TCommand>()
 {
     return(_componentContext.Resolve <IEnumerable <ICommandHandler <TCommand> > >());
 }
示例#60
0
        private IRepository <T> GetRepository <T>() where T : class
        {
            var repository = componentContext.Resolve <IRepository <T> >();

            return(repository);
        }