public bool IsRegisteredWithKey(string serviceKey, Type serviceType) { if (!string.IsNullOrEmpty(serviceKey)) { return(_container.IsRegisteredWithKey(serviceKey, serviceType)); } else { return(_container.IsRegistered(serviceType)); } }
public async Task DispatchAsync(Command command) { try { if (command.CommandName == "help" && command.Arguments.Count == 1) { await HandleHelpCommand(command); return; } var isCommandRegistered = _component.IsRegisteredWithKey <ICommandHandler>(command.CommandName); if (!isCommandRegistered) { await _component.ResolveKeyed <ICommandHandler>("command-not-found") .HandleAsync(command); return; } var commandHandler = _component.ResolveKeyed <ICommandHandler>(command.CommandName); if (command.Arguments.Count != commandHandler.GetAttributeCommandArgsCount()) { await DisplayValidationResult(command.CalledFromChannel); } else { var validationResult = await commandHandler.ValidateCommandAsync(command); if (!validationResult.IsValid) { await DisplayValidationResult(command.CalledFromChannel, validationResult.ErrorMessage); } else { await commandHandler.HandleAsync(command); } } } catch (Exception ex) { _logger.LogError("Error during processing command: {0} \n {1}", ex.Message, ex.StackTrace); await _component.ResolveKeyed <ICommandHandler>("internal-application-error") .HandleAsync(command); } }
static void HandleWhen(IComponentContext scope, object when) { if (!scope.IsRegisteredWithKey <IHandle <object> >(when.GetType())) { NUnit.Framework.Assert.Fail( "It appears you forgot to register a handler for the {0} message.", when.GetType().Name); } scope.ResolveKeyed <IHandle <object> >(when.GetType()).Handle(when); }
/// <inheritdoc /> public override object Create(Type objectType) { if (objectType == null) { throw new ArgumentNullException(nameof(objectType)); } return(_container.IsRegisteredWithKey(ContainerBuilderExtensions.ConfigurationRegistrationKey, objectType) ? _container.ResolveKeyed(ContainerBuilderExtensions.ConfigurationRegistrationKey, objectType) : _container.Resolve(objectType)); }
public static object ResolveConfigurationType([NotNull] this IComponentContext container, [NotNull] Type objectType) { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (objectType == null) { throw new ArgumentNullException(nameof(objectType)); } return(container.IsRegisteredWithKey(ContainerBuilderExtensions.ConfigurationRegistrationKey, objectType) ? container.ResolveKeyed(ContainerBuilderExtensions.ConfigurationRegistrationKey, objectType) : container.Resolve(objectType)); }
static void HandleWhen(IComponentContext scope, object when) { if (!scope.IsRegisteredWithKey<IHandle<object>>(when.GetType())) NUnit.Framework.Assert.Fail( "It appears you forgot to register a handler for the {0} message.", when.GetType().Name); scope.ResolveKeyed<IHandle<object>>(when.GetType()).Handle(when); }
public bool IsRegistered <T>(object serviceKey) { return(_container.IsRegisteredWithKey <T>(serviceKey)); }
public bool ContainsKey(TKey key) => _context.IsRegisteredWithKey <TValue>(key);
public static bool IsRegisteredWithName(this IComponentContext context, string serviceName, Type serviceType) { return(context.IsRegisteredWithKey(serviceName, serviceType)); }
public static bool IsRegisteredWithName <TService>(this IComponentContext context, string serviceName) { return(context.IsRegisteredWithKey <TService>(serviceName)); }
public static bool IsRegisteredWithKey <TService>(this IComponentContext context, object serviceKey) { return(context.IsRegisteredWithKey(serviceKey, typeof(TService))); }
private bool ExistsKeyService(TKey key) { return(_componentContext.IsRegisteredWithKey <T>(key)); }