コード例 #1
0
ファイル: UI.cs プロジェクト: ionutme/workshop-rx
        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);
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
 /// <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;
 }