/// <summary> /// Handles the <see cref="ExtensionContext.RegisteringInstance"/> event by /// ensuring that, if the lifetime manager is a <see cref="SynchronizedLifetimeManager"/> that its /// <see cref="SynchronizedLifetimeManager.GetValue"/> method has been called. /// </summary> /// <param name="sender">The object responsible for raising the event.</param> /// <param name="e">A <see cref="RegisterInstanceEventArgs"/> containing the event's data.</param> private void PreRegisteringInstance(object sender, RegisterInstanceEventArgs e) { if (e.LifetimeManager is SynchronizedLifetimeManager) { e.LifetimeManager.GetValue(); } }
private void OnRegisteringInstance(object sender, RegisterInstanceEventArgs e) { this.entries.Add(new TypeRegistrationEntry(e.RegisteredType, e.Name)); if (RegisteringInstance != null) RegisteringInstance(sender, e); }
/// <summary> /// Gets called when a new instance of a registered type is created. /// This is used to filter out module types and keep track of them. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnRegisteringInstance(object sender, RegisterInstanceEventArgs e) { if (e.RegisteredType.GetInterface(typeof(IModule).FullName) != null) { IModuleStatusService service = Container.Resolve<IModuleStatusService>(); service.RegisterLoadedModule(e.RegisteredType); } }
private void OnRegisterInstance(object sender, RegisterInstanceEventArgs e) { Context.RegisterNamedType(e.RegisteredType, e.Name); SetLifetimeManager(e.RegisteredType, e.Name, e.LifetimeManager); NamedTypeBuildKey identityKey = new NamedTypeBuildKey(e.RegisteredType, e.Name); Context.Policies.Set<IBuildKeyMappingPolicy>(new BuildKeyMappingPolicy(identityKey), identityKey); e.LifetimeManager.SetValue(e.Instance); }
private void OnRegisterInstance(object sender, RegisterInstanceEventArgs e) { Context.RegisterNamedType(e.RegisteredType, e.Name); this.SetLifetimeManager(e.RegisteredType, e.Name, e.LifetimeManager); NamedTypeBuildKey identityKey = new NamedTypeBuildKey(e.RegisteredType, e.Name); Context.Policies.Set <IBuildKeyMappingPolicy>(new BuildKeyMappingPolicy(identityKey), identityKey); e.LifetimeManager.SetValue(e.Instance); }
private void OnRegisterInstance(object sender, RegisterInstanceEventArgs e) { Context.RegisterNamedType(e.RegisteredType, e.Name); SetLifetimeManager(e.RegisteredType, e.Name, e.LifetimeManager); NamedTypeBuildKey identityKey = new NamedTypeBuildKey(e.RegisteredType, e.Name); Context.Policies.Set<IBuildKeyMappingPolicy>(new BuildKeyMappingPolicy(identityKey), identityKey); if (e.LifetimeManager is SynchronizedLifetimeManager) { // workaround to prevent a SynchronizationLockException from being thrown and caught e.LifetimeManager.GetValue(); } e.LifetimeManager.SetValue(e.Instance); }
private void OnRegisterInstance(object sender, RegisterInstanceEventArgs e) { var atts = e.Instance.GetType().GetCustomAttributes(typeof(SystemImmutableComponentAttribute), false); var atts2 = e.RegisteredType.GetCustomAttributes(typeof(SystemImmutableComponentAttribute), false); if ((atts.Length > 0) || (atts2.Length > 0) && (SistemComponentInstanceRegistered != null)) { var duplicated = (_registeredInstances.Contains(e.Instance.GetType()) || (_registeredInstances.Contains(e.RegisteredType))); SistemComponentInstanceRegistered(this, new InstanceRegisterEventArgs(e, duplicated)); } AddInstance(e.Instance.GetType()); }
void Context_RegisteringInstance(object sender, RegisterInstanceEventArgs e) { _logger.Log(String.Format("REG INSTANCE {0}", e.Instance.GetType().Name), Category.Debug, Priority.None); }
private void OnRegisterInstance(object sender, RegisterInstanceEventArgs e) { Context.RegisterNamedType(e.RegisteredType, e.Name); SetLifetimeManager(e.RegisteredType, e.Name, e.LifetimeManager); e.LifetimeManager.SetValue(e.Instance); }
private void OnRegisteringInstance(object sender, RegisterInstanceEventArgs e) { string returnedName = EnsureAndReturnName(e.Name, e.RegisteredType); if (!string.IsNullOrEmpty(returnedName)) { e.Name = returnedName; } }
void OnRegisteringInstance(object sender, RegisterInstanceEventArgs e) { Trace.WriteLine(String.Format("Registering Instance: {0}", e.Name ?? "_Default_")); Trace.WriteLine(String.Format(" Type: {0}", e.RegisteredType)); Trace.WriteLine(String.Format(" Lifetime: {0}", e.LifetimeManager.GetType())); }
public InstanceRegisterEventArgs(RegisterInstanceEventArgs e, bool isDuplicated) : this(e.RegisteredType, e.Instance, e.Name, e.LifetimeManager, isDuplicated) { }