/// <summary> /// Creates new instance of <see cref="ComponentFactoryNotFoundException" /> class for specified <paramref name="componentId"/>. /// </summary> /// <param name="componentId">Id of component for which factory was not found.</param> /// <param name="componentFactories">Collection of all available factories.</param> public ComponentFactoryNotFoundException(ComponentId componentId, IReadOnlyCollection<IComponentFactory> componentFactories) : base( GetMessage(componentId, Sorted(componentFactories))) { ComponentType = null; ComponentId = componentId; ComponentFactories = Sorted(componentFactories); }
public IComponentFactory Get(ComponentId componentId) { if (_factoriesById.TryGetValue(componentId, out var factory)) { return factory; } throw new ComponentFactoryNotFoundException(componentId, _factoriesById.Values); }
/// <summary> /// Initializes new instance of <see cref="ComponentIdAttribute" />. /// </summary> /// <param name="componentId"><see cref="string" /> representing <see cref="ComponentId" />.</param> public ComponentIdAttribute(string componentId) { ComponentId = new ComponentId(componentId); }
/// <summary> /// Initializes new instance of <see cref="Component" /> class. /// </summary> protected Component() { ComponentId = ComponentId.Of(GetType()); }
private static string GetMessage(ComponentId componentId, IEnumerable<IComponentFactory> factories) { return GetMessage($"No implementation of {nameof(IComponentFactory)} for component id \"{componentId}\" was found.", factories); }