示例#1
0
        private static TActor CreateActor <TActor>(
            ActorService service,
            ActorId id)
            where TActor : Actor
        {
            TActor actor;
            IServiceEventSource eventSource = null;

            try
            {
                var actorContainer = GetActorContainer(service, id);

                eventSource = actorContainer.GetInstance <IServiceEventSource>();
                eventSource.ServiceTypeRegistered(Process.GetCurrentProcess().Id, Naming.GetServiceName <TActor>());

                actor = actorContainer.GetInstance <TActor>();

                var stateManager = (LazyActorStateManager)actorContainer.GetInstance <IActorStateManager>();
                stateManager.SetActorStateManager(actor.StateManager);
            }
            catch (Exception e)
            {
                eventSource?.ServiceHostInitializationFailed(e.ToString());
                throw;
            }

            return(actor);
        }
 private void BuildContainer <T>(ContainerBuilder builder)
 {
     using (var container = builder.Build())
     {
         _eventSource?.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(T).Name);
         Thread.Sleep(Timeout.Infinite);
     }
 }
示例#3
0
        private static TService CreateService <TService>(StatefulServiceContext context) where TService : StatefulService
        {
            TService            service;
            IServiceEventSource eventSource = null;

            try
            {
                var container = GetContainer(context);

                eventSource = container.GetInstance <IServiceEventSource>();
                eventSource.ServiceTypeRegistered(Process.GetCurrentProcess().Id, Naming.GetServiceName <TService>());
                service = container.GetInstance <TService>();
            }
            catch (Exception e)
            {
                eventSource?.ServiceHostInitializationFailed(e.ToString());
                throw;
            }

            return(service);
        }