public bool Validate(ListInstanceCollection sourceCollection, ListInstanceCollection targetCollection, TokenParser tokenParser) { // Convert object collections to XML List <SerializedListInstance> sourceLists = new List <SerializedListInstance>(); List <SerializedListInstance> targetLists = new List <SerializedListInstance>(); foreach (ListInstance list in sourceCollection) { // don't add hidden lists since they're not exported again... if (!list.Hidden) { ProvisioningTemplate pt = new ProvisioningTemplate(); pt.Lists.Add(list); sourceLists.Add(new SerializedListInstance() { SchemaXml = ExtractElementXml(pt) }); } } foreach (ListInstance list in targetCollection) { ProvisioningTemplate pt = new ProvisioningTemplate(); pt.Lists.Add(list); targetLists.Add(new SerializedListInstance() { SchemaXml = ExtractElementXml(pt) }); } // Use XML validation logic to compare source and target Dictionary <string, string[]> parserSettings = new Dictionary <string, string[]> { { "SchemaXml", null } }; bool isListsMatch = ValidateObjectsXML(sourceLists, targetLists, "SchemaXml", new List <string> { "Title" }, tokenParser, parserSettings); // Use CustomAction validator to validate the custom actions on the list if (!isNoScriptSite) { var sourceListsWithUserCustomActions = sourceCollection.Where(p => p.UserCustomActions.Any() == true); foreach (ListInstance list in sourceListsWithUserCustomActions) { var targetList = targetCollection.Where(p => p.Title == list.Title).FirstOrDefault(); if (!CustomActionValidator.ValidateCustomActions(list.UserCustomActions, targetList.UserCustomActions, tokenParser)) { isListsMatch = false; break; } } } Console.WriteLine("-- Lists validation " + isListsMatch); return(isListsMatch); }
public bool ValidateListInstances(ListInstanceCollection sElements, ListInstanceCollection tElements, TokenParser sParser, TokenParser tParser) { List <Localization> sColl = LoadListInstances(sElements); List <Localization> tColl = LoadListInstances(tElements); if (sColl.Count > 0) { if (!Validatelocalization(sColl, tColl, sParser, tParser)) { return(false); } } return(true); }
private List <Localization> LoadListInstances(ListInstanceCollection coll) { List <Localization> loc = new List <Localization>(); foreach (ListInstance item in coll) { Localization localization = new Localization(item.Url, item.Title, item.Description); if (item.Fields != null) { localization.Fields = item.Fields; } loc.Add(localization); } return(loc); }
public bool Validate(ListInstanceCollection sourceCollection, ListInstanceCollection targetCollection, TokenParser tokenParser) { // Convert object collections to XML List<SerializedListInstance> sourceLists = new List<SerializedListInstance>(); List<SerializedListInstance> targetLists = new List<SerializedListInstance>(); foreach (ListInstance list in sourceCollection) { // don't add hidden lists since they're not exported again... if (!list.Hidden) { ProvisioningTemplate pt = new ProvisioningTemplate(); pt.Lists.Add(list); sourceLists.Add(new SerializedListInstance() { SchemaXml = ExtractElementXml(pt) }); } } foreach (ListInstance list in targetCollection) { ProvisioningTemplate pt = new ProvisioningTemplate(); pt.Lists.Add(list); targetLists.Add(new SerializedListInstance() { SchemaXml = ExtractElementXml(pt) }); } // Use XML validation logic to compare source and target Dictionary<string, string[]> parserSettings = new Dictionary<string, string[]>(); parserSettings.Add("SchemaXml", null); bool isListsMatch = ValidateObjectsXML(sourceLists, targetLists, "SchemaXml", new List<string> { "Title" }, tokenParser, parserSettings); // Use CustomAction validator to validate the custom actions on the list var sourceListsWithUserCustomActions = sourceCollection.Where(p => p.UserCustomActions.Any() == true); foreach(ListInstance list in sourceListsWithUserCustomActions) { var targetList = targetCollection.Where(p => p.Title == list.Title).FirstOrDefault(); if (!CustomActionValidator.ValidateCustomActions(list.UserCustomActions, targetList.UserCustomActions, tokenParser)) { isListsMatch = false; break; } } Console.WriteLine("-- Lists validation " + isListsMatch); return isListsMatch; }
public bool ValidateListInstances(ListInstanceCollection sElements, ListInstanceCollection tElements, TokenParser sParser, TokenParser tParser) { List<Localization> sColl = LoadListInstances(sElements); List<Localization> tColl = LoadListInstances(tElements); if (sColl.Count > 0) { if (!Validatelocalization(sColl, tColl, sParser, tParser)) { return false; } } return true; }
private List<Localization> LoadListInstances(ListInstanceCollection coll) { List<Localization> loc = new List<Localization>(); foreach (ListInstance item in coll) { Localization localization = new Localization(item.Url, item.Title, item.Description); if (item.Fields != null) { localization.Fields = item.Fields; } loc.Add(localization); } return loc; }