System.Xml.Serialization.XmlReflectionImporter.SetBase C# (CSharp) Method

SetBase() private method

private SetBase ( SerializableMapping mapping, XmlQualifiedName baseQname ) : void
mapping SerializableMapping
baseQname XmlQualifiedName
return void
        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(SR.Format(SR.XmlMissingSchema, baseQname.Namespace));
            }
            if (srcSchemas.Count > 1)
            {
                throw new InvalidOperationException(SR.Format(SR.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]);
        }