System.Xml.Schema.XmlSchemaAttribute.SetAttributeType C# (CSharp) Method

SetAttributeType() private method

private SetAttributeType ( XmlSchemaSimpleType value ) : void
value XmlSchemaSimpleType
return void
        internal void SetAttributeType(XmlSchemaSimpleType value) { 
            attributeType = value;
        }

Usage Example

        private void CompileAttribute(XmlSchemaAttribute xa)
        {
            if (xa.IsProcessing)
            {
                base.SendValidationEvent("Sch_AttributeCircularRef", xa);
            }
            else if (xa.AttDef == null)
            {
                xa.IsProcessing = true;
                SchemaAttDef def = null;
                try
                {
                    if (!xa.RefName.IsEmpty)
                    {
                        XmlSchemaAttribute attribute = (XmlSchemaAttribute) this.schema.Attributes[xa.RefName];
                        if (attribute == null)
                        {
                            throw new XmlSchemaException("Sch_UndeclaredAttribute", xa.RefName.ToString(), xa);
                        }
                        this.CompileAttribute(attribute);
                        if (attribute.AttDef == null)
                        {
                            throw new XmlSchemaException("Sch_RefInvalidAttribute", xa.RefName.ToString(), xa);
                        }
                        def = attribute.AttDef.Clone();
                        if (def.Datatype != null)
                        {
                            if (attribute.FixedValue != null)
                            {
                                if (xa.DefaultValue != null)
                                {
                                    throw new XmlSchemaException("Sch_FixedDefaultInRef", xa.RefName.ToString(), xa);
                                }
                                if (xa.FixedValue != null)
                                {
                                    if (xa.FixedValue != attribute.FixedValue)
                                    {
                                        throw new XmlSchemaException("Sch_FixedInRef", xa.RefName.ToString(), xa);
                                    }
                                }
                                else
                                {
                                    def.Presence = SchemaDeclBase.Use.Fixed;
                                    def.DefaultValueRaw = def.DefaultValueExpanded = attribute.FixedValue;
                                    def.DefaultValueTyped = def.Datatype.ParseValue(def.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), true);
                                }
                            }
                            else if (((attribute.DefaultValue != null) && (xa.DefaultValue == null)) && (xa.FixedValue == null))
                            {
                                def.Presence = SchemaDeclBase.Use.Default;
                                def.DefaultValueRaw = def.DefaultValueExpanded = attribute.DefaultValue;
                                def.DefaultValueTyped = def.Datatype.ParseValue(def.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), true);
                            }
                        }
                        xa.SetAttributeType(attribute.AttributeSchemaType);
                    }
                    else
                    {
                        def = new SchemaAttDef(xa.QualifiedName);
                        if (xa.SchemaType != null)
                        {
                            this.CompileSimpleType(xa.SchemaType);
                            xa.SetAttributeType(xa.SchemaType);
                            def.SchemaType = xa.SchemaType;
                            def.Datatype = xa.SchemaType.Datatype;
                        }
                        else if (!xa.SchemaTypeName.IsEmpty)
                        {
                            XmlSchemaSimpleType simpleType = this.GetSimpleType(xa.SchemaTypeName);
                            if (simpleType == null)
                            {
                                throw new XmlSchemaException("Sch_UndeclaredSimpleType", xa.SchemaTypeName.ToString(), xa);
                            }
                            xa.SetAttributeType(simpleType);
                            def.Datatype = simpleType.Datatype;
                            def.SchemaType = simpleType;
                        }
                        else
                        {
                            def.SchemaType = DatatypeImplementation.AnySimpleType;
                            def.Datatype = DatatypeImplementation.AnySimpleType.Datatype;
                            xa.SetAttributeType(DatatypeImplementation.AnySimpleType);
                        }
                    }
                    if (def.Datatype != null)
                    {
                        def.Datatype.VerifySchemaValid(this.schema.Notations, xa);
                    }
                    if ((xa.DefaultValue != null) || (xa.FixedValue != null))
                    {
                        if (xa.DefaultValue != null)
                        {
                            def.Presence = SchemaDeclBase.Use.Default;
                            def.DefaultValueRaw = def.DefaultValueExpanded = xa.DefaultValue;
                        }
                        else
                        {
                            def.Presence = SchemaDeclBase.Use.Fixed;
                            def.DefaultValueRaw = def.DefaultValueExpanded = xa.FixedValue;
                        }
                        if (def.Datatype != null)
                        {
                            def.DefaultValueTyped = def.Datatype.ParseValue(def.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), true);
                        }
                    }
                    else
                    {
                        switch (xa.Use)
                        {
                            case XmlSchemaUse.None:
                            case XmlSchemaUse.Optional:
                                def.Presence = SchemaDeclBase.Use.Implied;
                                break;

                            case XmlSchemaUse.Required:
                                def.Presence = SchemaDeclBase.Use.Required;
                                break;
                        }
                    }
                    def.SchemaAttribute = xa;
                    xa.AttDef = def;
                }
                catch (XmlSchemaException exception)
                {
                    if (exception.SourceSchemaObject == null)
                    {
                        exception.SetSource(xa);
                    }
                    base.SendValidationEvent(exception);
                    xa.AttDef = SchemaAttDef.Empty;
                }
                finally
                {
                    xa.IsProcessing = false;
                }
            }
        }
All Usage Examples Of System.Xml.Schema.XmlSchemaAttribute::SetAttributeType