private void ResolveProtectionLevel() { _protectionLevelAttribute = FileXmlDocument.SelectSingleNode("/DTS:Executable", NamespaceManager)?.Attributes?["DTS:ProtectionLevel"]; // At least in Visual Studio 2017 (14.0.0800.98), the DTS:ProtectionLevel elemented is ommited in case it is set to DontSaveSensitive. if (_protectionLevelAttribute == null) { var attr = FileXmlDocument.CreateAttribute("DTS:ProtectionLevel"); attr.Value = "DontSaveSensitive"; _protectionLevelAttribute = attr; } var protectionLevelValue = _protectionLevelAttribute?.Value; ProtectionLevel protectionLevel; if (!Enum.TryParse(protectionLevelValue, true, out protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}.", FileXmlDocument); } if (!Enum.IsDefined(typeof(ProtectionLevel), protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}.", FileXmlDocument); } }
private void ResolveProtectionLevel() { _protectionLevelAttribute = FileXmlDocument.SelectSingleNode("/DTS:Executable", NamespaceManager)?.Attributes?["DTS:ProtectionLevel"]; if (_protectionLevelAttribute == null) { _protectionLevelAttribute = FileXmlDocument.SelectSingleNode("/DTS:Executable", NamespaceManager).Attributes.Append(FileXmlDocument.CreateAttribute("DTS:ProtectionLevel")); ProtectionLevel = ProtectionLevel.DontSaveSensitive; } var protectionLevelValue = _protectionLevelAttribute.Value; ProtectionLevel protectionLevel; if (!Enum.TryParse(protectionLevelValue, true, out protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}. For Project {FilePath}", FileXmlDocument); } if (!Enum.IsDefined(typeof(ProtectionLevel), protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}. . For Project {FilePath}", FileXmlDocument); } }