private static CSharpFormattingProperties Load(XElement element) { var properties = new CSharpFormattingProperties(); properties.LoadContents(element.Elements()); return(properties); }
private static CSharpFormattingProperties Load(string fileName) { var result = new CSharpFormattingProperties(); using (var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { var xDocument = XDocument.Load(fileStream); if (xDocument.Root == null) { return(result); } var csharpFormattingPropertiesElement = xDocument.Root.DescendantsAndSelf().FirstOrDefault( e => e.Name == "Properties" && e.Attribute("key") != null && e.Attribute("key").Value == "CSharpFormatting" ); if (csharpFormattingPropertiesElement == null) { // Give it a shot _without the key :-) csharpFormattingPropertiesElement = xDocument.Root.DescendantsAndSelf() .FirstOrDefault( e => e.Name == "Properties"); } return(Load(csharpFormattingPropertiesElement)); } }