protected internal override void Read(XmlSchemaObject obj)
        {
            var type = obj as XmlSchemaComplexType;
            if (type != null)
            {
                AnyAttribute = type.AnyAttribute;
                var particle = type.Particle;

                if (particle == null && type.ContentModel != null)
                {
                    if (type.ContentModel.Content == null)
                    {
                        throw new InvalidOperationException(string.Format("Missing content on complex type content model '{0}'", type.Name));
                    }

                    var extension = type.ContentModel.Content as XmlSchemaComplexContentExtension;

                    if (extension == null)
                    {
                        throw new InvalidOperationException(string.Format("Unexpected content type '{0}' on complex type content model '{1}'", type.ContentModel.Content.GetType(), type.Name));
                    }

                    AnyAttribute = extension.AnyAttribute;
                    BaseType = extension.BaseTypeName;
                    particle = extension.Particle;
                }
                else
                {
                    AnyAttribute = type.AnyAttribute;
                }

                if (particle != null)
                {
                    var all = particle as XmlSchemaAll;

                    if (all == null)
                    {
                        throw new InvalidOperationException(string.Format("Unexpected particle type '{0}' on complex type '{1}'", particle.GetType(), type.Name));
                    }

                    foreach (var item in all.Items)
                    {
                        var element = item as XmlSchemaElement;

                        if (element == null)
                        {
                            throw new InvalidOperationException(string.Format("Unexpected all item type '{0}' on complex type '{1}'", item.GetType(), type.Name));
                        }

                        SDataSchemaProperty prop;

                        if (element.UnhandledAttributes != null && element.UnhandledAttributes.Any(attr => attr.NamespaceURI == SmeNamespaceUri && attr.LocalName == "relationship"))
                        {
                            prop = new SDataSchemaRelationshipProperty();
                        }
                        else
                        {
                            prop = new SDataSchemaValueProperty();
                        }

                        prop.Read(element);
                        Properties.Add(prop);
                    }
                }
            }

            base.Read(obj);
        }
예제 #2
0
        protected internal override void Read(XmlSchemaObject obj)
        {
            if (obj is XmlSchemaComplexType)
            {
                var type = (XmlSchemaComplexType)obj;
                AnyAttribute = type.AnyAttribute;
                var particle = type.Particle;

                if (particle == null && type.ContentModel != null)
                {
                    if (type.ContentModel.Content == null)
                    {
                        throw new InvalidOperationException(string.Format("Missing content on complex type content model '{0}'", type.Name));
                    }

                    var extension = type.ContentModel.Content as XmlSchemaComplexContentExtension;

                    if (extension == null)
                    {
                        throw new InvalidOperationException(string.Format("Unexpected content type '{0}' on complex type content model '{1}'", type.ContentModel.Content.GetType(), type.Name));
                    }

                    AnyAttribute = extension.AnyAttribute;
                    BaseType     = extension.BaseTypeName;
                    particle     = extension.Particle;
                }
                else
                {
                    AnyAttribute = type.AnyAttribute;
                }

                if (particle != null)
                {
                    var all = particle as XmlSchemaAll;

                    if (all == null)
                    {
                        throw new InvalidOperationException(string.Format("Unexpected particle type '{0}' on complex type '{1}'", particle.GetType(), type.Name));
                    }

                    foreach (var item in all.Items)
                    {
                        var element = item as XmlSchemaElement;

                        if (element == null)
                        {
                            throw new InvalidOperationException(string.Format("Unexpected all item type '{0}' on complex type '{1}'", item.GetType(), type.Name));
                        }

                        SDataSchemaProperty prop;

                        if (element.UnhandledAttributes != null && element.UnhandledAttributes.Any(attr => attr.NamespaceURI == SmeNamespaceUri && attr.LocalName == "relationship"))
                        {
                            prop = new SDataSchemaRelationshipProperty();
                        }
                        else
                        {
                            prop = new SDataSchemaValueProperty();
                        }

                        prop.Read(element);
                        Properties.Add(prop);
                    }
                }
            }

            base.Read(obj);
        }