System.Xml.Schema.XmlSchemaInfo.Clear C# (CSharp) Méthode

Clear() private méthode

private Clear ( ) : void
Résultat void
        internal void Clear() {
            isNil = false;
            isDefault = false;
            schemaType = null;
            schemaElement = null;
            schemaAttribute = null;
            memberType = null;
            validity = XmlSchemaValidity.NotKnown;
            contentType = XmlSchemaContentType.Empty;
        }
    }

Usage Example

        private object ValidateAttribute(string lName, string ns, XmlValueGetter attributeValueGetter, string attributeStringValue, XmlSchemaInfo schemaInfo)
        {
            if (lName == null)
            {
                throw new ArgumentNullException("localName");
            }
            if (ns == null)
            {
                throw new ArgumentNullException("namespaceUri");
            }
            ValidatorState toState = (this.validationStack.Length > 1) ? ValidatorState.Attribute : ValidatorState.TopLevelAttribute;
            this.CheckStateTransition(toState, MethodNames[(int) toState]);
            object typedValue = null;
            this.attrValid = true;
            XmlSchemaValidity notKnown = XmlSchemaValidity.NotKnown;
            XmlSchemaAttribute schemaAttribute = null;
            XmlSchemaSimpleType xmlType = null;
            ns = this.nameTable.Add(ns);
            if (Ref.Equal(ns, this.NsXmlNs))
            {
                return null;
            }
            SchemaAttDef def = null;
            SchemaElementDecl elementDecl = this.context.ElementDecl;
            XmlQualifiedName key = new XmlQualifiedName(lName, ns);
            if (this.attPresence[key] != null)
            {
                this.SendValidationEvent("Sch_DuplicateAttribute", key.ToString());
                if (schemaInfo != null)
                {
                    schemaInfo.Clear();
                }
                return null;
            }
            if (Ref.Equal(ns, this.NsXsi))
            {
                lName = this.nameTable.Add(lName);
                if ((Ref.Equal(lName, this.xsiTypeString) || Ref.Equal(lName, this.xsiNilString)) || (Ref.Equal(lName, this.xsiSchemaLocationString) || Ref.Equal(lName, this.xsiNoNamespaceSchemaLocationString)))
                {
                    this.attPresence.Add(key, SchemaAttDef.Empty);
                }
                else
                {
                    this.attrValid = false;
                    this.SendValidationEvent("Sch_NotXsiAttribute", key.ToString());
                }
            }
            else
            {
                AttributeMatchState state2;
                object obj4;
                XmlSchemaObject partialValidationType = (this.currentState == ValidatorState.TopLevelAttribute) ? this.partialValidationType : null;
                def = this.compiledSchemaInfo.GetAttributeXsd(elementDecl, key, partialValidationType, out state2);
                switch (state2)
                {
                    case AttributeMatchState.AttributeFound:
                        break;

                    case AttributeMatchState.AnyIdAttributeFound:
                        if (this.wildID != null)
                        {
                            this.SendValidationEvent("Sch_MoreThanOneWildId", string.Empty);
                        }
                        else
                        {
                            this.wildID = def;
                            XmlSchemaComplexType schemaType = elementDecl.SchemaType as XmlSchemaComplexType;
                            if (!schemaType.ContainsIdAttribute(false))
                            {
                                break;
                            }
                            this.SendValidationEvent("Sch_AttrUseAndWildId", string.Empty);
                        }
                        goto Label_0409;

                    case AttributeMatchState.UndeclaredElementAndAttribute:
                        def = this.CheckIsXmlAttribute(key);
                        if (def != null)
                        {
                            break;
                        }
                        if (((elementDecl != null) || (this.processContents != XmlSchemaContentProcessing.Strict)) || ((key.Namespace.Length == 0) || !this.compiledSchemaInfo.Contains(key.Namespace)))
                        {
                            if (this.processContents != XmlSchemaContentProcessing.Skip)
                            {
                                this.SendValidationEvent("Sch_NoAttributeSchemaFound", key.ToString(), XmlSeverityType.Warning);
                            }
                        }
                        else
                        {
                            this.attrValid = false;
                            this.SendValidationEvent("Sch_UndeclaredAttribute", key.ToString());
                        }
                        goto Label_0409;

                    case AttributeMatchState.UndeclaredAttribute:
                        def = this.CheckIsXmlAttribute(key);
                        if (def != null)
                        {
                            break;
                        }
                        this.attrValid = false;
                        this.SendValidationEvent("Sch_UndeclaredAttribute", key.ToString());
                        goto Label_0409;

                    case AttributeMatchState.AnyAttributeLax:
                        this.SendValidationEvent("Sch_NoAttributeSchemaFound", key.ToString(), XmlSeverityType.Warning);
                        goto Label_0409;

                    case AttributeMatchState.ProhibitedAnyAttribute:
                        def = this.CheckIsXmlAttribute(key);
                        if (def != null)
                        {
                            break;
                        }
                        this.attrValid = false;
                        this.SendValidationEvent("Sch_ProhibitedAttribute", key.ToString());
                        goto Label_0409;

                    case AttributeMatchState.ProhibitedAttribute:
                        this.attrValid = false;
                        this.SendValidationEvent("Sch_ProhibitedAttribute", key.ToString());
                        goto Label_0409;

                    case AttributeMatchState.AttributeNameMismatch:
                        this.attrValid = false;
                        this.SendValidationEvent("Sch_SchemaAttributeNameMismatch", new string[] { key.ToString(), ((XmlSchemaAttribute) partialValidationType).QualifiedName.ToString() });
                        goto Label_0409;

                    case AttributeMatchState.ValidateAttributeInvalidCall:
                        this.currentState = ValidatorState.Start;
                        this.attrValid = false;
                        this.SendValidationEvent("Sch_ValidateAttributeInvalidCall", string.Empty);
                        goto Label_0409;

                    default:
                        goto Label_0409;
                }
                schemaAttribute = def.SchemaAttribute;
                if (elementDecl != null)
                {
                    this.attPresence.Add(key, def);
                }
                if (attributeValueGetter != null)
                {
                    obj4 = attributeValueGetter();
                }
                else
                {
                    obj4 = attributeStringValue;
                }
                typedValue = this.CheckAttributeValue(obj4, def);
                XmlSchemaDatatype dtype = def.Datatype;
                if ((dtype.Variety == XmlSchemaDatatypeVariety.Union) && (typedValue != null))
                {
                    XsdSimpleValue value2 = typedValue as XsdSimpleValue;
                    xmlType = value2.XmlType;
                    dtype = value2.XmlType.Datatype;
                    typedValue = value2.TypedValue;
                }
                this.CheckTokenizedTypes(dtype, typedValue, true);
                if (this.HasIdentityConstraints)
                {
                    this.AttributeIdentityConstraints(key.Name, key.Namespace, typedValue, obj4.ToString(), dtype);
                }
            }
        Label_0409:
            if (!this.attrValid)
            {
                notKnown = XmlSchemaValidity.Invalid;
            }
            else if (def != null)
            {
                notKnown = XmlSchemaValidity.Valid;
            }
            if (schemaInfo != null)
            {
                schemaInfo.SchemaAttribute = schemaAttribute;
                schemaInfo.SchemaType = (schemaAttribute == null) ? null : schemaAttribute.AttributeSchemaType;
                schemaInfo.MemberType = xmlType;
                schemaInfo.IsDefault = false;
                schemaInfo.Validity = notKnown;
            }
            if (this.ProcessSchemaHints && (this.validatedNamespaces[ns] == null))
            {
                this.validatedNamespaces.Add(ns, ns);
            }
            return typedValue;
        }
All Usage Examples Of System.Xml.Schema.XmlSchemaInfo::Clear