示例#1
0
        private static void CreateTaxonomyElement(XmlNode node)
        {
            switch (node.Name)
            {
            case "taxonomyGroup":
                TaxonomyGroup = new TaxonomyGroup();
                break;

            case "taxonomyTermsets":
                break;

            case "taxonomyTermset":
                TermsetInfo = new TermSetInfo();
                break;

            case "terms":
                if (TermInfos == null)
                {
                    TermInfos = new List <TermInfo>();
                }
                break;

            case "term":
                var termInfo = new TermInfo();
                termInfo.TermId = Guid.NewGuid();
                TermInfos.Add(termInfo);
                break;

            case "name":
                NameParent(node.ParentNode.Name, node.InnerXml);
                break;

            case "format":
                var lastTerm = TermInfos.Last();
                lastTerm.TermFormat = node.InnerXml;
                break;

            case "url":
                var term = TermInfos.Last();
                term.TermHref = node.InnerXml;
                break;

            case "order":
                var finalTerm = TermInfos.Last();
                finalTerm.TermOrder = Convert.ToInt32(Int32.Parse(node.InnerXml));
                break;

            default:
                break;
            }
        }
示例#2
0
        private static void CreateSubTerms(TermInfo termInfo, Term term)
        {
            var lcid = 1033;

            if (termInfo.ChildTermInfos.Count != 0)
            {
                foreach (var childTerm in termInfo.ChildTermInfos)
                {
                    var newTerm = term.CreateTerm(childTerm.TermName, lcid, Guid.NewGuid());
                    newTerm.SetCustomProperty("Url", childTerm.TermHref);

                    CreateSubTerms(childTerm, newTerm);
                }
                string[] order = SetOrder(termInfo.ChildTermInfos);
                term.CustomSortOrder = String.Join(":", order);
            }
            else
            {
                return;
            }
        }