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


C# TemplateItem.GetField方法代码示例

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


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

示例1: CompareTwoTemplates

        private static void CompareTwoTemplates(Database compareDB, ItemComparisonInfo info, TemplateItem template, TemplateItem compareTemplate)
        {
            var infoF = (FieldComparisonInfo)null;
            foreach (var localF in template.OwnFields)
            {
                if (!localF.Name.StartsWith("__"))
                {
                    if (!info.FieldComparisons.ContainsKey(localF.Name))
                    {
                        infoF = new FieldComparisonInfo(localF);

                        var compareF = compareTemplate.GetField(localF.ID);
                        if (compareF == null)
                            infoF.AddDifference(string.Format("Field does not exist on database: {0}", compareDB.Name));
                        else
                        {
                            if (localF.Type != compareF.Type)
                                infoF.AddDifference("Type mismatch.", localF.Type, compareF.Type);
                            if (localF.Source != compareF.Source)
                                infoF.AddDifference("Source mismatch.", localF.Source, compareF.Source);
                            if (localF.Name != compareF.Name)
                                infoF.AddDifference("Name mismatch.", localF.Name, compareF.Name);

                            //foreach (var lang in localF.InnerItem.Languages)
                            //{
                            //    if (!compareF.InnerItem.Languages.Any(x => x.Name == lang.Name))
                            //        infoF.AddDifference("Language version missing", lang.Name, string.Empty);
                            //    else
                            //    {
                            //        var xmlLocal = GetSlimXml(localF.InnerItem.Database.GetItem(localF.ID, lang));
                            //        var xmlCompare = GetSlimXml(compareDB.GetItem(compareF.ID, lang));
                            //        if (xmlLocal != xmlCompare)
                            //            infoF.AddDifference(string.Format("({0}) Serialized field XML mismatch.", lang.Name), xmlLocal, xmlCompare);
                            //    }
                            //}

                            //foreach (var lang in compareF.InnerItem.Languages)
                            //{
                            //    if (!localF.InnerItem.Languages.Any(x => x.Name == lang.Name))
                            //        infoF.AddDifference("Language version missing", string.Empty, lang.Name);
                            //}

                            var xmlLocal = GetSlimXml(localF.InnerItem);
                            var xmlCompare = GetSlimXml(compareF.InnerItem);
                            if (xmlLocal != xmlCompare)
                                infoF.AddDifference("Serialized field XML mismatch.", xmlLocal, xmlCompare);
                        }

                        if (infoF.Differences.Count > 0)
                        {
                            info.Status = CompareStatus.Different;
                            info.FieldComparisons.Add(localF.Name, infoF);
                            info.Messages.Add("Field differences.");
                        }
                    }
                }
            }
        }
开发者ID:sitecorepm,项目名称:CompareServers,代码行数:58,代码来源:CompareEngine.cs


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