当前位置: 首页>>代码示例>>C#>>正文


C# IComponentContext类代码示例

本文整理汇总了C#中IComponentContext的典型用法代码示例。如果您正苦于以下问题:C# IComponentContext类的具体用法?C# IComponentContext怎么用?C# IComponentContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IComponentContext类属于命名空间,在下文中一共展示了IComponentContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RequestContextFactory

        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());
        }
开发者ID:qhme,项目名称:OrchardLite,代码行数:27,代码来源:MvcModule.cs

示例2: EditorFactory

		public EditorFactory(Package package, IComponentContext context)
		{
			Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} constructor", this));

			this.editorPackage = package;
			this.context = context;
		}
开发者ID:gleblebedev,项目名称:toe,代码行数:7,代码来源:EditorFactory.cs

示例3: PayPalExpressController

        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;
        }
开发者ID:omidghorbani,项目名称:SmartStoreNET,代码行数:31,代码来源:PayPalExpressController.cs

示例4: InjectProperties

        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);
            }
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:35,代码来源:AutofacBackportAutowiringPropertyInjector.cs

示例5: AutofacBytecodeProvider

 /// <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);
 }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:13,代码来源:AutofacBytecodeProvider.cs

示例6: InjectPropertiesForChildViews

        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;
            }
        }
开发者ID:slewis74,项目名称:Jukebox,代码行数:26,代码来源:ViewModule.cs

示例7: GoogleFeedService

        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;
            });
        }
开发者ID:mandocaesar,项目名称:Mesinku,代码行数:29,代码来源:GoogleFeedService.cs

示例8: GetObjectMappers

        private object GetObjectMappers(IComponentContext resolveContext)
        {
            var mappers = new List<IObjectMapper>(resolveContext.Resolve<IEnumerable<IObjectMapper>>());
            mappers.AddRange(MapperRegistry.Mappers);

            return mappers;
        }
开发者ID:andy-uq,项目名称:HomeTrack,代码行数:7,代码来源:MappingFeature.cs

示例9: EditorEnvironment

		public EditorEnvironment(
			MainEditorWindow mainEditorWindow, IResourceManager resourceManager, IComponentContext context)
		{
			this.mainEditorWindow = mainEditorWindow;
			this.resourceManager = resourceManager;
			this.context = context;
		}
开发者ID:gleblebedev,项目名称:toe,代码行数:7,代码来源:EditorEnvironment.cs

示例10: WithAutofacDefaults

 public static BusBuilderConfiguration WithAutofacDefaults(this BusBuilderConfiguration configuration, IComponentContext componentContext)
 {
     return configuration
         .WithTypesFrom(componentContext.Resolve<ITypeProvider>())
         .WithDependencyResolver(componentContext.Resolve<IDependencyResolver>())
         ;
 }
开发者ID:fenix2222,项目名称:Nimbus,代码行数:7,代码来源:AutofacBusBuilderConfigurationExtensions.cs

示例11: BinaryResourceFormat

		public BinaryResourceFormat(
			IResourceManager resourceManager, IComponentContext context, IResourceErrorHandler errorHandler)
		{
			this.resourceManager = resourceManager;
			this.context = context;
			this.errorHandler = errorHandler;
		}
开发者ID:gleblebedev,项目名称:toe,代码行数:7,代码来源:BinaryResourceFormat.cs

示例12: ConstructorParameterBinding

        /// <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;
                }
            }
        }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:41,代码来源:ConstructorParameterBinding.cs

示例13: CreateLogger

        private ILogger CreateLogger(IComponentContext resolver)
        {
            var configurations = resolver.ResolveAll<LogSink.Configuration>();
            var baseConfiguration = resolver.Resolve<LoggerConfiguration>();

            return configurations.Aggregate(baseConfiguration, (_, configure) => configure(_)).CreateLogger();
        }
开发者ID:andy-uq,项目名称:HomeTrack,代码行数:7,代码来源:LoggingFeature.cs

示例14: CreateSessionFactory

 /// <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();
 }
开发者ID:KamilLach,项目名称:RestBucks,代码行数:11,代码来源:NHibernateModule.cs

示例15: GetFactory

		/// <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;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:17,代码来源:ProvidedInstanceActivator.cs


注:本文中的IComponentContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。