/// <include file='doc\XmlSchemas.uex' path='docs/doc[@for="XmlSchemas.Find"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public object Find(XmlQualifiedName name, Type type) { XmlSchema schema = (XmlSchema)namespaces[name.Namespace]; if (schema == null) { return(null); } if (!schema.IsPreprocessed) { try { schema.Preprocess(null); } catch (Exception e) { throw new InvalidOperationException(Res.GetString(Res.XmlSchemaSyntaxError, name.Namespace), e); } } if (type == typeof(XmlSchemaSimpleType) || type == typeof(XmlSchemaComplexType)) { object ret = schema.SchemaTypes[name]; if (ret != null && type.IsAssignableFrom(ret.GetType())) { return(ret); } else { return(null); } } else if (type == typeof(XmlSchemaGroup)) { return(schema.Groups[name]); } else if (type == typeof(XmlSchemaAttributeGroup)) { return(schema.AttributeGroups[name]); } else if (type == typeof(XmlSchemaElement)) { return(schema.Elements[name]); } else if (type == typeof(XmlSchemaAttribute)) { return(schema.Attributes[name]); } else if (type == typeof(XmlSchemaNotation)) { return(schema.Notations[name]); } #if DEBUG // use exception in the place of Debug.Assert to avoid throwing asserts from a server process such as aspnet_ewp.exe throw new InvalidOperationException(Res.GetString(Res.XmlInternalErrorDetails, "XmlSchemas.Find: Invalid object type " + type.FullName)); #else return(null); #endif }