/// <summary> /// <para>Adds the content of the /doc XML file to this cache. /// Any warning or error (except ArgumentNullException and ArgumentException when fileName is null or empty) /// is logged using the referenced MBRLogger instance.</para> /// </summary> /// <param name="fileName">the filename of the /doc XML file.</param> /// <exception cref="ArgumentNullException">if fileName is null.</exception> /// <exception cref="ArgumentException">if fileName is empty.</exception> public void AddSlashDocFile(string fileName) { Helper.ValidateNotNullNotEmpty(fileName, "fileName"); try { //Load the compiler output files XmlTextReader reader = new XmlTextReader(fileName); object member = reader.NameTable.Add("member"); while (reader.Read()) { // Add all ids of nodes with name 'member' the docs HashTable if ((reader.NodeType == XmlNodeType.Element) && (reader.Name.Equals(member))) { //Get the name of the 'member' node. string id = reader.GetAttribute("name"); if (id == null) { continue; } //Get the documentation string doc = reader.ReadInnerXml().Trim(); //Log if duplicate ids are found if (docs.Contains(id)) { if (logger != null) { logger.Log(Level.WARN, "Duplicate <member> tags found with the same id = {0}.", id); } } docs[id] = doc; } } } //Ignore exceptions. Just log them. catch (Exception e) { if (logger != null) { logger.Log(Level.ERROR, "Unable to load /doc XML file {0}. Exception: {1}.", new object[] { fileName, e.ToString() }); } } }
/// <summary> /// <para>Loads an Assembly with the given fullName (fully qualified assembly name) /// from the given fileName in one of the custom paths. This methods iterates over the custom paths and /// combines the current path with the fileName to form a full path /// and use that full path to the load the assembly from. The given fullName is used to ensure that the loaded /// assembly is as desired. Any warning or error (except ArgumentNullException and ArgumentException when /// fileName is null or empty) is logged using the referenced MBRLogger instance. This method returns null if /// unable to load the assembly.</para> /// </summary> /// <param name="fileName">the name of the file to load the assembly from</param> /// <param name="fullName">the full name of the assembly to load.</param> /// <exception cref="ArgumentNullException">if any argument is null.</exception> /// <exception cref="ArgumentException">if any arugment is empty.</exception> private Assembly LoadAssemblyFromReferencePaths(string fullName, string fileName) { Helper.ValidateNotNullNotEmpty(fullName, "fullName"); Helper.ValidateNotNullNotEmpty(fileName, "fileName"); if (referencePaths == null) { return(null); } //Look for assembly in each reference path foreach (string path in referencePaths) { if (Directory.Exists(path)) { string fullPath = Path.Combine(path, fileName); if (File.Exists(fullPath)) { try { //Get the qualified name of the assembly found and compare it to the fullName AssemblyName assyName = AssemblyName.GetAssemblyName(fullPath); if (assyName.FullName == fullName) { return(LoadAssembly(fullPath)); } } //Ignore exceptions. Just log catch (Exception e) { if (logger != null) { logger.Log(Level.ERROR, "File {0} not a valid assembly.", fullPath); logger.Log(Level.ERROR, "\tException : {0}", e.ToString()); } } } } } return(null); }
public void TestLog1() { mbrLogger.Log(Level.DEBUG, "Black {0}", new object[] { "Sabbath" }); CheckForString("Black Sabbath"); }