本文整理汇总了C#中IComponentRegistration类的典型用法代码示例。如果您正苦于以下问题:C# IComponentRegistration类的具体用法?C# IComponentRegistration怎么用?C# IComponentRegistration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IComponentRegistration类属于命名空间,在下文中一共展示了IComponentRegistration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InstanceLookup
public InstanceLookup(
IComponentRegistration registration,
IResolveOperation context,
ISharingLifetimeScope mostNestedVisibleScope,
IEnumerable<Parameter> parameters)
{
Parameters = parameters;
ComponentRegistration = registration;
_context = context;
try
{
_activationScope = ComponentRegistration.Lifetime.FindScope(mostNestedVisibleScope);
}
catch (DependencyResolutionException ex)
{
var services = new StringBuilder();
foreach (var s in registration.Services)
{
services.Append("- ");
services.AppendLine(s.Description);
}
var message = String.Format(CultureInfo.CurrentCulture, ComponentActivationResources.UnableToLocateLifetimeScope, registration.Activator.LimitType, services);
throw new DependencyResolutionException(message, ex);
}
}
开发者ID:GitHuang,项目名称:Autofac,代码行数:27,代码来源:InstanceLookup.cs
示例2: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry registry, IComponentRegistration registration)
{
registration.Preparing += (s, e) =>
{
e.Parameters = new [] { loggerParameter }.Concat(e.Parameters);
};
}
开发者ID:ChrisMH,项目名称:Utility.Logging,代码行数:7,代码来源:NLogLoggerAutofacModule.cs
示例3: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry,
IComponentRegistration registration)
{
registration.Preparing += RegistrationOnPreparing;
registration.Activating += RegistrationOnActivating;
base.AttachToComponentRegistration(componentRegistry, registration);
}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:7,代码来源:AutofacResolveLoggingModule.cs
示例4: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
registration.Preparing += (sender, args) =>
{
args.Parameters = args.Parameters.Union( new[] { new NamedParameter(@"basePoint", _basePoint) } );
};
}
开发者ID:gofixiao,项目名称:Macsauto-Backup,代码行数:7,代码来源:InfrastructureModule.cs
示例5: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
var implementationType = registration.Activator.LimitType;
foreach (var autoWireType in autoWireTypes)
{
var constructors = implementationType.GetConstructorsWithDependency(autoWireType);
if (constructors.Any())
{
registration.Preparing += (sender, e) =>
{
var parameter = new TypedParameter(autoWireType,
e.Context.Resolve(autoWireType, new TypedParameter(typeof(Type), implementationType)));
e.Parameters = e.Parameters.Concat(new[] { parameter });
};
}
else
{
var props = implementationType.GetPropertiesWithDependency(autoWireType);
if (props.Any())
{
registration.Activated += (s, e) =>
{
foreach (var prop in props)
{
prop.SetValue(e.Instance,
e.Context.Resolve(autoWireType));
}
};
}
}
}
foreach (var serviceType in typebasedServiceTypes)
{
var constructorInjectors = BuildConstructorServiceInjectors(implementationType, serviceType).ToArray();
if (constructorInjectors.Any())
{
registration.Preparing += (s, e) =>
{
foreach (var ci in constructorInjectors)
ci(e);
};
return;
}
// build an array of actions on this type to assign loggers to member properties
var injectors = BuildPropertyServiceInjectors(implementationType, serviceType).ToArray();
if (injectors.Any())
{
registration.Activated += (s, e) =>
{
foreach (var injector in injectors)
injector(e.Context, e.Instance);
};
}
}
}
开发者ID:cairabbit,项目名称:daf,代码行数:60,代码来源:AttachComponentModule.cs
示例6: PreparingEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="PreparingEventArgs"/> class.
/// </summary>
/// <param name="service">Service which is preparing</param>
/// <param name="context">The context.</param>
/// <param name="component">The component.</param>
/// <param name="parameters">The parameters.</param>
public PreparingEventArgs(Service service, IComponentContext context, IComponentRegistration component, IEnumerable<Parameter> parameters)
{
_service = Enforce.ArgumentNotNull(service, "service");
_context = Enforce.ArgumentNotNull(context, "context");
_component = Enforce.ArgumentNotNull(component, "component");
_parameters = Enforce.ArgumentNotNull(parameters, "parameters");
}
开发者ID:dstimac,项目名称:revenj,代码行数:14,代码来源:PreparingEventArgs.cs
示例7: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
var type = registration.Activator.LimitType; // AF2.0+
// .Descriptor.BestKnownImplementationType; // AF1.2+
// we hook preparing to inject the logger into the constructor
registration.Preparing += OnComponentPreparing;
// build the list of actions for type and assign loggers to properties
var injectors = BuildLogPropertyInjectors(type);
// no logger properties, no need to hook up the event
// ReSharper disable PossibleMultipleEnumeration
if (!injectors.Any())
// ReSharper restore PossibleMultipleEnumeration
return;
// we hook acticating to inject the logger into the known public properties
registration.Activating += (s, e) =>
{
// ReSharper disable PossibleMultipleEnumeration
foreach (var injector in injectors)
// ReSharper restore PossibleMultipleEnumeration
injector(e.Context, e.Instance);
};
}
开发者ID:dbuksbaum,项目名称:Hazware.Core,代码行数:26,代码来源:AbstractLoggingRegistrationModule.cs
示例8: AttachToComponentRegistration
protected override void AttachToComponentRegistration(
IComponentRegistry componentRegistry,
IComponentRegistration registration)
{
registration.Preparing += (sender, args) =>
log.Debug([email protected]"Resolving concrete type {args.Component.Activator.LimitType}");
}
开发者ID:piriej,项目名称:Assignment3,代码行数:7,代码来源:ContainerSpecimenBuilder.cs
示例9: ShapeAttributeOccurrence
public ShapeAttributeOccurrence(ShapeAttribute shapeAttribute, MethodInfo methodInfo, IComponentRegistration registration, Func<Feature> feature)
{
ShapeAttribute = shapeAttribute;
MethodInfo = methodInfo;
Registration = registration;
_feature = feature;
}
开发者ID:l1183479157,项目名称:RabbitHub,代码行数:7,代码来源:ShapeAttributeOccurrence.cs
示例10: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
registration.Activating += (sender, e) =>
{
if (typeof (IMessageConsumer).IsAssignableFrom(e.Instance.GetType()))
consumerInterceptor.ItemCreated(e.Instance.GetType(), e.Component.Lifetime.GetType().Equals(typeof(CurrentScopeLifetime)));
};
}
开发者ID:BiYiTuan,项目名称:rhino-esb,代码行数:8,代码来源:ConsumerInterceptorModule.cs
示例11: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
registration.Preparing += (sender, args) => args.Parameters = args.Parameters.Concat(new[]
{
new ResolvedParameter((info, context) => info.ParameterType == typeof (ILog),
(info, context) => _logFactory(info.Member.DeclaringType))
});
}
开发者ID:patterns-group,项目名称:code-patterns,代码行数:8,代码来源:LoggingModule.cs
示例12: ComponentRegistrationLifetimeDecorator
public ComponentRegistrationLifetimeDecorator(IComponentRegistration inner, IComponentLifetime lifetime)
{
if (inner == null) throw new ArgumentNullException("inner");
if (lifetime == null) throw new ArgumentNullException("lifetime");
_inner = inner;
_lifetime = lifetime;
}
开发者ID:Ontropix,项目名称:slow-camera,代码行数:8,代码来源:ComponentRegistrationLifetimeDecorator.cs
示例13: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
// Handle constructor parameters.
registration.Preparing += OnComponentPreparing;
// Handle properties.
registration.Activated += (sender, e) => InjectLoggerProperties(e.Instance);
}
开发者ID:johnnyreilly,项目名称:proverb-api,代码行数:8,代码来源:LoggingModule.cs
示例14: AddDecoratedComponentParameter
static IEnumerable<Parameter> AddDecoratedComponentParameter(Type decoratedParameterType, IComponentRegistration decoratedComponent, IEnumerable<Parameter> configuredParameters)
{
var parameter = new ResolvedParameter(
(pi, c) => pi.ParameterType == decoratedParameterType,
(pi, c) => c.ResolveComponent(decoratedComponent, Enumerable.Empty<Parameter>()));
return new[] { parameter }.Concat(configuredParameters);
}
开发者ID:RoymanJing,项目名称:Autofac,代码行数:8,代码来源:OpenGenericDecoratorRegistrationSource.cs
示例15: ComponentRegisteredEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="ComponentRegisteredEventArgs"/> class.
/// </summary>
/// <param name="registry">The container into which the registration
/// was made.</param>
/// <param name="componentRegistration">The component registration.</param>
public ComponentRegisteredEventArgs(IComponentRegistry registry, IComponentRegistration componentRegistration)
{
if (registry == null) throw new ArgumentNullException(nameof(registry));
if (componentRegistration == null) throw new ArgumentNullException(nameof(componentRegistration));
ComponentRegistry = registry;
ComponentRegistration = componentRegistration;
}
开发者ID:GitHuang,项目名称:Autofac,代码行数:14,代码来源:ComponentRegisteredEventArgs.cs
示例16: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
// Use the event args to log detailed info
registration.Preparing += (sender, args) =>
Debug.WriteLine(
"Resolving concrete type {0}, Id {1}",
args.Component.Activator.LimitType, args.Component.Id.ToString());
}
开发者ID:darrenschwarz,项目名称:Karama.Identity.Net46,代码行数:8,代码来源:LogRequestsModule.cs
示例17: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
Type implementationType = registration.Activator.LimitType;
if (DynamicProxyContext.From(registration) != null && implementationType.FullName == "Orchard.Car.Services.CarInfoService")
{
registration.InterceptedBy<SimpleInterceptor>();
}
}
开发者ID:huhan,项目名称:OrchardNoCMS,代码行数:8,代码来源:SimpleInterceptorModule.cs
示例18: RecordActivation
public void RecordActivation(IComponentRegistration component)
{
lock (_synchRoot)
{
var componentInfo = GetComponent(component.Id);
componentInfo.RecordActivation();
}
}
开发者ID:rjmurillo,项目名称:Autofac-Visualizer,代码行数:8,代码来源:ContainerProfile.cs
示例19: AttachToComponentRegistration
protected override void AttachToComponentRegistration(
IContainer container, IComponentRegistration registration)
{
base.AttachToComponentRegistration(container, registration);
var registeredType = registration.Descriptor.BestKnownImplementationType;
if (IsConfiguredTransport(registeredType))
DecorateTransport(container, registeredType);
}
开发者ID:thirkcircus,项目名称:NServiceBus.MessageSinks,代码行数:9,代码来源:MessageSinkConfigurationModule.cs
示例20: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
var implementationType = registration.Activator.LimitType;
var property = FindProperty(implementationType);
if (property != null) {
registration.InterceptedBy<ISecurityModuleInterceptor>();
}
}
开发者ID:mofashi2011,项目名称:orchardcms,代码行数:9,代码来源:SecurityModule.cs
注:本文中的IComponentRegistration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论