本文整理汇总了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.");
}
}
}
}
}