RegisterActor <TActor>(
            this ContainerBuilder builder,
            Func <ActorBase, IActorStateProvider, IActorStateManager> stateManagerFactory = null,
            IActorStateProvider stateProvider = null,
            ActorServiceSettings settings     = null)
            where TActor : ActorBase
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var actorType = typeof(TActor);

            if (!actorType.CanBeProxied())
            {
                throw new ArgumentException(actorType.GetInvalidProxyTypeErrorMessage());
            }

            var registration = builder.RegisterServiceWithInterception <TActor, ActorInterceptor>();

            registration.EnsureRegistrationIsInstancePerLifetimeScope();

            var creator = new ServiceFabricRegistrationCreator(c => c.Resolve <IActorFactoryRegistration>().RegisterActorFactory <TActor>(
                                                                   c, stateManagerFactory, stateProvider, settings));

            builder.RegisterInstance(creator)
            .As <IServiceFabricRegistrationCreator>();

            // builder.RegisterBuildCallback(
            //    c => c.Resolve<IActorFactoryRegistration>().RegisterActorFactory<TActor>(
            //        c, stateManagerFactory, stateProvider, settings));
            return(registration);
        }
Ejemplo n.º 2
0
        RegisterStatelessService <TService>(
            this ContainerBuilder builder,
            string serviceTypeName)
            where TService : StatelessService
        {
            var registration = RegisterServiceWithContainer <TService>(builder, serviceTypeName);

            var creator = new ServiceFabricRegistrationCreator(c =>
                                                               c.Resolve <IStatelessServiceFactoryRegistration>()
                                                               .RegisterStatelessServiceFactory <TService>(c, serviceTypeName));

            builder.RegisterInstance(creator)
            .As <IServiceFabricRegistrationCreator>();

            // builder.RegisterBuildCallback(c =>
            //    c.Resolve<IStatelessServiceFactoryRegistration>()
            //        .RegisterStatelessServiceFactory<TService>(c, serviceTypeName));
            return(registration);
        }