System.Xml.Serialization.SerializableMapping.SetBaseMapping C# (CSharp) Method

SetBaseMapping() private method

private SetBaseMapping ( SerializableMapping mapping ) : void
mapping SerializableMapping
return void
        internal void SetBaseMapping(SerializableMapping mapping)
        {
            _baseMapping = mapping;
            if (_baseMapping != null)
            {
                _nextDerivedMapping = _baseMapping._derivedMappings;
                _baseMapping._derivedMappings = this;
                if (this == _nextDerivedMapping)
                {
                    throw new InvalidOperationException(SR.Format(SR.XmlCircularDerivation, TypeDesc.FullName));
                }
            }
        }

Usage Example

        internal void SetBase(SerializableMapping mapping, XmlQualifiedName baseQname) {

            if (baseQname.IsEmpty) return;
            if (baseQname.Namespace == XmlSchema.Namespace) return;
            XmlSchemaSet schemas = mapping.Schemas;
            ArrayList srcSchemas = (ArrayList)schemas.Schemas(baseQname.Namespace);

            if (srcSchemas.Count == 0) {
                throw new InvalidOperationException(Res.GetString(Res.XmlMissingSchema, baseQname.Namespace));
            }
            if (srcSchemas.Count > 1) {
                throw new InvalidOperationException(Res.GetString(Res.XmlGetSchemaInclude, baseQname.Namespace, typeof(IXmlSerializable).Name, "GetSchema"));
            }
            XmlSchema s = (XmlSchema)srcSchemas[0];

            XmlSchemaType t = (XmlSchemaType)s.SchemaTypes[baseQname];
            t = t.Redefined != null ? t.Redefined : t;

            if (serializables[baseQname] == null) {
                SerializableMapping baseMapping = new SerializableMapping(baseQname, schemas);
                SetBase(baseMapping, t.DerivedFrom);
                serializables.Add(baseQname, baseMapping);
            }
            mapping.SetBaseMapping((SerializableMapping)serializables[baseQname]);
        }
All Usage Examples Of System.Xml.Serialization.SerializableMapping::SetBaseMapping