Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ InvokeSchemaProviderMethod()

static bool System.Runtime.Serialization.SchemaExporter.InvokeSchemaProviderMethod ( Type clrType,
XmlSchemaSet schemas,
out XmlQualifiedName stableName,
out XmlSchemaType xsdType,
out bool hasRoot )
inlinestaticprivate

Definition at line 780 of file SchemaExporter.cs.

781 {
782 xsdType = null;
783 hasRoot = true;
784 object[] customAttributes = clrType.GetCustomAttributes(Globals.TypeOfXmlSchemaProviderAttribute, inherit: false);
785 if (customAttributes == null || customAttributes.Length == 0)
786 {
787 stableName = DataContract.GetDefaultStableName(clrType);
788 return false;
789 }
792 {
794 hasRoot = false;
795 }
796 string methodName = xmlSchemaProviderAttribute.MethodName;
797 if (methodName == null || methodName.Length == 0)
798 {
800 {
801 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(System.SR.Format(System.SR.InvalidGetSchemaMethod, DataContract.GetClrTypeFullName(clrType))));
802 }
803 stableName = DataContract.GetDefaultStableName(clrType);
804 }
805 else
806 {
807 MethodInfo method = clrType.GetMethod(methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, new Type[1] { typeof(XmlSchemaSet) });
808 if (method == null)
809 {
810 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(System.SR.Format(System.SR.MissingGetSchemaMethod, DataContract.GetClrTypeFullName(clrType), methodName)));
811 }
812 if (!Globals.TypeOfXmlQualifiedName.IsAssignableFrom(method.ReturnType) && !Globals.TypeOfXmlSchemaType.IsAssignableFrom(method.ReturnType))
813 {
814 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(System.SR.Format(System.SR.InvalidReturnTypeOnGetSchemaMethod, DataContract.GetClrTypeFullName(clrType), methodName, DataContract.GetClrTypeFullName(method.ReturnType), DataContract.GetClrTypeFullName(Globals.TypeOfXmlQualifiedName), typeof(XmlSchemaType))));
815 }
816 object obj = method.Invoke(null, new object[1] { schemas });
818 {
819 if (obj != null)
820 {
821 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(System.SR.Format(System.SR.InvalidNonNullReturnValueByIsAny, DataContract.GetClrTypeFullName(clrType), methodName)));
822 }
823 stableName = DataContract.GetDefaultStableName(clrType);
824 }
825 else if (obj == null)
826 {
828 hasRoot = false;
829 stableName = DataContract.GetDefaultStableName(clrType);
830 }
832 {
833 string localName = xmlSchemaType.Name;
834 string ns = null;
835 if (localName == null || localName.Length == 0)
836 {
837 DataContract.GetDefaultStableName(DataContract.GetClrTypeFullName(clrType), out localName, out ns);
838 stableName = new XmlQualifiedName(localName, ns);
841 }
842 else
843 {
844 foreach (XmlSchema item in schemas.Schemas())
845 {
846 foreach (XmlSchemaObject item2 in item.Items)
847 {
848 if (item2 == xmlSchemaType)
849 {
850 ns = item.TargetNamespace;
851 if (ns == null)
852 {
853 ns = string.Empty;
854 }
855 break;
856 }
857 }
858 if (ns != null)
859 {
860 break;
861 }
862 }
863 if (ns == null)
864 {
865 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(System.SR.Format(System.SR.MissingSchemaType, localName, DataContract.GetClrTypeFullName(clrType))));
866 }
867 stableName = new XmlQualifiedName(localName, ns);
868 }
869 }
870 else
871 {
873 }
874 }
875 return true;
876 }
static XmlSchemaComplexType CreateAnyElementType()
XmlElement ExportActualType(XmlQualifiedName typeName)
XmlSchemaAnnotation GetSchemaAnnotation(XmlQualifiedName annotationQualifiedName, string innerText, XmlSchema schema)
static string InvalidGetSchemaMethod
Definition SR.cs:150
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string MissingSchemaType
Definition SR.cs:682
static string MissingGetSchemaMethod
Definition SR.cs:208
static string InvalidNonNullReturnValueByIsAny
Definition SR.cs:156
static string InvalidReturnTypeOnGetSchemaMethod
Definition SR.cs:160
Definition SR.cs:7

References System.Runtime.Serialization.SchemaExporter.CreateAnyElementType(), System.Runtime.Serialization.Dictionary, System.Runtime.Serialization.SchemaExporter.ExportActualType(), System.SR.Format(), System.Runtime.Serialization.DataContract.GetClrTypeFullName(), System.Runtime.Serialization.DataContract.GetDefaultStableName(), System.Runtime.Serialization.SchemaExporter.GetSchemaAnnotation(), System.SR.InvalidGetSchemaMethod, System.SR.InvalidNonNullReturnValueByIsAny, System.SR.InvalidReturnTypeOnGetSchemaMethod, System.item, System.SR.MissingGetSchemaMethod, System.SR.MissingSchemaType, System.obj, System.Xml.Schema.XmlSchemaSet.Schemas(), System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(), System.Runtime.Serialization.Globals.TypeOfXmlQualifiedName, System.Runtime.Serialization.Globals.TypeOfXmlSchemaProviderAttribute, and System.Runtime.Serialization.Globals.TypeOfXmlSchemaType.

Referenced by System.Runtime.Serialization.SchemaExporter.ExportXmlDataContract(), and System.Runtime.Serialization.SchemaExporter.GetXmlTypeInfo().