Esempio n. 1
0
        MemberInfo IProviderInfoDescription.GetProviderMember(Type providerType, object criteria)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }
            if (criteria == null)
            {
                throw new ArgumentNullException("criteria");
            }

            string s = criteria as string;

            if (s != null)
            {
                return(((IProviderInfoDescription)this).GetProviderMember(providerType, s));
            }

            QualifiedName t = criteria as QualifiedName;

            if (t != null)
            {
                return(((IProviderInfoDescription)this).GetProviderMember(providerType, t));
            }

            return(ProviderData.GetProvidersUsingCriteria(providerType, criteria, u => u.Member)
                   .SingleOrThrow(RuntimeFailure.MultipleProviders));
        }
Esempio n. 2
0
        object IProviderInfoDescription.GetProvider(Type providerType, object criteria)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }
            if (criteria == null)
            {
                throw new ArgumentNullException("criteria");
            }

            string s = criteria as string;

            if (s != null)
            {
                return(((IProviderInfoDescription)this).GetProvider(providerType, s));
            }

            QualifiedName t = criteria as QualifiedName;

            if (t != null)
            {
                return(((IProviderInfoDescription)this).GetProvider(providerType, t));
            }

            return(ProviderData.GetProvidersUsingCriteria(providerType, criteria, u => u.GetValue()).FirstOrDefault());
        }
Esempio n. 3
0
        object IProviderInfoDescription.GetProvider(Type providerType, QualifiedName name)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }

            return(ProviderData.GetProvider(providerType, name, t => t.GetValue()));
        }
Esempio n. 4
0
        ProviderInfo IProviderInfoDescription.GetProviderInfo(Type type, QualifiedName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            return(ProviderData.GetProvider(type, name, t => t));
        }
Esempio n. 5
0
        IEnumerable <object> IProviderInfoDescription.GetProviders(Type providerType, object criteria)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }

            return(ProviderData.GetProvidersUsingCriteria(providerType, criteria, t => t.GetValue()));
        }
Esempio n. 6
0
        IEnumerable <QualifiedName> IProviderInfoDescription.GetProviderNames(Type providerType)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }

            return(ProviderData.GetProviderNames(providerType));
        }
Esempio n. 7
0
        object IProviderInfoDescription.GetProvider(Type providerType, string name)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }

            return(ProviderData.GetProvidersByLocalName(providerType, name, t => t.GetValue()).SingleOrThrow(RuntimeFailure.MultipleProviders));
        }
Esempio n. 8
0
        IEnumerable <object> IProviderInfoDescription.GetProviders(Type providerType)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }

            return(ProviderData.GetProviders(providerType));
        }
Esempio n. 9
0
        ProviderInfo IProviderInfoDescription.GetProviderInfo(Type type, string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw Failure.NullOrEmptyString(nameof(name));
            }

            return(ProviderData.GetProvidersByLocalName(
                       type, name, t => t).SingleOrThrow(RuntimeFailure.MultipleProviders));
        }
Esempio n. 10
0
        ProviderInfo IProviderInfoDescription.GetProviderInfo(Type type, object criteria)
        {
            if (criteria == null)
            {
                throw new ArgumentNullException("criteria");
            }

            var them = ProviderData.GetProvidersUsingCriteria(
                type, criteria, t => t).ToList();

            return(them.SingleOrThrow(RuntimeFailure.MultipleProviders));
        }
Esempio n. 11
0
        public static T FromProvider <T>(string name,
                                         IEnumerable <KeyValuePair <string, object> > values = null,
                                         IServiceProvider serviceProvider = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw Failure.NullOrEmptyString(nameof(name));
            }

            return((T)ProviderData.GetProvidersByLocalName(typeof(T), name,
                                                           t => t.Activate(values, serviceProvider))
                   .SingleOrThrow(RuntimeFailure.MultipleProviders));
        }
Esempio n. 12
0
        QualifiedName IProviderInfoDescription.GetProviderName(Type providerType, object instance)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            return(ProviderData.GetProviderMetadata(providerType,
                                                    t => t.PreciseMatch(instance),
                                                    t => t.Name));
        }
Esempio n. 13
0
        IEnumerable <QualifiedName> IProviderInfoDescription.GetProviderNames(Type providerType, object instance)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            return(ProviderData.GetProviderMetadataMany(providerType,
                                                        t => t.PreciseMatch(instance),
                                                        t => t.Names)
                   .SelectMany(t => t));
        }
Esempio n. 14
0
 IEnumerable <ProviderInfo> IProviderInfoDescription.GetProviderInfos(Type providerType)
 {
     return(ProviderData.GetProviders(providerType, t => t));
 }
Esempio n. 15
0
 IEnumerable <T> IProviderInfoDescription.GetProviders <T>()
 {
     return(ProviderData.GetProviders(typeof(T)).Cast <T>());
 }
Esempio n. 16
0
 IEnumerable <Type> IProviderInfoDescription.GetProviderTypes()
 {
     return(ProviderData.GetAllProviderRootTypes());
 }
Esempio n. 17
0
 IEnumerable <Type> IProviderInfoDescription.GetProviderTypes(Type providerType)
 {
     return(ProviderData.GetProviderTypes(providerType));
 }
Esempio n. 18
0
 T IProviderInfoDescription.GetProvider <T>(string name)
 {
     return((T)ProviderData.GetProvidersByLocalName(
                typeof(T), name, t => t.GetValue()).SingleOrThrow(RuntimeFailure.MultipleProviders));
 }
Esempio n. 19
0
 Type IProviderInfoDescription.GetProviderType(Type providerType, string name)
 {
     return(ProviderData.GetProvidersByLocalName(providerType, name, t => t.ValueType).SingleOrThrow(RuntimeFailure.MultipleProviders));
 }
Esempio n. 20
0
 Type IProviderInfoDescription.GetProviderType(Type providerType, QualifiedName name)
 {
     return(ProviderData.GetProviderType(providerType, name));
 }
Esempio n. 21
0
 T IProviderInfoDescription.GetProvider <T>(QualifiedName name)
 {
     return((T)ProviderData.GetProvider(typeof(T), name, t => t.GetValue()));
 }
Esempio n. 22
0
 T IProviderInfoDescription.GetProvider <T>(object criteria)
 {
     return((T)ProviderData.GetProvidersUsingCriteria(typeof(T), criteria, t => t.GetValue()).FirstOrDefault());
 }
Esempio n. 23
0
 MemberInfo IProviderInfoDescription.GetProviderMember(Type providerType, QualifiedName name)
 {
     return(ProviderData.GetProvider(providerType, name, t => t.Member));
 }