コード例 #1
0
        /// <summary>
        /// Создает экземпляр класса <see cref="INamedResolver{TDiscriminator, TInterface}"/>.
        /// </summary>
        /// <param name="serviceProvider">Провайдер служб.</param>
        /// <param name="namedRegistrator">Регистратор именованных типов.</param>
        public NamedResolver(IServiceProvider serviceProvider, INamedRegistrator <TDiscriminator, TInterface> namedRegistrator)
        {
            _serviceProvider = serviceProvider;
            var registeredTypesAccessor = (IHasRegisteredTypeInfos <TDiscriminator, TInterface>)namedRegistrator;

            _registeredDescriptors = registeredTypesAccessor.RegisteredTypes;
            _defaultDescriptor     = registeredTypesAccessor.DefaultDescriptor;
            _equalityComparer      = registeredTypesAccessor.EqualityComparer;
        }
コード例 #2
0
 /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>
 /// <see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <see langword="false" />.</returns>
 public bool Equals(NamedDescriptor <TDiscriminator, TInterface> other)
 {
     return((_equalityComparer ?? EqualityComparer <TDiscriminator?> .Default).Equals(Discriminator, other.Discriminator));
 }