当前位置: 首页>>代码示例>>C#>>正文


C# Term.GetDescription方法代码示例

本文整理汇总了C#中Term.GetDescription方法的典型用法代码示例。如果您正苦于以下问题:C# Term.GetDescription方法的具体用法?C# Term.GetDescription怎么用?C# Term.GetDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Term的用法示例。


在下文中一共展示了Term.GetDescription方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddTermElement

        private XmlElement AddTermElement(XmlElement parent, Term term)
        {
            XmlElement element = _xml.CreateElement("Term");
            if (parent == null)
                _xml.AppendChild(element);
            else
            {
                if (parent.Name == "TermSets")
                    parent.AppendChild(element);
                else
                {
                    XmlElement termsElement = parent.SelectSingleNode("./Terms") as XmlElement;
                    if (termsElement == null)
                    {
                        termsElement = _xml.CreateElement("Terms");
                        parent.AppendChild(termsElement);
                    }
                    termsElement.AppendChild(element);
                }
            }

            element.SetAttribute("Id", term.Id.ToString());
            element.SetAttribute("Name", term.Name);
            element.SetAttribute("CreatedDate", term.CreatedDate.ToString());
            element.SetAttribute("LastModifiedDate", term.LastModifiedDate.ToString());
            element.SetAttribute("Owner", term.Owner);
            element.SetAttribute("IsDeprecated", term.IsDeprecated.ToString());
            element.SetAttribute("IsAvailableForTagging", term.IsAvailableForTagging.ToString());
            element.SetAttribute("IsKeyword", term.IsKeyword.ToString());
            element.SetAttribute("IsReused", term.IsReused.ToString());
            element.SetAttribute("IsRoot", term.IsRoot.ToString());
            element.SetAttribute("IsSourceTerm", term.IsSourceTerm.ToString());
            element.SetAttribute("CustomSortOrder", term.CustomSortOrder);
            element.SetAttribute("IsPinned", term.IsPinned.ToString());
            element.SetAttribute("IsPinnedRoot", term.IsPinnedRoot.ToString());
            element.SetAttribute("PathOfTerm", term.PathOfTerm);

            if (!term.SourceTerm.IsPropertyAvailable("Id") || !term.SourceTerm.IsPropertyAvailable("Name"))
            {
                _ctx.Load(term.SourceTerm, st => st.Id, st => st.Name);
                _ctx.ExecuteQuery();
            }
            element.SetAttribute("SourceTerm", term.SourceTerm.Id + "|" + term.SourceTerm.Name);

            if (!term.PinSourceTermSet.IsPropertyAvailable("Id") || !term.PinSourceTermSet.IsPropertyAvailable("Name"))
            {
                _ctx.Load(term.PinSourceTermSet, st => st.Id, st => st.Name);
                _ctx.ExecuteQuery();
            }
            if (!term.PinSourceTermSet.ServerObjectIsNull.Value)
                element.SetAttribute("PinSourceTermSet", term.PinSourceTermSet.Id + "|" + term.PinSourceTermSet.Name);

            XmlElement descriptionsElement = _xml.CreateElement("Descriptions");
            element.AppendChild(descriptionsElement);
            LoadLanguages(term.TermStore);
            foreach (int lcid in _languages)
            {
                XmlElement descriptionElement = _xml.CreateElement("Description");
                descriptionsElement.AppendChild(descriptionElement);
                descriptionElement.SetAttribute("Language", lcid.ToString());
                var desc = term.GetDescription(lcid);
                _ctx.ExecuteQuery();
                descriptionElement.SetAttribute("Value", desc.Value);
            }

            XmlElement propertiesElement = _xml.CreateElement("CustomProperties");
            element.AppendChild(propertiesElement);
            foreach (string key in term.CustomProperties.Keys)
            {
                XmlElement propertyElement = _xml.CreateElement("CustomProperty");
                propertiesElement.AppendChild(propertyElement);
                propertyElement.SetAttribute("Name", key);
                propertyElement.SetAttribute("Value", term.CustomProperties[key]);
            }

            XmlElement localPropertiesElement = _xml.CreateElement("LocalCustomProperties");
            element.AppendChild(localPropertiesElement);
            foreach (string key in term.LocalCustomProperties.Keys)
            {
                XmlElement propertyElement = _xml.CreateElement("LocalCustomProperty");
                localPropertiesElement.AppendChild(propertyElement);
                propertyElement.SetAttribute("Name", key);
                propertyElement.SetAttribute("Value", term.LocalCustomProperties[key]);
            }

            XmlElement mergedTermIdsElement = _xml.CreateElement("MergedTermIds");
            element.AppendChild(mergedTermIdsElement);
            foreach (Guid mergedTermId in term.MergedTermIds)
            {
                XmlElement mergedTermIdElement = _xml.CreateElement("MergedTermId");
                mergedTermIdsElement.AppendChild(mergedTermIdElement);
                mergedTermIdElement.SetAttribute("Value", mergedTermId.ToString());
            }

            return element;
        }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:96,代码来源:ExportTermsHelper.cs

示例2: UpdateTerm

        private void UpdateTerm(ClientContext sourceClientContext, ClientContext targetClientContext, Term sourceTerm, Term targetTerm, List<int> languagesToProcess)
        {
            targetTerm.Name = sourceTerm.Name;
            targetTerm.IsAvailableForTagging = sourceTerm.IsAvailableForTagging;

            // Process custom properties
            if (sourceTerm.LocalCustomProperties.Count > 0)
            {
                // add properties from source
                foreach (KeyValuePair<string, string> property in sourceTerm.LocalCustomProperties)
                {
                    targetTerm.SetLocalCustomProperty(property.Key, property.Value);
                }
            }

            if (targetTerm.LocalCustomProperties.Count > 0)
            {
                //remove properties which are not needed anymore
                foreach (KeyValuePair<string, string> property in targetTerm.LocalCustomProperties)
                {
                    if (!sourceTerm.LocalCustomProperties.Keys.Contains(property.Key, StringComparer.InvariantCultureIgnoreCase))
                    {
                        targetTerm.DeleteLocalCustomProperty(property.Key);
                    }
                }
            }

            if (sourceTerm.CustomProperties.Count > 0)
            {
                // add properties from source
                foreach (KeyValuePair<string, string> property in sourceTerm.CustomProperties)
                {
                    targetTerm.SetCustomProperty(property.Key, property.Value);
                }
            }

            if (targetTerm.CustomProperties.Count > 0)
            {
                //remove properties which are not needed anymore
                foreach (KeyValuePair<string, string> property in targetTerm.CustomProperties)
                {
                    if (!sourceTerm.CustomProperties.Keys.Contains(property.Key, StringComparer.InvariantCultureIgnoreCase))
                    {
                        targetTerm.DeleteCustomProperty(property.Key);
                    }
                }
            }

            targetClientContext.ExecuteQuery();

            foreach (int language in languagesToProcess)
            {
                ClientResult<string> targetTermDescription = sourceTerm.GetDescription(language);
                sourceClientContext.ExecuteQuery();
                targetTerm.SetDescription(targetTermDescription.Value, language);

                //Process labels
                // Add new labels if needed
                LabelCollection sourceLabels = sourceTerm.GetAllLabels(language);
                sourceClientContext.Load(sourceLabels);
                sourceClientContext.ExecuteQuery();
                LabelCollection targetLabels = targetTerm.GetAllLabels(language);
                targetClientContext.Load(targetLabels);
                targetClientContext.ExecuteQuery();
                foreach (Label sourceLabel in sourceLabels)
                {
                    Label test = targetLabels.FirstOrDefault<Label>(label => label.Value.Equals(sourceLabel.Value));

                    if (test == null)
                    {
                        targetTerm.CreateLabel(sourceLabel.Value, sourceLabel.Language, sourceLabel.IsDefaultForLanguage);
                    }
                }
                targetClientContext.ExecuteQuery();

                // remove non existing labels
                targetLabels = targetTerm.GetAllLabels(language);
                targetClientContext.Load(targetLabels);
                targetClientContext.ExecuteQuery();
                List<Label> labelsToRemove = new List<Label>();
                foreach (Label targetLabel in targetLabels)
                {
                    Label test = sourceLabels.FirstOrDefault<Label>(label => label.Value.Equals(targetLabel.Value));
                    if (test == null)
                    {
                        labelsToRemove.Add(targetLabel);
                    }
                }

                foreach (Label label in labelsToRemove)
                {
                    label.DeleteObject();
                    targetClientContext.ExecuteQuery();
                }
            }

            // Deprecating terms on the target is tricky...this will prevent reuse of deprecited terms later on
            //if (sourceTerm.IsDeprecated && !targetTerm.IsDeprecated)
            //{
            //    targetTerm.Deprecate(true);
//.........这里部分代码省略.........
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:101,代码来源:MMSSyncManager.cs

示例3: GetTerm

 private static void GetTerm(Term term)
 {
     strExportXml.Append("<Term Name=\"" + term.Name.ToString() + "\">");
     strExportXml.Append("<Labels>");
     foreach (Microsoft.SharePoint.Taxonomy.Label lbl in term.Labels)
     {
         strExportXml.Append("<Label lcid=\"" + lbl.Language.ToString() + "\" Name=\"" + lbl.Value + "\" Description=\"" + term.GetDescription(lbl.Language) + "\" />");
         //  Console.WriteLine("     Label: " + lbl.Value + " LCID: " + lbl.Language.ToString());
     }
     strExportXml.Append("</Labels>");
     foreach (Term subtrm in term.Terms)
     {
         strExportXml.Append("<Terms>");
         GetTerm(subtrm);
         strExportXml.Append("</Terms>");
     }
     strExportXml.Append("</Term>");
 }
开发者ID:chrisdee,项目名称:Solutions,代码行数:18,代码来源:Form1.cs


注:本文中的Term.GetDescription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。