Example #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);
        }
 public virtual void Run <T>(string serviceTypeName, IServiceEventSource serviceEventSourceBase)
 {
     _eventSource = serviceEventSourceBase;
     //ILogger logger = null;
     try
     {
         //logger = LoggerFactoryCreator.GetLoggerFactory().Create($"Initialization.{typeof(T).Name}");
         RunSpecific(serviceTypeName);
     }
     catch (Exception ex)
     {
         serviceEventSourceBase.ServiceHostInitializationFailed(ex.ToString());
         //logger?.Error("Failed to initialize service", e);
         throw;
     }
 }
Example #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);
        }