Exemplo n.º 1
0
 static Tuple <DefaultFileList, 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 DefaultFileList(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(DnSpyFileInfo.CreateFile(name2));
             }
             else if (type.Equals("refasm"))
             {
                 l.Add(new DnSpyFileInfo(name2, FileConstants.FILETYPE_REFASM));
             }
             else if (type.Equals("user-file") && hasGuid)
             {
                 l.Add(new DnSpyFileInfo(name2, guid));
             }
             else                     // should be "gac"
             {
                 l.Add(DnSpyFileInfo.CreateGacFile(name2));
             }
         }
         return(Tuple.Create(l, isDefault ?? false));
     }
     catch {
         Debug.Fail("Exception");
     }
     return(null);
 }
Exemplo n.º 2
0
 static Tuple <DefaultFileList, 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 DefaultFileList(name);
         foreach (var sect in root.Elements("File"))
         {
             var asmFullName = (string)sect.Attribute("name");
             if (string.IsNullOrWhiteSpace(asmFullName))
             {
                 return(null);
             }
             l.Add(DnSpyFileInfo.CreateGacFile(asmFullName));
         }
         return(Tuple.Create(l, isDefault ?? false));
     }
     catch {
         Debug.Fail("Exception");
     }
     return(null);
 }
Exemplo n.º 3
0
 static Tuple<DefaultFileList, 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 DefaultFileList(name);
         foreach (var sect in root.Elements("File")) {
             var asmFullName = (string)sect.Attribute("name");
             if (string.IsNullOrWhiteSpace(asmFullName))
                 return null;
             l.Add(DnSpyFileInfo.CreateGacFile(asmFullName));
         }
         return Tuple.Create(l, isDefault ?? false);
     }
     catch {
         Debug.Fail("Exception");
     }
     return null;
 }
Exemplo n.º 4
0
		static Tuple<DefaultFileList, 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 DefaultFileList(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(DnSpyFileInfo.CreateFile(name2));
					else if (type.Equals("refasm"))
						l.Add(new DnSpyFileInfo(name2, FileConstants.FILETYPE_REFASM));
					else if (type.Equals("user-file") && hasGuid)
						l.Add(new DnSpyFileInfo(name2, guid));
					else // should be "gac"
						l.Add(DnSpyFileInfo.CreateGacFile(name2));
				}
				return Tuple.Create(l, isDefault ?? false);
			}
			catch {
				Debug.Fail("Exception");
			}
			return null;
		}