當前位置: 首頁>>代碼示例>>C#>>正文


C# SchemaAttDef.CheckDefaultValue方法代碼示例

本文整理匯總了C#中System.Xml.Schema.SchemaAttDef.CheckDefaultValue方法的典型用法代碼示例。如果您正苦於以下問題:C# SchemaAttDef.CheckDefaultValue方法的具體用法?C# SchemaAttDef.CheckDefaultValue怎麽用?C# SchemaAttDef.CheckDefaultValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Schema.SchemaAttDef的用法示例。


在下文中一共展示了SchemaAttDef.CheckDefaultValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddDefaultAttribute

        internal bool AddDefaultAttribute( SchemaAttDef attrDef, bool definedInDtd ) {
            string localName = attrDef.Name.Name;
            string prefix = attrDef.Prefix;
            string ns = attrDef.Name.Namespace;

            // DTD default attribute
            if ( definedInDtd ) {
                if ( prefix.Length > 0 ) {
                    attrNeedNamespaceLookup = true;
                }
            }
            // XSD/XDR default attribute
            else {
                // atomize namesspace - Xsd Validator does not need to have the same nametable
                ns = nameTable.Add( ns );
                if ( prefix.Length == 0 && ns.Length > 0 ) {
                    prefix = namespaceManager.LookupPrefix( ns );

                    Debug.Assert( prefix != null );
                    if ( prefix == null ) {
                        prefix = string.Empty;
                    }
                }
            }

            // atomize names - Xsd Validator does not need to have the same nametable
            localName = nameTable.Add( localName );
            prefix = nameTable.Add( prefix );

            // check for duplicates
            for ( int i = index + 1; i < index + 1 + attrCount; i++ ) {
                if ( (object)nodes[i].localName == (object)localName && 
                     ( ( (object)nodes[i].prefix == (object)prefix ) || ( (object)nodes[i].ns == (object)ns  &&  ns != null ) ) ) {
                    return false;
                }
            }

            // check the default attribute value if it has a valid value according to its type
            if ( definedInDtd && DtdValidation && !attrDef.DefaultValueChecked ) {
                attrDef.CheckDefaultValue( dtdParserProxy.DtdSchemaInfo, dtdParserProxy );
            }

            // setup the attribute 
            NodeData attr = AddAttribute( localName, prefix, prefix.Length > 0 ? null : localName );
            if ( !definedInDtd ) {
                Debug.Assert( ns != null );
                attr.ns = ns;
            }
            attr.SetValue( attrDef.DefaultValueExpanded );
            attr.IsDefaultAttribute = true;
            attr.schemaType = ( attrDef.SchemaType == null ) ? (object)attrDef.Datatype : (object)attrDef.SchemaType;
            attr.typedValue = attrDef.DefaultValueTyped;
            attr.lineInfo.Set( attrDef.LineNum, attrDef.LinePos );
            attr.lineInfo2.Set( attrDef.ValueLineNum, attrDef.ValueLinePos );

            // handle special attributes:
            if ( attr.prefix.Length == 0 ) {
                // default namespace declaration
                if ( Ref.Equal( attr.localName, XmlNs ) ) {
                    OnDefaultNamespaceDecl( attr );
                    if ( !definedInDtd ) {
                        // change element default namespace
                        Debug.Assert( nodes[index].type == XmlNodeType.Element );
                        if ( nodes[index].prefix.Length == 0 ) {
                            nodes[index].ns = xmlContext.defaultNamespace;
                        }
                    }
                }
            }
            else {
                // prefixed namespace declaration
                if ( Ref.Equal( attr.prefix, XmlNs ) ) {
                    OnNamespaceDecl( attr );
                    if ( !definedInDtd ) {
                        // change namespace of current element and attributes
                        string pref = attr.localName;
                        Debug.Assert( nodes[index].type == XmlNodeType.Element );
                        for ( int i = index; i < index + attrCount + 1; i++ ) {
                            if ( nodes[i].prefix.Equals( pref ) ) {
                                nodes[i].ns = namespaceManager.LookupNamespace( pref );
                            }
                        }
                    }
                }
                // xml: attribute
                else {
                    if ( attrDef.Reserved != SchemaAttDef.Reserve.None ) {
                        OnXmlReservedAttribute( attr );
                    }
                }
            }

            fullAttrCleanup = true;
            return true;
        }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:95,代碼來源:xmltextreaderimpl.cs


注:本文中的System.Xml.Schema.SchemaAttDef.CheckDefaultValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。