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


C# IBuilderContext.NewBuildUp方法代码示例

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


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

示例1: PostBuildUp

        public override void PostBuildUp(IBuilderContext context)
        {
            if (context.Existing is IInterceptingProxy || !_interfaceInterceptor.CanIntercept(context.OriginalBuildKey.Type))
                return;

            if (!context.Existing.GetType().HasCustomerAttributes<LogAttribute>())
                return;

            //var methods = _interfaceInterceptor.GetInterceptableMethods(context.OriginalBuildKey.Type, context.BuildKey.Type);

            var loggingInterceptionBehavior = new LoggingInterfaceMethodBehavior(context.NewBuildUp<ILogMethodInvocation>(), context.NewBuildUp<PropertyMappingDictionary>(), context.Existing.GetType());

            context.Existing = Intercept.ThroughProxy(context.OriginalBuildKey.Type, context.Existing, _interfaceInterceptor, new[] { loggingInterceptionBehavior });
        }
开发者ID:ptsurko,项目名称:Unity.Logging,代码行数:14,代码来源:LoggingInterfaceMethodBuildStrategy.cs

示例2: 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

示例3: 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

示例4: 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)
 {
     if (context == null)
      {
     throw new ArgumentNullException("context");
      }
      return context.NewBuildUp(new NamedTypeBuildKey(typeToBuild));
 }
开发者ID:kostaswonga,项目名称:NServiceBus,代码行数:13,代码来源:OptionalFixedTypeResolverPolicy.cs

示例5: GetBroker

 private EventBroker GetBroker(IBuilderContext context)
 {
     var broker = context.NewBuildUp<EventBroker>();
     if(broker == null)
     {
         throw new InvalidOperationException("No event broker available");
     }
     return broker;
 }
开发者ID:CFMITL,项目名称:unity,代码行数:9,代码来源:EventBrokerWireupStrategy.cs

示例6: GetSettingsFactory

      private static ISettingsFactory GetSettingsFactory(IBuilderContext context)
      {
         var factory = context.NewBuildUp<ISettingsFactory>("DefaultSettingsFactory");
         if (factory == null) {
            throw new InvalidOperationException("No instance of ISettingsFactory available.");
         }

         return factory;
      }
开发者ID:bgrebil,项目名称:Unity.Settings,代码行数:9,代码来源:SettingsProviderExtension.cs

示例7: BuildUp

        /// <summary>
        ///   Creates an instance of this build plan's type, or fills
        ///   in the existing type if passed in.
        /// </summary>
        /// <param name = "context">Context used to build up the object.</param>
        public void BuildUp(IBuilderContext context)
        {
            if (context.Existing == null)
            {
                var currentContainer = context.NewBuildUp<IUnityContainer>();
                context.Existing = factory(currentContainer, context.BuildKey.Type, context.BuildKey.Name);

                DynamicMethodConstructorStrategy.SetPerBuildSingleton(context);
            }
        }
开发者ID:Raconeisteron,项目名称:bakopanos,代码行数:15,代码来源:FactoryDelegateBuildPlanPolicy.cs

示例8: Resolve

 /// <summary>
 /// Resolve object from given context.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public object Resolve(IBuilderContext context)
 {
     var uri = (string) _uriResolver.Resolve(context);
     var resourceLoader = context.NewBuildUp<ResourceLoader>();
     if (_many)
     {
         return resourceLoader.GetResources(uri);
     }
     return resourceLoader.GetResource(uri);
 }
开发者ID:pkubryk,项目名称:SummerBatch,代码行数:15,代码来源:ResourceDependencyResolverPolicy.cs

示例9: PostBuildUp

		public override void PostBuildUp(IBuilderContext context)
		{
			var proxy = context.Existing as IInterceptingProxy;
			if (proxy == null || context.Policies.Get<InterceptVirtualMethodPolicy>(context.BuildKey) == null)
				return;

			//var methods = _virtualMethodInterceptor.GetInterceptableMethods(context.OriginalBuildKey.Type, context.BuildKey.Type);

			//proxy.AddInterceptionBehavior(new LoggingVirtualMethodBehavior(context.NewBuildUp<ILogger>(), context.NewBuildUp<PropertyMappingDictionary>()));
			proxy.AddInterceptionBehavior(context.NewBuildUp<LoggingVirtualMethodBehavior>());
		}
开发者ID:ptsurko,项目名称:Unity.Logging,代码行数:11,代码来源:LoggingVirtualMethodBuildStrategy.cs

示例10: BuildUp

        public void BuildUp(IBuilderContext context)
        {
            Microsoft.Practices.Unity.Utility.Guard.ArgumentNotNull(context, "context");

            if(context.Existing == null)
            {
                var currentContainer = context.NewBuildUp<IUnityContainer>();
                context.Existing = factory(currentContainer, context.BuildKey.Type, context.BuildKey.Name);

                DynamicMethodConstructorStrategy.SetPerBuildSingleton(context);
            }
        }
开发者ID:theoju,项目名称:CleanCode,代码行数:12,代码来源:FactoryDelegateBuildPlanPolicy.cs

示例11: PreBuildUp

 public override void PreBuildUp(IBuilderContext context)
 {
     if (context.Existing == null)
     {
         var policy = context.Policies.Get<IAutoFactoryPolicy>(context.OriginalBuildKey);
         if (policy != null)
         {
             var autoFactoryType = AutoFactoryTypeGenerator.GetAutoFactoryType(context.OriginalBuildKey.Type, policy.ConcreteResultType);
             context.Existing = context.NewBuildUp(new NamedTypeBuildKey(autoFactoryType, context.OriginalBuildKey.Name));
         }
     }
     base.PreBuildUp(context);
 }
开发者ID:thomaslevesque,项目名称:Unity.AutoFactory,代码行数:13,代码来源:AutoFactoryStrategy.cs

示例12: PreBuildUp

 public override void PreBuildUp(IBuilderContext context)
 {
     if (context.Existing == null)
     {
         var policy = context.Policies.Get<ILazyProxyPolicy>(context.OriginalBuildKey);
         if (policy != null)
         {
             var lazyProxyType = LazyProxyGenerator.GetLazyProxyType(policy.ServiceType, policy.ImplementationType);
             context.Existing = context.NewBuildUp(new NamedTypeBuildKey(lazyProxyType, context.OriginalBuildKey.Name));
         }
     }
     base.PreBuildUp(context);
 }
开发者ID:thomaslevesque,项目名称:LazyProxy,代码行数:13,代码来源:LazyProxyBuilderStrategy.cs

示例13: GetEffectiveBehaviors

        /// <summary>
        /// Get the set of <see cref="IInterceptionBehavior"/> object to be used for the given type and
        /// interceptor.
        /// </summary>
        /// <remarks>
        /// This method will return a sequence of <see cref="IInterceptionBehavior"/>s. These behaviors will
        /// only be included if their <see cref="IInterceptionBehavior.WillExecute"/> properties are true.
        /// </remarks>
        /// <param name="context">Context for the current build operation.</param>
        /// <param name="interceptor">Interceptor that will be used to invoke the behavior.</param>
        /// <param name="typeToIntercept">Type that interception was requested on.</param>
        /// <param name="implementationType">Type that implements the interception.</param>
        /// <returns></returns>
        public IEnumerable<IInterceptionBehavior> GetEffectiveBehaviors(
            IBuilderContext context, IInterceptor interceptor, Type typeToIntercept, Type implementationType)
        {
            var interceptionRequest = new CurrentInterceptionRequest(interceptor, typeToIntercept, implementationType);

            foreach (var key in BehaviorKeys)
            {
                var behavior = (IInterceptionBehavior)context.NewBuildUp(key,
                    childContext => childContext.AddResolverOverrides(
                        new DependencyOverride<CurrentInterceptionRequest>(interceptionRequest)));
                yield return behavior;
            }
        }
开发者ID:kangkot,项目名称:unity,代码行数:26,代码来源:InterceptionBehaviorsPolicy.cs

示例14: GetInstrumentationProvider

 private static IValidationInstrumentationProvider GetInstrumentationProvider(IBuilderContext context)
 {
     var mapping = context.Policies.Get<IBuildKeyMappingPolicy>(
             NamedTypeBuildKey.Make<IValidationInstrumentationProvider>());
     if(mapping != null)
     {
         return context.NewBuildUp<IValidationInstrumentationProvider>();
     }
     return null;
 }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:10,代码来源:ValidatorCreationStrategy.cs

示例15: GetInterceptor

 public ITypeInterceptor GetInterceptor(IBuilderContext context)
 {
     Guard.ArgumentNotNull(context, "context");
     return (ITypeInterceptor) context.NewBuildUp(buildKey);
 }
开发者ID:theoju,项目名称:CleanCode,代码行数:5,代码来源:ResolvedTypeInterceptionPolicy.cs


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