예제 #1
0
        /// <summary>
        /// Registers an <see cref="IAction{TState,TInput}"/> or <see cref="IPrecondition{TState,TInput}"/>.
        /// </summary>
        /// <param name="registrar"></param>
        /// <param name="connectorType">
        /// The unbound generic type of the connector aka generic type definition. e.g.
        /// <c>typeof(LoggingAction&lt;,&gt;)</c>
        /// </param>
        /// <param name="registrationName">
        /// The name to register the type as in the <see cref="IComponentContainer"/>.
        /// <para />
        /// Multiple registrations with the same name will override each other.
        /// <para />
        /// The default is the assembly qualified name of the type.
        /// </param>
        /// <returns>A <see cref="IConnectorRegistration"/> that allows the caller to
        /// register an <see cref="IConnectorConfiguration"/> that includes an Identifier
        /// that can be resolved using a <see cref="Schematics.ConnectorKey"/> in a <see cref="Schematics.ISchematic{TState,TInput}"/>.
        /// </returns>
        /// <remarks>
        /// Connectors are available for use by a <see cref="IStateMachine{TState,TInput}"/> when a <see cref="Schematics.ConnectorKey"/>
        /// in it's <see cref="Schematics.ISchematic{TState,TInput}"/> matches a <see cref="IConnectorConfiguration"/>,
        /// that has been registered in a <see cref="IConnectorRegistration"/>'s <c>WithConfiguration</c> method.
        /// </remarks>
        public static IConnectorRegistration RegisterConnector(this IRegistrar registrar, Type connectorType, string registrationName = null)
        {
            var registrationKey = registrationName ?? connectorType.FullName;

            var interfaces = connectorType
                             .GetInterfaces()
                             .Where(type => type.IsConstructedGenericType)
                             .Select(type => type.GetGenericTypeDefinition())
                             .ToList();

            var registered = false;

            if (interfaces.Any(type => type == typeof(IAction <,>)))
            {
                registrar.Register(typeof(IAction <,>), connectorType, registrationKey);

                registered = true;
            }

            if (interfaces.Any(type => type == typeof(IPrecondition <,>)))
            {
                registrar.Register(typeof(IPrecondition <,>), connectorType, registrationKey);

                registered = true;
            }

            if (!registered)
            {
                throw new ArgumentException(
                          message: "Type must be either IAction<,> or IPrecondition<,> to be registered.",
                          paramName: nameof(connectorType));
            }

            return(new ConnectorRegistration(registrar, connectorType));
        }
        private void RegisterXamarinDependencies(IRegistrar registrar)
        {
            registrar.Register <LocationService, ILocationService>();
            registrar.Register <PageService, IPageService>();


            // registrar.Register<GpsService, IGpsSensor>();
        }
예제 #3
0
            public IConnectorRegistration WithConfiguration <TConfiguration>(TConfiguration configuration)
                where TConfiguration : class, IConnectorConfiguration
            {
                _registrar.Register(configuration, configuration.Identifier);
                _registrar.Register(new ConnectorTypeToIdentifierMapping(ConnectorType, configuration.Identifier), configuration.Identifier);

                return(this);
            }
예제 #4
0
            public IConnectorRegistration WithConfiguration <TConfiguration>(TConfiguration configuration)
                where TConfiguration : class, IConnectorConfiguration
            {
                // Register the configuration object, using its identifier as the key.
                _registrar.Register(configuration, configuration.Identifier);

                // Create a mapping (used by resolvers to choose which connector to load),
                // and register it under the same Identifer.
                _registrar.Register(new ConnectorTypeToIdentifierMapping(ConnectorType, configuration.Identifier),
                                    configuration.Identifier);

                return(this);
            }
예제 #5
0
 public override void Start(IRegistrar registrar)
 {
     // pass 0 or 1 is bootstrap, pass 2 is for reals
     if (pass < 2)
     {
         Logger = new ConsoleLogger(consoleLoggerPluginConfiguration.Name, consoleLoggerPluginConfiguration);
         registrar.Register(consoleLoggerPluginConfiguration.Name, consoleLoggerPluginConfiguration.IsDefaultLogger, this);
     }
     else if (pass == 2 && registrar.World != null)
     {
         Logger = registrar.World.ActorFor <ILogger>(Definition.Has <ConsoleLoggerActor>(Definition.Parameters(Logger), Logger));
         registrar.Register(consoleLoggerPluginConfiguration.Name, consoleLoggerPluginConfiguration.IsDefaultLogger, this);
     }
 }
예제 #6
0
        /// <summary>
        /// Registers dependencies in the component.
        /// </summary>
        /// <param name="registrar">The registration system to register with, typically a DI container.</param>
        public void Register(IRegistrar registrar)
        {
            registrar.Register(_options);

            registrar.Register(typeof(IStateMachineServiceClient), typeof(StateMachineServiceClient));

            registrar.Register(container => container.Resolve <IStateMachineServiceClient>().Create());

            registrar.Register(typeof(IRemoteStateEngine <,>), typeof(GrpcStateEngine <,>));

            if (_options.UseAsDefaultEngine)
            {
                registrar.Register(typeof(IStateEngine <,>), typeof(GrpcStateEngine <,>));
            }
        }
예제 #7
0
        /**
         * Verify the correct getLocale() behavior for the given service.
         * @param requestedLocale the locale to request.  This MUST BE
         * FAKE.  In other words, it should be something like
         * en_US_FAKEVARIANT so this method can verify correct fallback
         * behavior.
         * @param svc a factory object that can create the object to be
         * tested.
         * @param sub an object that can be used to retrieve a subobject
         * which should also be tested.  May be null.
         * @param reg an object that supplies the registration and
         * unregistration functionality to be tested.  May be null.
         */
        internal void CheckService(String requestedLocale, IServiceFacade svc,
                                   ISubobject sub, IRegistrar reg)
        {
            UCultureInfo req = new UCultureInfo(requestedLocale);
            Object       obj = svc.Create(req);

            CheckObject(requestedLocale, obj, "gt", "ge");
            if (sub != null)
            {
                Object subobj = sub.Get(obj);
                CheckObject(requestedLocale, subobj, "gt", "ge");
            }
            if (reg != null)
            {
                Logln("Info: Registering service");
                Object key    = reg.Register(req, obj);
                Object objReg = svc.Create(req);
                CheckObject(requestedLocale, objReg, "eq", "eq");
                if (sub != null)
                {
                    Object subobj = sub.Get(obj);
                    // Assume subobjects don't come from services, so
                    // their metadata should be structured normally.
                    CheckObject(requestedLocale, subobj, "gt", "ge");
                }
                Logln("Info: Unregistering service");
                if (!reg.Unregister(key))
                {
                    Errln("FAIL: unregister failed");
                }
                Object objUnreg = svc.Create(req);
                CheckObject(requestedLocale, objUnreg, "gt", "ge");
            }
        }
예제 #8
0
        public void Start()
        {
            Response <Guid> registrationResponse;

            try
            {
                registrationResponse = _registrar.Register(new RegisterWorkerRequest()
                {
                    IPAddress = LocalIPAddress, Name = Dns.GetHostName()
                });
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                throw new ApplicationException("Application unable to start. Worker registration failed. Check logs for additional data", ex);
            }
            if (registrationResponse.Succeeded)
            {
                _token = registrationResponse.Payload;
                _listener.Start();
            }
            else
            {
                throw new ApplicationException("Application unable to start. Check logs for additional data");
            }
        }
예제 #9
0
        public void Register(IRegistrar registrar)
        {
            var builder = new GrammarBuilder<DirectionsArgs>();
            builder.AddArgument(a => a.Source, "starting at", "from");
            builder.AddArgument(a => a.Destination, "ending at", "to");
            _grammar = builder.Grammar;

            registrar.Register<DirectionsArgs>("directions", _grammar, GetDirections);
        }
예제 #10
0
        public void Register(IRegistrar registrar)
        {
            var builder = new GrammarBuilder <DirectionsArgs>();

            builder.AddArgument(a => a.Source, "starting at", "from");
            builder.AddArgument(a => a.Destination, "ending at", "to");
            _grammar = builder.Grammar;

            registrar.Register <DirectionsArgs>("directions", _grammar, GetDirections);
        }
예제 #11
0
 public void Register(IRegistrar registrar)
 {
     registrar.Register("simple", Grammar.EmptyGrammar, DoThing);
 }
예제 #12
0
 /// <summary>
 ///    Initializes a new instance of the <see cref="DataModule"/> class.
 /// </summary>
 /// <param name="registrar">The service registrar. Must not be <see langword="null" />.</param>
 public DataModule(IRegistrar registrar)
     : base(registrar)
 {
     registrar.Register<IConnection, Connection>();
 }
예제 #13
0
 public static void RegisterEventListener(this IRegistrar registrar, IEventListener listener)
 {
     registrar.Register(listener, listener.GetType().FullName);
 }
 /// <summary>
 /// Registers the dependencies of this component and actives necessary configuration
 /// </summary>
 /// <param name="registrar">The registrar to which the configuration and dependencies should be added</param>
 public void Register(IRegistrar registrar)
 {
     registrar.Register(new REstateRedisDatabase(_restateDatabase));
     registrar.Register(typeof(IRepositoryContextFactory <,>), typeof(RedisRepositoryContextFactory <,>));
 }
예제 #15
0
 public void Start(IRegistrar registrar)
 {
     completesEventuallyProvider = new MockCompletesEventuallyProvider(completesResults);
     registrar.Register("mock-completes-eventually", completesEventuallyProvider);
 }
 /// <summary>
 /// Registers the dependencies of this component and actives necessary configuration
 /// </summary>
 /// <param name="registrar">The registrar to which the configuration and dependencies should be added</param>
 public void Register(IRegistrar registrar)
 {
     registrar.Register(new REstateDbContextFactory(_dbContextOptions));
     registrar.Register(typeof(IRepositoryContextFactory <,>), typeof(RepositoryFactory <,>));
 }
 public static void RegisterEventListener(this IRegistrar registrar, IEventListener listener)
 {
     registrar.Register(listener, listener.GetType().AssemblyQualifiedName);
 }
 public override void Start(IRegistrar registrar)
 {
     registrar.Register(_configuration.Name, _configuration.IsDefaultMailbox, this);
 }
 public void Register(IRegistrar registrar)
 {
     registrar.Register("simple", Grammar.EmptyGrammar, DoThing);
 }
예제 #20
0
 /// <summary>
 /// Registers the dependencies of this component and actives necessary configuration
 /// </summary>
 /// <param name="registrar">The registrar to which the configuration and dependencies should be added</param>
 public void Register(IRegistrar registrar)
 {
     registrar.Register(_options);
     registrar.Register(typeof(IRepositoryContextFactory <,>), typeof(EntityFrameworkCoreRepositoryContextFactory <,>));
 }
 public override void Start(IRegistrar registrar)
 {
     completesEventuallyProvider = new CompletesEventuallyPool(pooledCompletesPluginConfiguration.PoolSize, pooledCompletesPluginConfiguration.Mailbox !);
     registrar.Register(pooledCompletesPluginConfiguration.Name, completesEventuallyProvider !);
 }
예제 #22
0
 public void RegisterAll()
 {
     _registrar.Register(SomeQuery.CreateInstance);
     _registrar.Register(AnotherQuery.CreateInstance);
 }
예제 #23
0
 public void Register(IRegistrar registrar)
 {
     registrar.Register(typeof(IRepositoryContextFactory <,>), typeof(InMemoryRepositoryContextFactory <,>));
 }
예제 #24
0
 public override void Start(IRegistrar registrar) => registrar.Register(Name, false, this);
예제 #25
0
 /// <summary>
 /// Registers a factory method for <typeparamref name="TService"/>
 /// </summary>
 public void Register <TService>(Func <ResolutionContext, TService> serviceFactory)
 {
     Registrar.Register(serviceFactory);
 }
예제 #26
0
 protected override void RegisterPlatformDependencies(IRegistrar registrar)
 {
     registrar.Register <IosGpsSensorService, IGpsSensorService>();
 }
 public override void Start(IRegistrar registrar)
 {
     executorDispatcher = new ExecutorDispatcher(System.Environment.ProcessorCount, configuration.NumberOfDispatchersFactor);
     registrar.Register(configuration.Name, configuration.IsDefaultMailbox, this);
 }