예제 #1
0
        public override async Task DeleteAsync(ActorActivatorState obj)
        {
            var state = (State)obj;

            await DisposeCore(state.Actor);
            await DisposeCore(state.Scope);
        }
예제 #2
0
        public async Task DeleteAsync_NotDisposable()
        {
            var activator = new DefaultActorActivator();

            var host  = new ActorHost(ActorTypeInformation.Get(typeof(TestActor)), ActorId.CreateRandom(), JsonSerializerDefaults.Web, NullLoggerFactory.Instance, ActorProxy.DefaultProxyFactory);
            var actor = new TestActor(host);
            var state = new ActorActivatorState(actor);

            await activator.DeleteAsync(state); // does not throw
        }
예제 #3
0
        public async Task DeleteAsync_NotDisposable()
        {
            var activator = new DefaultActorActivator();

            var host  = ActorHost.CreateForTest <TestActor>();
            var actor = new TestActor(host);
            var state = new ActorActivatorState(actor);

            await activator.DeleteAsync(state); // does not throw
        }
예제 #4
0
 /// <summary>
 /// Deletes the actor instance and cleans up all associated resources.
 /// </summary>
 /// <param name="state">
 /// The <see cref="ActorActivatorState" /> instance that was created during creation of the actor.
 /// </param>
 /// <returns>
 /// A task that represents the asynchronous completion of the operation.
 /// </returns>
 /// <remarks>
 /// Implementations should not interact with lifecycle callback methods on the <see cref="Actor" /> type.
 /// These methods will be called by the runtime.
 /// </remarks>
 public async override ValueTask DeleteAsync(ActorActivatorState state)
 {
     if (state.Actor is IAsyncDisposable asyncDisposable)
     {
         await asyncDisposable.DisposeAsync();
     }
     else if (state.Actor is IDisposable disposable)
     {
         disposable.Dispose();
     }
 }
예제 #5
0
        public async Task DeleteAsync_AsyncDisposable()
        {
            var activator = new DefaultActorActivator();

            var host  = new ActorHost(ActorTypeInformation.Get(typeof(AsyncDisposableActor)), ActorId.CreateRandom(), JsonSerializerDefaults.Web, NullLoggerFactory.Instance, ActorProxy.DefaultProxyFactory);
            var actor = new AsyncDisposableActor(host);
            var state = new ActorActivatorState(actor);

            await activator.DeleteAsync(state);

            Assert.True(actor.IsDisposed);
        }
예제 #6
0
        public async Task DeleteAsync_Disposable()
        {
            var activator = new DefaultActorActivator();

            var host  = new ActorHost(ActorTypeInformation.Get(typeof(DisposableActor)), ActorId.CreateRandom(), NullLoggerFactory.Instance);
            var actor = new DisposableActor(host);
            var state = new ActorActivatorState(actor);

            await activator.DeleteAsync(state); // does not throw

            Assert.True(actor.IsDisposed);
        }
예제 #7
0
        public async Task DeleteAsync_AsyncDisposable()
        {
            var activator = new DefaultActorActivator();

            var host  = ActorHost.CreateForTest <AsyncDisposableActor>();
            var actor = new AsyncDisposableActor(host);
            var state = new ActorActivatorState(actor);

            await activator.DeleteAsync(state);

            Assert.True(actor.IsDisposed);
        }
예제 #8
0
 public override Task DeleteAsync(ActorActivatorState state)
 {
     DeleteCallCount++;
     return(base.DeleteAsync(state));
 }
예제 #9
0
 /// <summary>
 /// Deletes the actor instance and cleans up all associated resources.
 /// </summary>
 /// <param name="state">
 /// The <see cref="ActorActivatorState" /> instance that was created during creation of the actor.
 /// </param>
 /// <returns>
 /// A task that represents the asynchronous completion of the operation.
 /// </returns>
 /// <remarks>
 /// Implementations should not interact with lifecycle callback methods on the <see cref="Actor" /> type.
 /// These methods will be called by the runtime.
 /// </remarks>
 public abstract Task DeleteAsync(ActorActivatorState state);