示例#1
0
 private IEnumerable <StatefulServiceDelegate> GetServiceDelegates(
     StatefulServiceLifecycleEvent @event)
 {
     return(this.serviceDelegates == null
         ? Array.Empty <StatefulServiceDelegate>()
         : this.serviceDelegates[@event]);
 }
        private static IStatefulServiceHostDelegateReplicator MockDelegateReplicatorForEvent(
            Action mockDelegate,
            StatefulServiceLifecycleEvent mockEvent)
        {
            var mockDelegateReplicator = new Mock <IStatefulServiceHostDelegateReplicator>();

            mockDelegateReplicator.Setup(instance => instance.ReplicateFor(It.IsAny <IStatefulService>()))
            .Returns(
                new StatefulServiceDelegate(
                    () =>
            {
                var mockTask            = new TaskCompletionSource <bool>();
                var mockDelegateInvoker = new Mock <IStatefulServiceHostDelegateInvoker>();
                mockDelegateInvoker.Setup(
                    instance => instance.InvokeAsync(It.IsAny <IStatefulServiceDelegateInvocationContext>(), It.IsAny <CancellationToken>()))
                .Callback(
                    () =>
                {
                    mockDelegate();
                    mockTask.SetResult(true);
                })
                .Returns(mockTask.Task);

                return(mockDelegateInvoker.Object);
            },
                    mockEvent));

            return(mockDelegateReplicator.Object);
        }
示例#3
0
 public StatefulServiceDelegate(
     Func <IStatefulServiceHostDelegateInvoker> delegateInvokerFunc,
     StatefulServiceLifecycleEvent @event)
 {
     this.Event = @event;
     this.CreateDelegateInvokerFunc = delegateInvokerFunc
                                      ?? throw new ArgumentNullException(nameof(delegateInvokerFunc));
 }
        public static IStatefulServiceHostDelegateReplicaTemplate UseEvent(
            this IStatefulServiceHostDelegateReplicaTemplate @this,
            StatefulServiceLifecycleEvent @event)
        {
            @this.ConfigureObject(
                configurator => configurator.UseEvent(@event));

            return(@this);
        }
示例#5
0
 public void UseEvent(
     StatefulServiceLifecycleEvent @event)
 {
     this.Event = @event;
 }
 public StatefulServiceDelegateInvocationContext(
     StatefulServiceLifecycleEvent @event)
 {
     this.Event = @event;
 }