static Tuple <DefaultDocumentList, bool> ReadDefaultFileList(string filename) { try { var doc = XDocument.Load(filename, LoadOptions.None); var root = doc.Root; if (root.Name != "FileList") { return(null); } var name = (string)root.Attribute("name"); if (string.IsNullOrWhiteSpace(name)) { return(null); } bool?isDefault = (bool?)root.Attribute("default"); var l = new DefaultDocumentList(name); foreach (var sect in root.Elements("File")) { var name2 = (string)sect.Attribute("name"); if (string.IsNullOrWhiteSpace(name2)) { return(null); } var type = (string)sect.Attribute("type") ?? "gac"; var guidStr = (string)sect.Attribute("guid"); Guid guid = Guid.Empty; bool hasGuid = guidStr != null && Guid.TryParse(guidStr, out guid); if (type.Equals("file")) { l.Add(DsDocumentInfo.CreateDocument(name2)); } else if (type.Equals("refasm")) { l.Add(new DsDocumentInfo(name2, DocumentConstants.DOCUMENTTYPE_REFASM)); } else if (type.Equals("user-file") && hasGuid) { l.Add(new DsDocumentInfo(name2, guid)); } else // should be "gac" { l.Add(DsDocumentInfo.CreateGacDocument(name2)); } } return(Tuple.Create(l, isDefault ?? false)); } catch { Debug.Fail("Exception"); } return(null); }
static Tuple<DefaultDocumentList, bool> ReadDefaultFileList(string filename) { try { var doc = XDocument.Load(filename, LoadOptions.None); var root = doc.Root; if (root.Name != "FileList") return null; var name = (string)root.Attribute("name"); if (string.IsNullOrWhiteSpace(name)) return null; bool? isDefault = (bool?)root.Attribute("default"); var l = new DefaultDocumentList(name); foreach (var sect in root.Elements("File")) { var name2 = (string)sect.Attribute("name"); if (string.IsNullOrWhiteSpace(name2)) return null; var type = (string)sect.Attribute("type") ?? "gac"; var guidStr = (string)sect.Attribute("guid"); Guid guid = Guid.Empty; bool hasGuid = guidStr != null && Guid.TryParse(guidStr, out guid); if (type.Equals("file")) l.Add(DsDocumentInfo.CreateDocument(name2)); else if (type.Equals("refasm")) l.Add(new DsDocumentInfo(name2, DocumentConstants.DOCUMENTTYPE_REFASM)); else if (type.Equals("user-file") && hasGuid) l.Add(new DsDocumentInfo(name2, guid)); else // should be "gac" l.Add(DsDocumentInfo.CreateGacDocument(name2)); } return Tuple.Create(l, isDefault ?? false); } catch { Debug.Fail("Exception"); } return null; }
public DocumentList(DefaultDocumentList defaultList) { Documents = new List <DsDocumentInfo>(defaultList.Documents); Name = defaultList.Name; }