コード例 #1
1
ファイル: MvcModule.cs プロジェクト: qhme/OrchardLite
        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());
        }
コード例 #2
0
        private void BuildupView(IComponentContext context, DependencyObject instance)
        {
            try
            {
                if (instance == null)
                    return;

                foreach (object c in LogicalTreeHelper.GetChildren(instance))
                {
                    var child = c as DependencyObject;
                    if (child == null)
                        continue;

                    BuildupView(context, child);
                }

                Type viewInterfaceType = instance.GetType().GetInterface(typeof (IView<>).FullName);
                if (viewInterfaceType == null)
                    return;

                PropertyInfo viewModelProperty = viewInterfaceType.GetProperty("ViewModel");
                Type viewModelType = viewInterfaceType.GetGenericArguments()[0];


                object viewModel = context.Resolve(viewModelType);
                viewModelProperty.SetValue(instance, viewModel, null);

                viewInterfaceType.GetMethod("ViewInitialized").Invoke(instance, null);
            }
            catch (Exception e)
            {
            }
        }
コード例 #3
0
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 public WebApplicationComponent(IWebAppEndpoint endpoint, Auto<ILogger> logger, IComponentContext componentContext)
 {
     _app = endpoint.Contract;
     _address = endpoint.Address;
     _logger = logger.Instance;
     _container = (ILifetimeScope)componentContext;
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AutofacBytecodeProvider"/> class.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="proxyFactoryFactory">The proxy factory factory.</param>
 /// <param name="collectionTypeFactory">The collection type factory.</param>
 public AutofacBytecodeProvider(IComponentContext container, IProxyFactoryFactory proxyFactoryFactory, ICollectionTypeFactory collectionTypeFactory)
 {
     _container = container;
     _proxyFactoryFactory = proxyFactoryFactory;
     _collectionTypeFactory = collectionTypeFactory;
     _objectsFactory = new AutofacObjectsFactory(container);
 }
コード例 #5
0
 /// <summary>
 /// Configure session Factory
 /// </summary>
 /// <returns>Session</returns>
 private ISessionFactory CreateSessionFactory(IComponentContext a_componentContext)
 {
     return Fluently.Configure()
     .Database(MsSqlConfiguration.MsSql2008.ConnectionString(a_c => a_c.FromConnectionStringWithKey("Restbucks")))
     .Mappings(a_m => a_m.FluentMappings.AddFromAssemblyOf<NHibernateModule>())
     .BuildSessionFactory();
 }
コード例 #6
0
ファイル: AzureModule.cs プロジェクト: hadouken/peach
        private static CloudBlobClient CreateCloudBlobClient(IComponentContext componentContext)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["HadoukenStorage"].ConnectionString;
            var account = CloudStorageAccount.Parse(connectionString);

            return account.CreateCloudBlobClient();
        }
        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);
            }
        }
コード例 #8
0
ファイル: RepositoriesModule.cs プロジェクト: slavo/FunnelWeb
        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();
        }
コード例 #9
0
        public GoogleFeedService(
			IRepository<GoogleProductRecord> gpRepository,
			IProductService productService,
			IManufacturerService manufacturerService,
			FroogleSettings settings,
			IMeasureService measureService,
			MeasureSettings measureSettings,
			IDbContext dbContext,
			AdminAreaSettings adminAreaSettings,
			ICurrencyService currencyService,
			ICommonServices services,
			IComponentContext ctx)
        {
            _gpRepository = gpRepository;
            _productService = productService;
            _manufacturerService = manufacturerService;
            Settings = settings;
            _measureService = measureService;
            _measureSettings = measureSettings;
            _dbContext = dbContext;
            _adminAreaSettings = adminAreaSettings;
            _currencyService = currencyService;
            _services = services;

            _helper = new FeedPluginHelper(ctx, "SmartStore.GoogleMerchantCenter", "SmartStore.GoogleMerchantCenter", () =>
            {
                return Settings as PromotionFeedSettings;
            });
        }
コード例 #10
0
ファイル: LoggingModule.cs プロジェクト: 20081111/TEST
 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);
 }
コード例 #11
0
ファイル: ViewModule.cs プロジェクト: slewis74/Jukebox
        private void InjectPropertiesForChildViews(IComponentContext context, IPresentationBusConfiguration bus, UIElement uiElement)
        {
            var userControl = uiElement as UserControl;
            if (userControl != null)
            {
                InjectProperties(context, bus, userControl.Content);
                return;
            }

            var panel = uiElement as Panel;
            if (panel != null)
            {
                foreach (var child in panel.Children)
                {
                    InjectProperties(context, bus, child);
                }
                return;
            }

            var contentControl = uiElement as ContentControl;
            if (contentControl != null)
            {
                InjectProperties(context, bus, contentControl.Content as UIElement);
                return;
            }
        }
コード例 #12
0
        public EventStoreProxy(IComponentContext container)
        {
            _container = container;

            //Ensure we only set up the connection once
            lock (CreateConnectionLock)
            {
                if (_eventStoreConn == null)
                {
                    var connSettings = ConnectionSettings.Create()
                        .KeepReconnecting()
                        .KeepRetrying();

                    //TODO: get config value for address, port and user account
                    _eventStoreConn = EventStoreConnection.Create(connSettings, new IPEndPoint(IPAddress.Loopback, 1113));
                    _eventStoreConn.Disconnected += EventStoreConnDisconnected;
                    _eventStoreConn.ErrorOccurred += EventStoreConnErrorOccurred;
                    _eventStoreConn.Reconnecting += EventStoreConnReconnecting;
                    _eventStoreConn.Connected += EventStoreConnConnected;
                    _eventStoreConn.ConnectAsync().Wait();

                    SubscribeToStreamComment();
                    SubscribeToStreamTodo();
                }
            }
        }
コード例 #13
0
		/// <summary>
		/// Activate an instance in the provided context.
		/// </summary>
		/// <param name="context">Context in which to activate instances.</param>
		/// <param name="parameters">Parameters to the instance.</param>
		/// <returns>The activated instance.</returns>
		/// <remarks>
		/// The context parameter here should probably be ILifetimeScope in order to reveal Disposer,
		/// but will wait until implementing a concrete use case to make the decision
		/// </remarks>
		public Func<object> GetFactory(IComponentContext context, IEnumerable<Parameter> parameters)
		{
			if (context == null) throw new ArgumentNullException("context");
			if (parameters == null) throw new ArgumentNullException("parameters");

			return () => _instance;
		}
コード例 #14
0
ファイル: AgencyBanks.cs プロジェクト: jhonner72/plat
 public AgencyBanks(IComponentContext container)
 {
         this.iContainer = container;
         queueConfiguration = iContainer.Resolve<IQueueConfiguration>();
         publisher = iContainer.Resolve<IExchangePublisher<Job>>();
         publisher.Declare(queueConfiguration.ResponseExchangeName);
 }
コード例 #15
0
ファイル: ProxyActivator.cs プロジェクト: netcasewqs/nlite
        private object[] GetConstructurArgs(IComponentContext context)
        {

            if (context.NamedArgs != null && context.NamedArgs.Count > 0)
                return context.NamedArgs.Values.ToArray();
            if (context.Args != null && context.Args.Length > 0)
                return context.Args;

            //const BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public;
            var impType = context.Component.Implementation;

            object o;

            if (context.Component.ExtendedProperties.TryGetValue(impType.FullName + ":ctorInjections", out o))
            {
                var ctors = o as ConstructorInjection[];

                if (ctors != null && ctors.Length > 0)
                {
                    var validConstructorBinding = ctors.FirstOrDefault(p => p.IsMatch);
                    if (validConstructorBinding != null)
                        return validConstructorBinding.Dependencies.Select(p => p.ValueProvider()).ToArray();
                }
            }

            return null;
        }
コード例 #16
0
        /// <summary>
        /// Override to return a closure that injects properties into a target.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>The injector.</returns>
        protected override Func<object, object> GetInjector(IComponentContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            return context.InjectProperties<object>;
        }
コード例 #17
0
ファイル: PreparingEventArgs.cs プロジェクト: dstimac/revenj
		/// <summary>
		/// Initializes a new instance of the <see cref="PreparingEventArgs"/> class.
		/// </summary>
		/// <param name="service">Service which is preparing</param>
		/// <param name="context">The context.</param>
		/// <param name="component">The component.</param>
		/// <param name="parameters">The parameters.</param>
		public PreparingEventArgs(Service service, IComponentContext context, IComponentRegistration component, IEnumerable<Parameter> parameters)
		{
			_service = Enforce.ArgumentNotNull(service, "service");
			_context = Enforce.ArgumentNotNull(context, "context");
			_component = Enforce.ArgumentNotNull(component, "component");
			_parameters = Enforce.ArgumentNotNull(parameters, "parameters");
		}
コード例 #18
0
 private static ITwitterFeed OnStartupExtracted(IComponentContext ctx, bool useTwitter)
 {
     if (useTwitter)
         return ctx.Resolve<TwitterFeedAsync>();
     else
         return ctx.Resolve<FakeTwitterFeed>();
 }
コード例 #19
0
        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);
                }
            }
        }
コード例 #20
0
        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);
            });
        }
コード例 #21
0
ファイル: EditorEnvironment.cs プロジェクト: gleblebedev/toe
		public EditorEnvironment(
			MainEditorWindow mainEditorWindow, IResourceManager resourceManager, IComponentContext context)
		{
			this.mainEditorWindow = mainEditorWindow;
			this.resourceManager = resourceManager;
			this.context = context;
		}
コード例 #22
0
 public static BusBuilderConfiguration WithAutofacDefaults(this BusBuilderConfiguration configuration, IComponentContext componentContext)
 {
     return configuration
         .WithTypesFrom(componentContext.Resolve<ITypeProvider>())
         .WithDependencyResolver(componentContext.Resolve<IDependencyResolver>())
         ;
 }
コード例 #23
0
		public BinaryResourceFormat(
			IResourceManager resourceManager, IComponentContext context, IResourceErrorHandler errorHandler)
		{
			this.resourceManager = resourceManager;
			this.context = context;
			this.errorHandler = errorHandler;
		}
コード例 #24
0
ファイル: LoggingFeature.cs プロジェクト: andy-uq/HomeTrack
        private ILogger CreateLogger(IComponentContext resolver)
        {
            var configurations = resolver.ResolveAll<LogSink.Configuration>();
            var baseConfiguration = resolver.Resolve<LoggerConfiguration>();

            return configurations.Aggregate(baseConfiguration, (_, configure) => configure(_)).CreateLogger();
        }
コード例 #25
0
        /// <summary>
        /// Construct a new ConstructorParameterBinding.
        /// </summary>
        /// <param name="ci">ConstructorInfo to bind.</param>
        /// <param name="availableParameters">Available parameters.</param>
        /// <param name="context">Context in which to construct instance.</param>
        public ConstructorParameterBinding(
            ConstructorInfo ci,
            IEnumerable<Parameter> availableParameters,
            IComponentContext context)
        {
            _canInstantiate = true;
            _ci = Enforce.ArgumentNotNull(ci, "ci");
            if (availableParameters == null) throw new ArgumentNullException("availableParameters");
            if (context == null) throw new ArgumentNullException("context");

            var parameters = ci.GetParameters();
            _valueRetrievers = new Func<object>[parameters.Length];

            for (int i = 0; i < parameters.Length; ++i)
            {
                var pi = parameters[i];
                bool foundValue = false;
                foreach (var param in availableParameters)
                {
                    Func<object> valueRetriever;
                    if (param.CanSupplyValue(pi, context, out valueRetriever))
                    {
                        _valueRetrievers[i] = valueRetriever;
                        foundValue = true;
                        break;
                    }
                }
                if (!foundValue)
                {
                    _canInstantiate = false;
                    _firstNonBindableParameter = pi;
                    break;
                }
            }
        }
コード例 #26
0
ファイル: EditorFactory.cs プロジェクト: gleblebedev/toe
		public EditorFactory(Package package, IComponentContext context)
		{
			Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} constructor", this));

			this.editorPackage = package;
			this.context = context;
		}
コード例 #27
0
ファイル: Base3DEditor.cs プロジェクト: gleblebedev/toe
		//private GLControl glControl;

		#region Constructors and Destructors

		public Base3DEditor(
			IComponentContext context, IEditorOptions<Base3DEditorOptions> options, Base3DEditorContent content)
		{
			this.options = options;
			this.content = content;
			this.graphicsContext = context.Resolve<ToeGraphicsContext>();
			this.camera = new EditorCamera(context.Resolve<IEditorOptions<EditorCameraOptions>>());
			this.camera.PropertyChanged += this.OnCameraPropertyChanged;
			this.InitializeComponent();
			this.Dock = DockStyle.Fill;
			//this.glControl = new GLControl(GraphicsMode.Default, 1, 0, GraphicsContextFlags.Default);
			//this.glControl.Dock = DockStyle.Fill;
			this.glControl.Load += this.GLControlLoad;
			this.glControl.Paint += this.GLControlPaint;
			this.glControl.Resize += this.GLControlResize;
			this.Controls.Add(this.glControl);
			this.glControl.MouseMove += this.OnSceneMouseMove;
			this.glControl.MouseEnter += this.OnSceneMouseEnter;
			this.glControl.MouseLeave += this.OnSceneMouseLeave;
			this.glControl.MouseWheel += this.OnSceneMouseWheel;
			this.glControl.KeyDown += this.OnControlKeyDown;
			this.glControl.KeyUp += this.OnControlKeyUp;
			this.glControl.GotFocus += this.OnSceneGotFocus;
			this.glControl.LostFocus += this.OnSceneLostFocus;
			this.Camera.LookAt(new Vector3(512, 64, 1024), new Vector3(0, 0, 0));
			this.CameraController = new TargetCameraController { Camera = this.Camera };
			this.yUpToolStripMenuItem.Click += this.SelectYUp;
			this.zUpToolStripMenuItem.Click += this.SelectZUp;
			this.UpdateCoordinateSystemIcon();
			this.UpdateLighingIcon();
			this.UpdateWireframeIcon();
			this.UpdateNormalIcon();
		}
コード例 #28
0
ファイル: MappingFeature.cs プロジェクト: andy-uq/HomeTrack
        private object GetObjectMappers(IComponentContext resolveContext)
        {
            var mappers = new List<IObjectMapper>(resolveContext.Resolve<IEnumerable<IObjectMapper>>());
            mappers.AddRange(MapperRegistry.Mappers);

            return mappers;
        }
コード例 #29
0
        public PayPalExpressController(
			IPaymentService paymentService, IOrderService orderService,
			IOrderProcessingService orderProcessingService,
			ILogger logger, 
			PaymentSettings paymentSettings, ILocalizationService localizationService,
			OrderSettings orderSettings,
			ICurrencyService currencyService, CurrencySettings currencySettings,
			IOrderTotalCalculationService orderTotalCalculationService, ICustomerService customerService,
			IGenericAttributeService genericAttributeService,
            IComponentContext ctx, ICommonServices services,
            IStoreService storeService)
        {
            _paymentService = paymentService;
            _orderService = orderService;
            _orderProcessingService = orderProcessingService;
            _logger = logger;
            _paymentSettings = paymentSettings;
            _localizationService = localizationService;
            _orderSettings = orderSettings;
            _currencyService = currencyService;
            _currencySettings = currencySettings;
            _orderTotalCalculationService = orderTotalCalculationService;
            _customerService = customerService;
            _genericAttributeService = genericAttributeService;
            _services = services;
            _storeService = storeService;

            _helper = new PluginHelper(ctx, "SmartStore.PayPal", "Plugins.Payments.PayPalExpress");

            T = NullLocalizer.Instance;
        }
コード例 #30
0
 public CommandDispatcher(IComponentContext context)
 {
     _context = context;
 }
コード例 #31
0
 public AutofacQueryFactory(IComponentContext c)
 {
     this.c = c;
 }
コード例 #32
0
 public ViewFactory(IComponentContext componentContext)
 {
     _componentContext = componentContext;
     Instance          = this;
 }
コード例 #33
0
        public static ApplicationUserManager Create(IDataProtectionProvider dataProtectionProvider, IComponentContext context)
        {
            var manager = new ApplicationUserManager(context.Resolve <IUserStore <ApplicationUser> >());

            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator <ApplicationUser>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequireNonLetterOrDigit = false,
                RequireDigit            = false,
                RequireLowercase        = false,
                RequireUppercase        = false
            };
            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider = new DataProtectorTokenProvider <ApplicationUser>(context.Resolve <IDataProtector>());
            }
            return(manager);
        }
コード例 #34
0
 public CommandFactory(IComponentContext container)
 {
     this.container = container ?? throw new ArgumentNullException(nameof(container));
 }
コード例 #35
0
 public AutofacMessageBusDependencyResolver(IComponentContext container)
     : this(container, container.Resolve <ILogger <AutofacMessageBusDependencyResolver> >())
 {
 }
コード例 #36
0
 public AutofacMessageBusDependencyResolver(IComponentContext container, ILogger <AutofacMessageBusDependencyResolver> logger)
 {
     _logger           = logger;
     _componentContext = container;
     _lifetimeScope    = container as ILifetimeScope;
 }
コード例 #37
0
 public AutofacDependencyResolver([NotNull] IComponentContext kernel)
 {
     _context = kernel ?? throw new ArgumentNullException(nameof(kernel));
 }
コード例 #38
0
 public WorkContextImplementation(IComponentContext componentContext)
 {
     _componentContext          = componentContext;
     _workContextStateProviders = componentContext.Resolve <IEnumerable <IWorkContextStateProvider> >();
 }
コード例 #39
0
 public WcfServiceHostFactory(IComponentContext container)
 {
     _container = container;
 }
コード例 #40
0
 public WcfInstanceProvider(IComponentContext container)
 {
     _container = container;
 }
 public AutofacDependencyResolver(IComponentContext ctx)
 {
     this.ctx = ctx;
 }
コード例 #42
0
 public InMemoryBus(IComponentContext componentContext)
 {
     _componentContext = componentContext;
 }
コード例 #43
0
 public ProviderManager(IComponentContext ctx, ICommonServices services, PluginMediator pluginMediator)
 {
     this._ctx            = ctx;
     this._services       = services;
     this._pluginMediator = pluginMediator;
 }
コード例 #44
0
ファイル: LoggingModule.cs プロジェクト: naguvan/Smartstore
 private static ILogger GetInstallLogger(IComponentContext context)
 {
     return(context.Resolve <ILoggerFactory>().CreateLogger("Install"));
 }
コード例 #45
0
ファイル: Parameter.cs プロジェクト: arsil/autofac-net20
 /// <summary>
 /// Returns true if the parameter is able to provide a value to a particular site.
 /// </summary>
 /// <param name="pi">Constructor, method, or property-mutator parameter.</param>
 /// <param name="context">The component context in which the value is being provided.</param>
 /// <param name="valueProvider">If the result is true, the valueProvider parameter will
 /// be set to a function that will lazily retrieve the parameter value. If the result is false,
 /// will be set to null.</param>
 /// <returns>True if a value can be supplied; otherwise, false.</returns>
 public abstract bool CanSupplyValue(ParameterInfo pi, IComponentContext context, out Func <object> valueProvider);
コード例 #46
0
ファイル: LocalDispatcher.cs プロジェクト: kennyup/stacks
 /// <summary>
 /// Initializes a new instance of the <see cref="LocalDispatcher"/> class.
 /// </summary>
 /// <param name="components">The configured <see cref="IComponentContext"/>.</param>
 public LocalDispatcher(IComponentContext components)
 {
     _components         = components;
     _environmentContext = components.Resolve <IEnvironmentContext>();
     _requestContext     = components.Resolve <IRequestContext>();
 }
コード例 #47
0
ファイル: StartableManager.cs プロジェクト: yus1977/Autofac
        /// <summary>
        /// Executes the startable and auto-activate components in a context.
        /// </summary>
        /// <param name="properties">The set of properties used during component registration.</param>
        /// <param name="componentContext">
        /// The <see cref="IComponentContext"/> in which startable services should execute.
        /// </param>
        internal static void StartStartableComponents(IDictionary <string, object?> properties, IComponentContext componentContext)
        {
            var componentRegistry = componentContext.ComponentRegistry;

            try
            {
                properties[MetadataKeys.StartOnActivatePropertyKey] = true;

                // We track which registrations have already been auto-activated by adding
                // a metadata value. If the value is present, we won't re-activate. This helps
                // in the container update situation.
                var startableService = new TypedService(typeof(IStartable));
                foreach (var registration in componentRegistry.ServiceRegistrationsFor(startableService).Where(r => !r.Metadata.ContainsKey(MetadataKeys.AutoActivated)))
                {
                    try
                    {
                        var request = new ResolveRequest(startableService, registration, Enumerable.Empty <Parameter>());
                        componentContext.ResolveComponent(request);
                    }
                    finally
                    {
                        registration.Metadata[MetadataKeys.AutoActivated] = true;
                    }
                }

                var autoActivateService = new AutoActivateService();
                foreach (var registration in componentRegistry.ServiceRegistrationsFor(autoActivateService).Where(r => !r.Metadata.ContainsKey(MetadataKeys.AutoActivated)))
                {
                    try
                    {
                        var request = new ResolveRequest(autoActivateService, registration, Enumerable.Empty <Parameter>());
                        componentContext.ResolveComponent(request);
                    }
                    catch (DependencyResolutionException ex)
                    {
                        throw new DependencyResolutionException(string.Format(CultureInfo.CurrentCulture, ContainerBuilderResources.ErrorAutoActivating, registration), ex);
                    }
                    finally
                    {
                        registration.Metadata[MetadataKeys.AutoActivated] = true;
                    }
                }
            }
            finally
            {
                properties.Remove(MetadataKeys.StartOnActivatePropertyKey);
            }
        }
コード例 #48
0
 public QueryDispatcher(IComponentContext componentContext)
 {
     _componentContext = componentContext;
 }
コード例 #49
0
 public HyperwayOutboundComponent(IComponentContext context)
 {
     this.context = context;
 }
コード例 #50
0
 public HierarchicalNavigation(IComponentContext componentContext)
 {
     _componentContext = componentContext;
 }
コード例 #51
0
ファイル: CommandBus.cs プロジェクト: Zilib/Watchman
 public CommandBus(IComponentContext context)
 {
     _context = context;
 }
コード例 #52
0
 public AdjustmentLettersRequestProcessorFactory(IComponentContext container)
 {
     this.container = container;
 }
コード例 #53
0
        public void Autofac_IComponentContext( )
        {
            IComponentContext instance = Factory.Current.Resolve <IComponentContext>( );

            Assert.That(instance, Is.Not.Null);
        }
コード例 #54
0
 public CommandDispatcher(IComponentContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
コード例 #55
0
ファイル: DialogFactory.cs プロジェクト: mluvii/dots
 public DialogFactory(IComponentContext scope)
 {
     SetField.NotNull(out Scope, nameof(scope), scope);
 }
コード例 #56
0
 public ListPathConstraintUpdator(IListPathConstraint listPathConstraint, IComponentContext componentContext, IListCategoryPathConstraint listCategoryPathConstraint)
 {
     this.listPathConstraint         = listPathConstraint;
     this.componentContext           = componentContext;
     this.listCategoryPathConstraint = listCategoryPathConstraint;
 }
コード例 #57
0
 public virtual object ResolveParameter(ParameterInfo p, IComponentContext c = null)
 {
     return((c ?? _container.Value).Resolve(p.ParameterType));
 }
コード例 #58
0
 public ContosoFlowersDialogFactory(IComponentContext scope)
     : base(scope)
 {
 }
コード例 #59
-1
 public NHibernateBoxQueryEvaluator(ILog log, 
     RepositoryFinder repoFinder, IComponentContext context)
 {
     this.log = log;
     _repoFinder = repoFinder;
     this.context = context;
 }