public static List <MappingLogic> getMappingLogicsFromString(string logicsString, TSF_EA.Model model)
{
var mappingLogics = new List <MappingLogic>();
if (!string.IsNullOrEmpty(logicsString))
{
try
{
XDocument xdoc = XDocument.Load(new System.IO.StringReader(logicsString));
foreach (var logicNode in xdoc.Descendants("mappingLogic"))
{
string contextID = logicNode.Elements("context").FirstOrDefault()?.Value;
TSF_EA.ElementWrapper contextElement = model.getElementWrapperByGUID(contextID);
string description = logicNode.Elements("description").FirstOrDefault()?.Value;
//only create mapping logic if the description exists, or the contextElement exists.
if (!string.IsNullOrEmpty(description) || contextElement != null)
{
mappingLogics.Add(new MappingLogic(description, contextElement));
}
}
}
catch (System.Xml.XmlException)
{
//no xml found, just plain text
mappingLogics.Add(new MappingLogic(logicsString));
}
}
return(mappingLogics);
}