/// <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<,>)</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>(); }
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); }
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); }
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); } }
/// <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 <,>)); } }
/** * 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"); } }
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"); } }
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); }
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); }
public void Register(IRegistrar registrar) { registrar.Register("simple", Grammar.EmptyGrammar, DoThing); }
/// <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>(); }
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 <,>)); }
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); }
/// <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 !); }
public void RegisterAll() { _registrar.Register(SomeQuery.CreateInstance); _registrar.Register(AnotherQuery.CreateInstance); }
public void Register(IRegistrar registrar) { registrar.Register(typeof(IRepositoryContextFactory <,>), typeof(InMemoryRepositoryContextFactory <,>)); }
public override void Start(IRegistrar registrar) => registrar.Register(Name, false, this);
/// <summary> /// Registers a factory method for <typeparamref name="TService"/> /// </summary> public void Register <TService>(Func <ResolutionContext, TService> serviceFactory) { Registrar.Register(serviceFactory); }
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); }