System.Runtime.Serialization.SchemaHelper.GetSchemaElement C# (CSharp) Method

GetSchemaElement() static private method

static private GetSchemaElement ( SchemaObjectDictionary schemaInfo, XmlQualifiedName elementName ) : XmlSchemaElement
schemaInfo SchemaObjectDictionary
elementName System.Xml.XmlQualifiedName
return System.Xml.Schema.XmlSchemaElement
        internal static XmlSchemaElement GetSchemaElement(SchemaObjectDictionary schemaInfo, XmlQualifiedName elementName)
        {
            SchemaObjectInfo schemaObjectInfo;
            if (schemaInfo.TryGetValue(elementName, out schemaObjectInfo))
            {
                return schemaObjectInfo.element;
            }
            return null;
        }

Same methods

SchemaHelper::GetSchemaElement ( XmlSchemaSet schemas, XmlQualifiedName elementQName, XmlSchema &outSchema ) : XmlSchemaElement

Usage Example

コード例 #1
0
ファイル: SchemaExporter.cs プロジェクト: rsumner31/corefx2
        private void ExportXmlDataContract(XmlDataContract dataContract)
        {
            XmlQualifiedName typeQName;
            bool             hasRoot;
            XmlSchemaType    xsdType;

            Type clrType = dataContract.UnderlyingType;

            if (!IsSpecialXmlType(clrType, out typeQName, out xsdType, out hasRoot))
            {
                if (!InvokeSchemaProviderMethod(clrType, _schemas, out typeQName, out xsdType, out hasRoot))
                {
                    InvokeGetSchemaMethod(clrType, _schemas, typeQName);
                }
            }

            if (hasRoot)
            {
                if (!(typeQName.Equals(dataContract.StableName)))
                {
                    Fx.Assert("XML data contract type name does not match schema name");
                }

                XmlSchema schema;
                if (SchemaHelper.GetSchemaElement(Schemas,
                                                  new XmlQualifiedName(dataContract.TopLevelElementName.Value, dataContract.TopLevelElementNamespace.Value),
                                                  out schema) == null)
                {
                    XmlSchemaElement topLevelElement = ExportTopLevelElement(dataContract, schema);
                    topLevelElement.IsNillable = dataContract.IsTopLevelElementNullable;
                    ReprocessAll(_schemas);
                }

                XmlSchemaType anonymousType = xsdType;
                xsdType = SchemaHelper.GetSchemaType(_schemas, typeQName, out schema);
                if (anonymousType == null && xsdType == null && typeQName.Namespace != XmlSchema.Namespace)
                {
                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.MissingSchemaType, typeQName, DataContract.GetClrTypeFullName(clrType))));
                }
                if (xsdType != null)
                {
                    xsdType.Annotation = GetSchemaAnnotation(
                        ExportSurrogateData(dataContract),
                        dataContract.IsValueType ?
                        GetAnnotationMarkup(IsValueTypeName, XmlConvert.ToString(dataContract.IsValueType), schema) :
                        null
                        );
                }
            }
        }