本文整理汇总了C#中IComponentRegistry类的典型用法代码示例。如果您正苦于以下问题:C# IComponentRegistry类的具体用法?C# IComponentRegistry怎么用?C# IComponentRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IComponentRegistry类属于命名空间,在下文中一共展示了IComponentRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry registry, IComponentRegistration registration)
{
registration.Preparing += (s, e) =>
{
e.Parameters = new [] { loggerParameter }.Concat(e.Parameters);
};
}
示例2: 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);
};
}
示例3: Configure
public void Configure(IComponentRegistry componentRegistry)
{
componentRegistry.Registered += (s, e) =>
{
e.ComponentRegistration.Preparing += OnComponentPreparing;
};
}
示例4: CopyOnWriteRegistry
public CopyOnWriteRegistry(IComponentRegistry readRegistry, Func<IComponentRegistry> createWriteRegistry)
{
if (readRegistry == null) throw new ArgumentNullException("readRegistry");
if (createWriteRegistry == null) throw new ArgumentNullException("createWriteRegistry");
_readRegistry = readRegistry;
_createWriteRegistry = createWriteRegistry;
}
示例5: Configure
public void Configure(IComponentRegistry componentRegistry)
{
var builder = new ContainerBuilder();
if (_atomicStorageFactory == null)
{
AtomicIsInMemory(strategyBuilder => { });
}
if (_streamingRoot == null)
{
StreamingIsInFiles(Directory.GetCurrentDirectory());
}
if (_tapeStorage == null)
{
TapeIsInMemory();
}
var core = new AtomicRegistrationCore(_atomicStorageFactory);
var source = new AtomicRegistrationSource(core);
builder.RegisterSource(source);
builder.RegisterInstance(new NuclearStorage(_atomicStorageFactory));
builder
.Register(
c => new AtomicStorageInitialization(new[] {_atomicStorageFactory}, c.Resolve<ISystemObserver>()))
.As<IEngineProcess>().SingleInstance();
builder.RegisterInstance(_streamingRoot);
builder.RegisterInstance(_tapeStorage);
builder.RegisterInstance(new TapeStorageInitilization(new[] {_tapeStorage})).As<IEngineProcess>();
builder.Update(componentRegistry);
}
示例6: AttachToComponentRegistration
protected override void AttachToComponentRegistration(
IComponentRegistry componentRegistry,
IComponentRegistration registration)
{
registration.Preparing += (sender, args) =>
log.Debug([email protected]"Resolving concrete type {args.Component.Activator.LimitType}");
}
示例7: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
registration.Preparing += (sender, args) =>
{
args.Parameters = args.Parameters.Union( new[] { new NamedParameter(@"basePoint", _basePoint) } );
};
}
示例8: RegistrationSourceAddedEventArgs
/// <summary>
/// Construct an instance of the <see cref="RegistrationSourceAddedEventArgs"/> class.
/// </summary>
/// <param name="componentRegistry">The registry to which the source was added.</param>
/// <param name="registrationSource">The source that was added.</param>
/// <exception cref="ArgumentNullException"></exception>
public RegistrationSourceAddedEventArgs(IComponentRegistry componentRegistry, IRegistrationSource registrationSource)
{
if (componentRegistry == null) throw new ArgumentNullException("componentRegistry");
if (registrationSource == null) throw new ArgumentNullException("registrationSource");
_componentRegistry = componentRegistry;
_registrationSource = registrationSource;
}
示例9: AttachToComponentRegistration
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry,
IComponentRegistration registration)
{
registration.Preparing += RegistrationOnPreparing;
registration.Activating += RegistrationOnActivating;
base.AttachToComponentRegistration(componentRegistry, registration);
}
示例10: 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);
};
}
}
}
示例11: LifetimeScope
/// <summary>
/// Create a root lifetime scope for the provided components.
/// </summary>
/// <param name="tag">The tag applied to the <see cref="ILifetimeScope"/>.</param>
/// <param name="componentRegistry">Components used in the scope.</param>
public LifetimeScope(IComponentRegistry componentRegistry, object tag)
: this()
{
_componentRegistry = Enforce.ArgumentNotNull(componentRegistry, "componentRegistry");
_root = this;
_tag = Enforce.ArgumentNotNull(tag, "tag");
}
示例12: AttachToRegistrationSource
protected override void AttachToRegistrationSource(IComponentRegistry componentRegistry, IRegistrationSource registrationSource)
{
base.AttachToRegistrationSource(componentRegistry, registrationSource);
var message = new RegistrationSourceAddedMessage(_modelMapper.GetRegistrationSourceModel(registrationSource));
Send(message);
}
示例13: 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)));
};
}
示例14: 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))
});
}
示例15: RegistrationSourceAddedEventArgs
/// <summary>
/// Construct an instance of the <see cref="RegistrationSourceAddedEventArgs"/> class.
/// </summary>
/// <param name="componentRegistry">The registry to which the source was added.</param>
/// <param name="registrationSource">The source that was added.</param>
/// <exception cref="ArgumentNullException"></exception>
public RegistrationSourceAddedEventArgs(IComponentRegistry componentRegistry, IRegistrationSource registrationSource)
{
if (componentRegistry == null) throw new ArgumentNullException(nameof(componentRegistry));
if (registrationSource == null) throw new ArgumentNullException(nameof(registrationSource));
ComponentRegistry = componentRegistry;
RegistrationSource = registrationSource;
}