System.Xml.Serialization.XmlReflectionImporter.GetMethodFromSchemaProvider C# (CSharp) Method

GetMethodFromSchemaProvider() static private method

static private GetMethodFromSchemaProvider ( XmlSchemaProviderAttribute provider, Type type ) : MethodInfo
provider XmlSchemaProviderAttribute
type System.Type
return System.Reflection.MethodInfo
        internal static MethodInfo GetMethodFromSchemaProvider(XmlSchemaProviderAttribute provider, Type type)
        {
            if (provider.IsAny)
            {
                // do not validate the schema provider method for wildcard types.
                return null;
            }
            else if (provider.MethodName == null)
            {
                throw new ArgumentNullException(nameof(provider.MethodName));
            }
            if (!CodeGenerator.IsValidLanguageIndependentIdentifier(provider.MethodName))
                throw new ArgumentException(SR.Format(SR.XmlGetSchemaMethodName, provider.MethodName), nameof(provider.MethodName));

            MethodInfo getMethod = getMethod = type.GetMethod(provider.MethodName, /* BindingFlags.DeclaredOnly | */ BindingFlags.Static | BindingFlags.Public, new Type[] { typeof(XmlSchemaSet) });
            if (getMethod == null)
                throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaMethodMissing, provider.MethodName, typeof(XmlSchemaSet).Name, type.FullName));

            if (!(typeof(XmlQualifiedName).IsAssignableFrom(getMethod.ReturnType)) && !(typeof(XmlSchemaType).IsAssignableFrom(getMethod.ReturnType)))
                throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaMethodReturnType, type.Name, provider.MethodName, typeof(XmlSchemaProviderAttribute).Name, typeof(XmlQualifiedName).FullName, typeof(XmlSchemaType).FullName));

            return getMethod;
        }