/// <summary> /// File constructor /// </summary> /// <param name="filename">The filename from which to load the reflection data set information</param> public ReflectionDataSet(string filename) : this() { this.Filename = filename; XDocument doc = XDocument.Load(filename); XElement dataSet = doc.Root; platform = dataSet.Attribute("Platform").Value; if (dataSet.Attribute("Version") == null || !Version.TryParse(dataSet.Attribute("Version").Value, out version)) { version = new Version(); } title = dataSet.Attribute("Title").Value; allSystemTypesRedirected = ((bool?)dataSet.Attribute("AllSystemTypesRedirected") ?? false); notes = (string)dataSet.Element("Notes"); foreach (var location in dataSet.Descendants("Location")) { assemblyLocations.Add(AssemblyLocation.FromXml(location)); } foreach (var ignored in dataSet.Descendants("Namespace")) { ignoredNamespaces.Add(new StringWrapper { Value = ignored.Value }); } foreach (var ignored in dataSet.Descendants("Unresolved")) { ignoredUnresolved.Add(new StringWrapper { Value = ignored.Value }); } foreach (var br in dataSet.Descendants("BindingRedirection")) { bindingRedirections.Add(BindingRedirection.FromXml(br)); } }
/// <summary> /// This is used to see if any comments files exist in a culture-specific framework location folder /// </summary> /// <param name="location">The framework location</param> /// <param name="language">The language used to check for a culture-specific folder</param> /// <returns>True if files were</returns> private static string CultureSpecificCommentsFileFolder(AssemblyLocation location, CultureInfo language) { string path = location.Path; if(language == null) return null; if(Directory.Exists(Path.Combine(path, language.Name))) path = Path.Combine(path, language.Name); else if(Directory.Exists(Path.Combine(path, language.TwoLetterISOLanguageName))) path = Path.Combine(path, language.TwoLetterISOLanguageName); else path = null; if(path != null && !location.IncludedAssemblies.Any(a => File.Exists(Path.ChangeExtension( Path.Combine(path, Path.GetFileName(a.Filename)), ".xml")))) path = null; return path; }
//===================================================================== /// <summary> /// This is used to load the settings for an assembly location from an XML element /// </summary> /// <param name="location">The XML element containing the settings</param> /// <returns>The new assembly location item</returns> /// <remarks>If the location element is empty, the assembly details will be created by scanning the /// location for assemblies.</remarks> internal static AssemblyLocation FromXml(XElement location) { AssemblyLocation al = new AssemblyLocation(location.Attribute("Path").Value); foreach(var a in location.Descendants("AssemblyDetails")) al.assemblyDetails.Add(AssemblyDetails.FromXml(al.Path, a)); return al; }