• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IComponentContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Base3DEditor

		//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();
		}
开发者ID:gleblebedev,项目名称:toe,代码行数:37,代码来源:Base3DEditor.cs


示例17: AgencyBanks

 public AgencyBanks(IComponentContext container)
 {
         this.iContainer = container;
         queueConfiguration = iContainer.Resolve<IQueueConfiguration>();
         publisher = iContainer.Resolve<IExchangePublisher<Job>>();
         publisher.Declare(queueConfiguration.ResponseExchangeName);
 }
开发者ID:jhonner72,项目名称:plat,代码行数:7,代码来源:AgencyBanks.cs


示例18: InjectProperties

        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);
                }
            }
        }
开发者ID:clbond,项目名称:continuous-runner,代码行数:31,代码来源:PropertyInjector.cs


示例19: EventStoreProxy

        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();
                }
            }
        }
开发者ID:nootn,项目名称:SampleFluxReactDotNet,代码行数:26,代码来源:EventStoreProxy.cs


示例20: Start

        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);
            });
        }
开发者ID:haroldma,项目名称:PopcornTime,代码行数:28,代码来源:TorrentBootstrapper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IComponentModel类代码示例发布时间:2022-05-24
下一篇:
C# IComponentChangeService类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap