Beispiel #1
0
        private static void WriteJumpTableSection(this MamlWriter writer, Context context,
                                                  IEnumerable <XmlSchemaObject> rows, string title, string address)
        {
            var listItems = ListItemBuilder.Build(context, rows);

            writer.WriteJumpTableSection(context, listItems, title, address);
        }
Beispiel #2
0
        public static void WriteUsagesSection(this MamlWriter writer, Context context, IEnumerable <XmlSchemaObject> usages)
        {
            // Test for empty list...
            IList <ListItem> listItems = ListItemBuilder.Build(context, usages);

            if (listItems == null || listItems.Count == 0)
            {
                return;
            }

            writer.StartSection("Usages", "usages");
            writer.StartParagraph();
            writer.WriteList(context, listItems);
            writer.EndParagraph();

            writer.StartParagraph();
            if (context.MoveToTopLink && listItems.Count > 15)
            {
                // Create a link to the introduction, it is the top...
                writer.WriteLink("#introduction", "Top");
            }
            writer.EndParagraph();

            writer.EndSection();
        }
Beispiel #3
0
        private static void WriteJumpTableSection(this MamlWriter writer, Context context,
                                                  IEnumerable <string> namespaces, string title, string address)
        {
            var listItems = ListItemBuilder.Build(context, namespaces);

            writer.WriteJumpTableSection(context, listItems, title, address);
        }
        public static void WriteList(this MamlWriter writer, Context context, IEnumerable <XmlSchemaObject> schemaObjects)
        {
            var listItems = ListItemBuilder.Build(context, schemaObjects);

            var isFirst = true;

            foreach (var item in listItems)
            {
                if (isFirst)
                {
                    writer.WriteString(" ");
                    isFirst = false;
                }

                writer.WriteHtmlArtItemWithTopicLink(item.ArtItem, item.Topic);
            }
        }
        private static string GetSchemaObjectName(Context context,
                                                  XmlSchemaObject schemaObject)
        {
            XmlSchema               schema;
            XmlSchemaAttribute      attribute;
            XmlSchemaElement        element;
            XmlSchemaGroup          group;
            XmlSchemaAttributeGroup attributeGroup;
            XmlSchemaSimpleType     simpleType;
            XmlSchemaComplexType    complexType;
            XmlSchemaGroupBase      groupBase;
            XmlSchemaGroupRef       groupRef;

            XmlSchemaContent content;

            if (Casting.TryCast(schemaObject, out attribute))
            {
                var parents = context.SchemaSetManager.GetObjectParents(attribute);

                IList <ListItem> listItems = ListItemBuilder.Build(context, parents);
                if (listItems != null && listItems.Count == 1)
                {
                    ListItem parentItem = listItems[0];

                    return(parentItem.Topic.LinkTitle);
                }

                //var simpleTypeStructureRoot =
                //    context.SchemaSetManager.GetSimpleTypeStructure(
                //    attribute.AttributeSchemaType);
                //if (simpleTypeStructureRoot != null)
                //{
                //    if (simpleTypeStructureRoot.Children.Count == 1)
                //    {
                //        var node = simpleTypeStructureRoot.Children[0];
                //        var isSingleRow = SimpleTypeStructureNode.GetIsSingleRow(node);
                //        if (isSingleRow && node.NodeType == SimpleTypeStructureNodeType.NamedType)
                //        {
                //            XmlSchemaType schemaType = (XmlSchemaType)node.Node;

                //            return GetTypeName(context.TopicManager, schemaType);
                //        }
                //    }
                //}

                return(attribute.AttributeSchemaType.Name);
            }

            if (Casting.TryCast(schemaObject, out element))
            {
                var parents = context.SchemaSetManager.GetObjectParents(element);

                IList <ListItem> listItems = ListItemBuilder.Build(context, parents);
                if (listItems != null && listItems.Count == 1)
                {
                    ListItem parentItem = listItems[0];

                    return(parentItem.Topic.LinkTitle);
                }

                //var simpleTypeStructureRoot =
                //    context.SchemaSetManager.GetSimpleTypeStructure(
                //    element.ElementSchemaType);

                //if (simpleTypeStructureRoot != null)
                //{
                //    if (simpleTypeStructureRoot.Children.Count == 1)
                //    {
                //        var node = simpleTypeStructureRoot.Children[0];
                //        var isSingleRow = SimpleTypeStructureNode.GetIsSingleRow(node);
                //        if (isSingleRow && node.NodeType == SimpleTypeStructureNodeType.NamedType)
                //        {
                //            XmlSchemaType schemaType = (XmlSchemaType)node.Node;

                //            return GetTypeName(context.TopicManager, schemaType);
                //        }
                //    }
                //}

                return(element.ElementSchemaType.Name);
            }

            if (Casting.TryCast(schemaObject, out schema))
            {
                return(String.Empty);
            }

            if (Casting.TryCast(schemaObject, out group))
            {
                return(group.QualifiedName.Name);
            }

            if (Casting.TryCast(schemaObject, out attributeGroup))
            {
                return(attributeGroup.QualifiedName.Name);
            }
            if (Casting.TryCast(schemaObject, out simpleType))
            {
                return(simpleType.QualifiedName.Name);
            }

            if (Casting.TryCast(schemaObject, out complexType))
            {
                return(complexType.QualifiedName.Name);
            }

            if (Casting.TryCast(schemaObject, out groupBase))
            {
                return(GetSchemaObjectName(context, groupBase.Parent));
            }

            if (Casting.TryCast(schemaObject, out groupRef))
            {
                group = context.SchemaSetManager.SchemaSet.ResolveGroup(groupRef);

                if (group != null)
                {
                    return(group.QualifiedName.Name);
                }
            }

            if (Casting.TryCast(schemaObject, out content))
            {
                XmlSchemaSimpleContentExtension    simpleContentExtension;
                XmlSchemaSimpleContentRestriction  simpleContentRestriction;
                XmlSchemaComplexContentExtension   complexContentExtension;
                XmlSchemaComplexContentRestriction complexContentRestriction;

                if (Casting.TryCast(content, out simpleContentExtension))
                {
                    return(simpleContentExtension.BaseTypeName.Name);
                }
                else if (Casting.TryCast(content, out simpleContentRestriction))
                {
                    return(simpleContentRestriction.BaseTypeName.Name);
                }
                else if (Casting.TryCast(content, out complexContentExtension))
                {
                    return(complexContentExtension.BaseTypeName.Name);
                }
                else if (Casting.TryCast(content, out complexContentRestriction))
                {
                    return(complexContentRestriction.BaseTypeName.Name);
                }
            }

            //if (schemaObject.Parent != null)
            //{
            //    return GetSchemaObjectName(context, schemaObject.Parent);
            //}

            throw ExceptionBuilder.UnexpectedSchemaObjectType(schemaObject);
        }