コード例 #1
0
        public static async ValueTask <EntityScope <TEntity> > Create(
            Func <Task <TEntity> > entityCreate,
            Func <TEntity, Task> entityDelete,
            ILog log)
        {
            var lifetime = new Lifetime(log);

            try
            {
                var entity = await entityCreate();

                lifetime.Add(() => entityDelete(entity));
                var result = new EntityScope <TEntity>(entity, lifetime);
                lifetime = null;
                return(result);
            }
            finally
            {
                if (lifetime != null)
                {
                    await lifetime.DisposeAsync();
                }
            }
        }
コード例 #2
0
 public ValueTask DisposeAsync() => lifetime.DisposeAsync();
コード例 #3
0
 public async Task DisposeAsync() => await lifetime.DisposeAsync();