예제 #1
0
 static void CreateAnonymousActorFactory()
 {
     _factory = ActorFactory.CreateAnonymousActorFactory(x =>
     {
         x.ConstructedBy(CreateAnonymousActor);
         x.UseSchedulerFactory(_schedulerFactory);
         x.UseFiberFactory(_fiberFactory);
     });
 }
예제 #2
0
        public static ActorFactory <TActor> Create <TWorkflow, TActor>(Func <Inbox, TActor> createInstance,
                                                                       Action <StateMachineConfigurator <TWorkflow, TActor> >
                                                                       configurationAction)
            where TActor : class, Actor
            where TWorkflow : class
        {
            StateMachineWorkflow <TWorkflow, TActor> workflow = StateMachineWorkflow.New(configurationAction);

            var workflowBinder = new StateMachineWorkflowBinder <TWorkflow, TActor>(workflow);

            ActorFactory <TActor> factory = ActorFactory.Create <TActor>(x =>
            {
                x.ConstructedBy(inbox =>
                {
                    TActor instance = createInstance(inbox);

                    workflowBinder.Bind(inbox, instance);

                    return(instance);
                });
            });

            return(factory);
        }