本文整理汇总了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 });
}
示例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)));
}
示例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;
}
示例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));
}
示例5: GetBroker
private EventBroker GetBroker(IBuilderContext context)
{
var broker = context.NewBuildUp<EventBroker>();
if(broker == null)
{
throw new InvalidOperationException("No event broker available");
}
return broker;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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>());
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例15: GetInterceptor
public ITypeInterceptor GetInterceptor(IBuilderContext context)
{
Guard.ArgumentNotNull(context, "context");
return (ITypeInterceptor) context.NewBuildUp(buildKey);
}