public List <Threat> GetThreats() { var list = new List <Threat>(); var xThreats = xdoc.Document.Descendants(nsArrays + "KeyValueOfstringThreatpc_P0_PhOB").ToList(); foreach (XElement xThreat in xThreats) { var key = xThreat.Element(nsArrays + "Key").Value; var value = xThreat.Element(nsArrays + "Value"); var flowGuid = value.Element(nsKnowledgeBase + "FlowGuid").Value; var sourceGuid = value.Element(nsKnowledgeBase + "SourceGuid").Value; var targetGuid = value.Element(nsKnowledgeBase + "TargetGuid").Value; var threat = new Threat { Id = int.Parse(value.Element(nsKnowledgeBase + "Id").Value, CultureInfo.InvariantCulture), Priority = value.Element(nsKnowledgeBase + "Priority").Value, PriorityWeight = dictionaries.SeverityWeight.FirstOrDefault(i => i.Key == value.Element(nsKnowledgeBase + "Priority").Value).Value, ChangedBy = value.Element(nsKnowledgeBase + "ChangedBy").Value, ModifiedAt = DateTime.Parse(value.Element(nsKnowledgeBase + "ModifiedAt").Value, CultureInfo.InvariantCulture), FlowGuid = flowGuid, FlowName = getComponentPropertyValue(flowGuid, Settings.Default.Name), FlowOutOfScope = getComponentPropertyValue(flowGuid, Settings.Default.OutOfScope), FlowOutOfScopeReason = getComponentPropertyValue(flowGuid, Settings.Default.OutOfScopeReason), SourceGuid = sourceGuid, SourceName = getComponentPropertyValue(sourceGuid, Settings.Default.Name), SourceOutOfScope = getComponentPropertyValue(sourceGuid, Settings.Default.OutOfScope), SourceOutOfScopeReason = getComponentPropertyValue(sourceGuid, Settings.Default.OutOfScopeReason), TargetGuid = targetGuid, TargetName = getComponentPropertyValue(targetGuid, Settings.Default.Name), TargetOutOfScope = getComponentPropertyValue(targetGuid, Settings.Default.OutOfScope), TargetOutOfScopeReason = getComponentPropertyValue(targetGuid, Settings.Default.OutOfScopeReason), State = value.Element(nsKnowledgeBase + "State").Value == "AutoGenerated" ? "Not Started" : value.Element(nsKnowledgeBase + "State").Value }; threat.InteractionImage = xdoc.Descendants(nsKnowledgeBase + "ImageSource").FirstOrDefault().Value; var xProperties = value.Descendants(nsKnowledgeBase + "Properties").ToList(); foreach (XElement xProperty in xProperties.Elements(nsArrays + "KeyValueOfstringstring")) { if (xProperty.Element(nsArrays + "Key").Value == "Title") { threat.Title = xProperty.Element(nsArrays + "Value").Value; } else if (xProperty.Element(nsArrays + "Key").Value == "UserThreatDescription") { threat.Description = GetNormalizedString(xProperty.Element(nsArrays + "Value").Value); } else if (xProperty.Element(nsArrays + "Key").Value == "UserThreatShortDescription") { threat.ShortDescription = xProperty.Element(nsArrays + "Value").Value; } else if (xProperty.Element(nsArrays + "Key").Value == "UserThreatCategory") { threat.Category = xProperty.Element(nsArrays + "Value").Value; threat.MitigationStrategy = getMitigationStrategy(threat.Category); } else if (xProperty.Element(nsArrays + "Key").Value == "InteractionString") { threat.Interaction = xProperty.Element(nsArrays + "Value").Value; } else if (xProperty.Element(nsArrays + "Key").Value == "StateInformation") { threat.Justification = GetNormalizedString(xProperty.Element(nsArrays + "Value").Value); } else if (xProperty.Element(nsArrays + "Key").Value == "SDLPhase") { threat.SDLPhase = xProperty.Element(nsArrays + "Value").Value; } else if (xProperty.Element(nsArrays + "Key").Value == "PossibleMitigations") { threat.PossibleMitigations = xProperty.Element(nsArrays + "Value").Value; } else if (TryParseGuid(xProperty.Element(nsArrays + "Key").Value, out Guid key1)) { var customPropName = getCustomPropertyName(xdoc, key1.ToString()); if (customPropName == "Assets") { threat.Assets = xProperty.Element(nsArrays + "Value").Value; } if (customPropName == "Impact") { threat.Impact = xProperty.Element(nsArrays + "Value").Value; } if (customPropName == "Attack Vectors") { threat.AttackVectors = xProperty.Element(nsArrays + "Value").Value; } if (customPropName == "Likelihood") { threat.Likelihood = xProperty.Element(nsArrays + "Value").Value; } if (customPropName == "Actors") { threat.Actors = xProperty.Element(nsArrays + "Value").Value; } if (customPropName == "Affected (CIA)") { threat.Actions = xProperty.Element(nsArrays + "Value").Value; } if (customPropName == "Issue Reference") { threat.IssueReference = xProperty.Element(nsArrays + "Value").Value; } if (customPropName == "Issue Status") { threat.IssueStatus = xProperty.Element(nsArrays + "Value").Value; } if (customPropName == "Mitigated Components") { threat.MitigatedComponents = xProperty.Element(nsArrays + "Value").Value; } } } list.Add(threat); } return(list.OrderBy(i => i.Id).ToList()); }