コード例 #1
0
 public MockableActorRegistration(
     Func <ActorService, ActorId, TActorImplementation> activator,
     CreateStateManager createStateManager   = null,
     CreateStateProvider createStateProvider = null)
 {
     InterfaceType       = typeof(TActorInterface);
     ImplementationType  = typeof(TActorImplementation);
     Activator           = activator;
     CreateStateManager  = createStateManager;
     CreateStateProvider = createStateProvider;
     CreateActorService  = null;
 }
コード例 #2
0
        public void SetupActor <TActorImplementation>(
            Func <ActorService, ActorId, TActorImplementation> activator,
            CreateStateManager createStateManager   = null,
            CreateStateProvider createStateProvider = null)
            where TActorImplementation : class, IActor
        {
            var actorInterface = typeof(TActorImplementation).IsInterface
                ? typeof(TActorImplementation)
                : typeof(TActorImplementation).GetInterfaces().FirstOrDefault(i => i.GetInterfaces().Any(i2 => i2 == typeof(IActor)));
            var actorRegistration = new MockableActorRegistration(actorInterface, typeof(TActorImplementation), activator, createStateManager, createStateProvider);

            ((MockActorProxyFactory)ActorProxyFactory).AddActorRegistration(actorRegistration);
        }
コード例 #3
0
        public void SetupActor <TActorImplementation, TActorService>(
            Func <TActorService, ActorId, TActorImplementation> activator,
            CreateActorService <TActorService> createActorService,
            CreateStateManager createStateManager   = null,
            CreateStateProvider createStateProvider = null)
            where TActorImplementation : class, IActor
            where TActorService : ActorService
        {
            var actorInterface = typeof(TActorImplementation).IsInterface
                ? typeof(TActorImplementation)
                : typeof(TActorImplementation).GetInterfaces().FirstOrDefault(i => i.GetInterfaces().Any(i2 => i2 == typeof(IActor)));
            var actorRegistration = new MockableActorRegistration <TActorService>(
                interfaceType: actorInterface,
                implementationType: typeof(TActorImplementation),
                createActorService: createActorService,
                activator: (Func <ActorService, ActorId, TActorImplementation>)((actorService, actorId) => activator((TActorService)actorService, actorId)),
                createStateManager: createStateManager,
                createStateProvider: createStateProvider);

            ((MockActorProxyFactory)ActorProxyFactory).AddActorRegistration(actorRegistration);
        }