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

C# IBuilderContext类代码示例

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

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



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

示例1: PreBuildUp

        public override void PreBuildUp(IBuilderContext context)
        {
            var key = context.OriginalBuildKey;

            if (!key.Type.IsInterface)
            {
                // We only record for interfaces
                return;
            }

            var existing = context.Existing;

            if (existing == null)
            {
                return;
            }

            if (_settings.InterestingTypes.Count > 0)
            {
                if (!_settings.InterestingTypes.Contains(key.Type.FullName))
                {
                    return;
                }
            }

            Debug.WriteLine("Instantiated " + existing.GetType().FullName);
            Debug.WriteLine("ResolvedFrom " + key.Type.FullName);

            var replacement = _recorder.Record(context.OriginalBuildKey.Type, context.Existing);

            Debug.WriteLine("ReplacedWith " + replacement.GetType().FullName);

            context.Existing = replacement;
        }
开发者ID:chakming,项目名称:Betamax.Net,代码行数:34,代码来源:BetamaxRecordingBuilderStrategy.cs


示例2: PreBuildUp

        public override void PreBuildUp(IBuilderContext context)
        {
            var type = context.BuildKey.Type;
            if (!type.FullName.StartsWith("Microsoft.Practices"))
            {
                var properties = type.GetProperties();

                foreach (var property in properties)
                {
                    if (!property.CanWrite)
                        continue;

                    if (_unityContainer.IsRegistered(property.PropertyType))
                    {
                        property.SetValue(context.Existing, _unityContainer.Resolve(property.PropertyType),null);
                    }

                    if(configuredProperties.ContainsKey(type))
                    {
                        var p = configuredProperties[type].FirstOrDefault(t => t.Item1 == property.Name);

                        if(p != null)
                            property.SetValue(context.Existing, p.Item2,null);
                    }
                }
            }
        }
开发者ID:nghead,项目名称:NServiceBus,代码行数:27,代码来源:PropertyInjectionBuilderStrategy.cs


示例3: Build

        /// <summary>Builds the dependency demands required by this implementation. </summary>
        /// <param name="containerBuilder">The <see cref="IContainerBuilder"/> .</param>
        /// <param name="context">The context for this building session containing configuration etc.</param>
        public void Build(IContainerBuilder containerBuilder, IBuilderContext context)
        {
            containerBuilder
                .ForFactory(x => new IndexConfiguration(context.MapPath("~/App_Data/DiskCaches/Lucene/")))
                .KnownAsSelf()
                .ScopedAs.Singleton();

            //containerBuilder
            //    .ForFactory(x => new IndexController(x.Resolve<IndexConfiguration>(), null))
            //    .KnownAsSelf()
            //    .OnActivated((ctx, ctrlr) =>
            //    {
            //        var frameworkContext = ctx.Resolve<IFrameworkContext>();
            //        ctrlr.SetFrameworkContext(frameworkContext);
            //    })
            //    .ScopedAs.Singleton();

            containerBuilder
                .ForFactory(x => new IndexController(x.Resolve<IndexConfiguration>(), x.Resolve<IFrameworkContext>))
                .KnownAsSelf()
                //.OnActivated((ctx, ctrlr) =>
                //{
                //    var frameworkContext = ctx.Resolve<IFrameworkContext>();
                //    ctrlr.SetFrameworkContext(frameworkContext);
                //})
                .ScopedAs.Singleton();
        }
开发者ID:paulsuart,项目名称:rebelcmsxu5,代码行数:30,代码来源:DemandBuilder.cs


示例4: PostBuildUp

            public override void PostBuildUp(IBuilderContext context)
            {
                base.PostBuildUp(context);

                Type targetType = context.Existing.GetType();

                if (!_trackabilityCache.ContainsKey(targetType))
                    _trackabilityCache[targetType] =
                        targetType.GetInterfaces().Contains(typeof(ITrackingAware)) ||
                        targetType.GetProperties().Any(p => p.GetCustomAttributes(true).OfType<TrackableAttribute>().Count() > 0);

                if (_trackabilityCache[targetType])
                {
                    List<StateTracker> trackers = new List<StateTracker>(_container.ResolveAll<StateTracker>());
                    if (_container.IsRegistered<StateTracker>())
                        trackers.Add(_container.Resolve<StateTracker>());

                    foreach (StateTracker tracker in trackers)
                    {
                        var config = tracker.Configure(context.Existing);
                        _customizeConfigAction(config);
                        config.Apply();
                    }
                }
            }
开发者ID:anakic,项目名称:Ursus,代码行数:25,代码来源:TrackingExtension.cs


示例5: PreBuildUp

        public override void PreBuildUp(IBuilderContext context)
        {
            NamedTypeBuildKey key = context.OriginalBuildKey;

            if (!(key.Type.IsInterface && _typeStacks.ContainsKey(key.Type)))
            {
                return;
            }

            if (null != context.GetOverriddenResolver(key.Type))
            {
                return;
            }

            var stack = new Stack<Type>(_typeStacks[key.Type]);
            object value = null;
            stack.ForEach(type =>
            {
                value = context.NewBuildUp(new NamedTypeBuildKey(type, key.Name));
                var overrides = new DependencyOverride(key.Type, value);
                context.AddResolverOverrides(overrides);
            }
                );

            context.Existing = value;
            context.BuildComplete = true;
        }
开发者ID:medvekoma,项目名称:portfotolio,代码行数:27,代码来源:UnityDecoratorBuildStrategy.cs


示例6: GetWorkItem

        private WorkItem GetWorkItem(IBuilderContext context, object item)
        {
            if (item is WorkItem)
                return item as WorkItem;

            return context.Locator.Get<WorkItem>(new DependencyResolutionLocatorKey(typeof(WorkItem), null));
        }
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:7,代码来源:ActionStrategy.cs


示例7: Initialise

        /// <summary>
        /// Initializes the provider and ensures that all configuration can be read
        /// </summary>
        /// <param name="builderContext"></param>
        public override void Initialise(IBuilderContext builderContext)
        {
            Mandate.ParameterNotNull(builderContext, "builderContext");

            var configMain = builderContext.ConfigurationResolver.GetConfigSection(HiveConfigSection.ConfigXmlKey) as HiveConfigSection;

            if (configMain == null)
                throw new ConfigurationErrorsException(
                    string.Format("Configuration section '{0}' not found when building packaging provider '{1}'",
                                  HiveConfigSection.ConfigXmlKey, ProviderKey));

            var config2Rw = configMain.Providers.ReadWriters[ProviderKey] ?? configMain.Providers.Readers[ProviderKey];

            if (config2Rw == null)
                throw new ConfigurationErrorsException(
                    string.Format("No configuration found for persistence provider '{0}'", ProviderKey));

            //get the Hive provider config section
            _localConfig = DeepConfigManager.Default.GetFirstPluginSection<ProviderConfigurationSection>(config2Rw.ConfigSectionKey);

            if (!ValidateProviderConfigSection<MembershipDemandBuilder>(_localConfig, config2Rw))
            {
                CanBuild = false;
                return;
            }

            CanBuild = true;
        }
开发者ID:RebelCMS,项目名称:rebelcmsxu5,代码行数:32,代码来源:MembershipDemandBuilder.cs


示例8: BuildUp

        /// <summary>
        /// Implementation of <see cref="IBuilderStrategy.BuildUp"/>. Sets the property values.
        /// </summary>
        /// <param name="context">The build context.</param>
        /// <param name="typeToBuild">The type being built.</param>
        /// <param name="existing">The object on which to inject property values.</param>
        /// <param name="idToBuild">The ID of the object being built.</param>
        /// <returns>The built object.</returns>
        public override object BuildUp(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)
        {
            if (existing != null)
                InjectProperties(context, existing, idToBuild);

            return base.BuildUp(context, typeToBuild, existing, idToBuild);
        }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:15,代码来源:PropertySetterStrategy.cs


示例9: SelectProperty

        /// <summary>
        /// See <see cref="IPropertySetterInfo.SelectProperty"/> for more information.
        /// </summary>
        public PropertyInfo SelectProperty(IBuilderContext context, Type type, string id)
        {
            if (prop != null)
                return prop;

            return type.GetProperty(name);
        }
开发者ID:BackupTheBerlios,项目名称:sofia-svn,代码行数:10,代码来源:PropertySetterInfo.cs


示例10: PreBuildUp

        /// <summary>
        /// Called during the chain of responsibility for a build operation. The
        ///             PreBuildUp method is called when the chain is being executed in the
        ///             forward direction.
        /// </summary>
        /// <param name="context">Context of the build operation.</param>
        public override void PreBuildUp(IBuilderContext context)
        {
            if (context == null) throw new ArgumentNullException("context");

            var key = context.BuildKey;

            if(!RequestIsForValidatorOfT(key)) return;

            var typeToValidate = TypeToValidate(key.Type);
            var rulesetName = key.Name;

            var validatorFactory = GetValidatorFactory(context);

            Validator validator;

            if(string.IsNullOrEmpty(rulesetName))
            {
                validator = validatorFactory.CreateValidator(typeToValidate);
            }
            else
            {
                validator = validatorFactory.CreateValidator(typeToValidate, rulesetName);
            }

            context.Existing = validator;
            context.BuildComplete = true;
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:33,代码来源:ValidatorCreationStrategy.cs


示例11: GetValidatorFactory

        private ValidatorFactory GetValidatorFactory(IBuilderContext context)
        {
            var validationSpecificationSource = ValidationSource(context);

            if(validationSpecificationSource == 0)
            {
                throw new InvalidOperationException(
                    string.Format(CultureInfo.CurrentCulture, 
                    Resources.InvalidValidationSpecificationSource, validationSpecificationSource));
            }

            if(validationSpecificationSource == ValidationSpecificationSource.All)
            {
                return context.NewBuildUp<ValidatorFactory>();
            }

            var factories = new List<ValidatorFactory>();

            if((validationSpecificationSource & ValidationSpecificationSource.Attributes) != 0)
            {
                factories.Add(context.NewBuildUp<AttributeValidatorFactory>());
            }
            if((validationSpecificationSource & ValidationSpecificationSource.Configuration) != 0)
            {
                factories.Add(context.NewBuildUp<ConfigurationValidatorFactory>());
            }
            if((validationSpecificationSource & ValidationSpecificationSource.DataAnnotations) != 0)
            {
                factories.Add(context.NewBuildUp<ValidationAttributeValidatorFactory>());
            }

            return new CompositeValidatorFactory(GetInstrumentationProvider(context), factories);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:33,代码来源:ValidatorCreationStrategy.cs


示例12: BuildUp

        /// <summary>
        /// Implementation of <see cref="IBuilderStrategy.BuildUp"/>.
        /// </summary>
        /// <param name="context">The build context.</param>
        /// <param name="typeToBuild">The type of the object being built.</param>
        /// <param name="existing">The existing instance of the object.</param>
        /// <param name="idToBuild">The ID of the object being built.</param>
        /// <returns>The built object.</returns>
        public override object BuildUp(
			IBuilderContext context, Type typeToBuild, object existing, string idToBuild)
        {
            IBuildPlan buildPlan = GetPlanFromContext(context, typeToBuild, idToBuild);
            existing = buildPlan.BuildUp(context, typeToBuild, existing, idToBuild);
            return base.BuildUp(context, typeToBuild, existing, idToBuild);
        }
开发者ID:riseandcode,项目名称:open-wscf-2010,代码行数:15,代码来源:BuildPlanStrategy.cs


示例13: Build

        public void Build(IContainerBuilder containerBuilder, IBuilderContext context)
        {
            containerBuilder.For<MapResolverContext>().KnownAsSelf().ScopedAs.Singleton();

            // register the model mappers
            containerBuilder.For<RenderTypesModelMapper>()
                .KnownAs<AbstractMappingEngine>()
                .WithMetadata<TypeMapperMetadata, bool>(x => x.MetadataGeneratedByMapper, true)
                .ScopedAs.Singleton();

            containerBuilder
                .For<FrameworkModelMapper>()
                .KnownAs<AbstractMappingEngine>()
                .WithMetadata<TypeMapperMetadata, bool>(x => x.MetadataGeneratedByMapper, true)
                .ScopedAs.Singleton();

            //register model mapper for security model objects
            containerBuilder
                .For<SecurityModelMapper>()
                .KnownAs<AbstractMappingEngine>()
                .WithMetadata<TypeMapperMetadata, bool>(x => x.MetadataGeneratedByMapper, true)
                .ScopedAs.Singleton();

            //register model mapper for web model objects
            containerBuilder
                .For<CmsModelMapper>()
                .KnownAs<AbstractMappingEngine>()
                .WithMetadata<TypeMapperMetadata, bool>(x => x.MetadataGeneratedByMapper, true)
                .ScopedAs.Singleton();
        }
开发者ID:RebelCMS,项目名称:rebelcmsxu5,代码行数:30,代码来源:ModelMappingsDemandBuilder.cs


示例14: ApplyPolicy

        private void ApplyPolicy(IBuilderContext context, object obj, string id)
        {
            if (obj == null)
                return;

            Type type = obj.GetType();
            IMethodPolicy policy = context.Policies.Get<IMethodPolicy>(type, id);

            if (policy == null)
                return;

            foreach (IMethodCallInfo methodCallInfo in policy.Methods.Values)
            {
                MethodInfo methodInfo = methodCallInfo.SelectMethod(context, type, id);

                if (methodInfo != null)
                {
                    object[] parameters = methodCallInfo.GetParameters(context, type, id, methodInfo);
                    Guard.ValidateMethodParameters(methodInfo, parameters, obj.GetType());

                    if (TraceEnabled(context))
                        TraceBuildUp(context, type, id, Properties.Resources.CallingMethod, methodInfo.Name, ParametersToTypeList(parameters));

                    methodInfo.Invoke(obj, parameters);
                }
            }
        }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:27,代码来源:MethodExecutionStrategy.cs


示例15: DependencyResolver

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="context">The builder context in which the resolver will resolve
        /// dependencies.</param>
        public DependencyResolver(IBuilderContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            this.context = context;
        }
开发者ID:BackupTheBerlios,项目名称:sofia-svn,代码行数:12,代码来源:DependencyResolver.cs


示例16: PreBuildUp

            public override void PreBuildUp(IBuilderContext context)
            {
                var policy = BuildTracking.GetPolicy(context)
                    ?? BuildTracking.SetPolicy(context);

                policy.BuildKeys.Push(context.BuildKey);
            }
开发者ID:ramarivera,项目名称:TpFinalTDP2015,代码行数:7,代码来源:BuildTracking.cs


示例17: GetResolver

        /// <summary>
        /// Returns a <see cref="StepScopeResolverPolicy"/> for dependencies in the step scope.
        /// </summary>
        /// <param name="context">the current build context</param>
        /// <param name="dependencyType">the type of dependency</param>
        /// <returns>a <see cref="StepScopeResolverPolicy"/> if the dependency being resolved in is step scope; null otherwise</returns>
        public override IDependencyResolverPolicy GetResolver(IBuilderContext context, Type dependencyType)
        {
            var constructorParameterOperation = context.CurrentOperation as ConstructorArgumentResolveOperation;
            StepScopeDependency dependency;
            if (constructorParameterOperation != null &&
                _constructorParameters.TryGetValue(constructorParameterOperation.ParameterName, out dependency))
            {
                return new StepScopeResolverPolicy(dependency);
            }

            var propertyValueOperation = context.CurrentOperation as ResolvingPropertyValueOperation;
            if (propertyValueOperation != null && _properties.TryGetValue(propertyValueOperation.PropertyName, out dependency))
            {
                return new StepScopeResolverPolicy(dependency);
            }

            var methodParameterOperation = context.CurrentOperation as MethodArgumentResolveOperation;
            if (methodParameterOperation != null && 
                TryGetMethodParameterDependency(
                    new Tuple<string, string>(methodParameterOperation.MethodSignature, methodParameterOperation.ParameterName),
                    out dependency))
            {
                return new StepScopeResolverPolicy(dependency);
            }

            return null;
        }
开发者ID:pkubryk,项目名称:SummerBatch,代码行数:33,代码来源:StepScopeResolverOverride.cs


示例18: Resolve

 /// <summary>
 /// Get the value for a dependency.
 /// </summary>
 /// <param name="context">Current build context.</param>
 /// <returns>
 /// The value for the dependency.
 /// </returns>
 public object Resolve(IBuilderContext context)
 {
     return context.NewBuildUp(new NamedTypeBuildKey(validatorType, ruleSet),
         newContext => newContext.Policies.Set(
             new ValidationSpecificationSourcePolicy(validationSource),
             new NamedTypeBuildKey(validatorType, ruleSet)));
 }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:14,代码来源:ValidatorResolver.cs


示例19: CreateObject

        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            MockTraceListenerClient createdObject = new MockTraceListenerClient();
            createdObject.traceListener = TraceListenerCustomFactory.Instance.Create(context, name, configurationSource, reflectionCache);

            return createdObject;
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:7,代码来源:MockTraceListenerClient.cs


示例20: InjectProperties

 private void InjectProperties(IBuilderContext context, object obj, string id)
 {
     if (obj != null)
     {
         Type typePolicyAppliesTo = obj.GetType();
         IPropertySetterPolicy policy = context.Policies.Get<IPropertySetterPolicy>(typePolicyAppliesTo, id);
         if (policy != null)
         {
             foreach (IPropertySetterInfo info in policy.Properties.Values)
             {
                 PropertyInfo propInfo = info.SelectProperty(context, typePolicyAppliesTo, id);
                 if (propInfo != null)
                 {
                     if (!propInfo.CanWrite)
                     {
                         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.CannotInjectReadOnlyProperty, new object[] { typePolicyAppliesTo, propInfo.Name }));
                     }
                     object obj2 = info.GetValue(context, typePolicyAppliesTo, id, propInfo);
                     if (obj2 != null)
                     {
                         Guard.TypeIsAssignableFromType(propInfo.PropertyType, obj2.GetType(), obj.GetType());
                     }
                     if (base.TraceEnabled(context))
                     {
                         base.TraceBuildUp(context, typePolicyAppliesTo, id, Resources.CallingProperty, new object[] { propInfo.Name, propInfo.PropertyType.Name });
                     }
                     propInfo.SetValue(obj, obj2, null);
                 }
             }
         }
     }
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:32,代码来源:PropertySetterStrategy.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IBus类代码示例发布时间:2022-05-24
下一篇:
C# IBuilder类代码示例发布时间: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