private void BtnContextDisposableClick(object sender, EventArgs e) { txtOutput.Text = $"The UI Thread ID is: {Thread.CurrentThread.ManagedThreadId}{Environment.NewLine}"; var logging = new Action <string>(message => txtOutput.Invoke(new Action(() => txtOutput.Text += message + Environment.NewLine))); LifetimeManagement.ContextDisposable_WillExecuteItsDisposableImplementation_OnTheSpecifiedSynchronizationContext(logging); }
private LifetimeManager GenerateLifetimeManager(LifetimeManagement lifeManagementEnum) { switch (lifeManagementEnum) { case LifetimeManagement.Transient: return(new TransientLifetimeManager()); case LifetimeManagement.TransientPerResolve: return(new PerResolveLifetimeManager()); case LifetimeManagement.Singleton: return(new ContainerControlledLifetimeManager()); case LifetimeManagement.ThreadSingleton: return(new PerThreadLifetimeManager()); default: throw new ArgumentOutOfRangeException(nameof(lifeManagementEnum)); } }
private LifetimeManager GetLifetimeStateInstance(LifetimeManagement lifetime) { switch (lifetime) { case LifetimeManagement.TransientLifetime: return(new TransientLifetimeManager()); case LifetimeManagement.ContainerControlledLifetime: return(new ContainerControlledLifetimeManager()); case LifetimeManagement.PerThreadLifetime: return(new PerThreadLifetimeManager()); case LifetimeManagement.PerResolveLifetime: return(new PerResolveLifetimeManager()); case LifetimeManagement.PerRequestLifetime: return(new PerRequestLifetimeManager()); default: return(new TransientLifetimeManager()); } }
/// <summary> /// Initialise une nouvelle instance de la classe <see cref="InheritedExportAsAttribute"/>. /// </summary> /// <param name="mode">le mode de gestion de la durée de vie.</param> public InheritedExportAsAttribute(LifetimeManagement mode) : base() { LifetimeManagement = mode; }