コード例 #1
0
 /// <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);
 }
コード例 #2
0
        public IComponentFactory Get(ComponentId componentId)
        {
            if (_factoriesById.TryGetValue(componentId, out var factory))
            {
                return factory;
            }

            throw new ComponentFactoryNotFoundException(componentId, _factoriesById.Values);
        }
コード例 #3
0
 /// <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);
 }
コード例 #4
0
 /// <summary>
 ///     Initializes new instance of <see cref="Component" /> class.
 /// </summary>
 protected Component()
 {
     ComponentId = ComponentId.Of(GetType());
 }
コード例 #5
0
 private static string GetMessage(ComponentId componentId, IEnumerable<IComponentFactory> factories)
 {
     return GetMessage($"No implementation of {nameof(IComponentFactory)} for component id \"{componentId}\" was found.", factories);
 }