public NewHostCommandStub(MiniLogger logger) { _debug = false; _logger = logger; _currentProcessLevel = VstProcessLevels.User; }
void addArgument(string key, string value) { if (!this.arguments.ContainsKey(key)) { if (verbose) { MiniLogger.log("Adding " + key + " = " + value); } arguments.Add(key, value); } else { if (overwrite) { if (verbose) { MiniLogger.log("Replacing old value of " + key + " from " + arguments[key] + " to " + value); } arguments[key] = value; //arguments.Add(key, value); } else { MiniLogger.log( MethodBase.GetCurrentMethod(), "duplicate value for key: " + key + " [prev=" + arguments[key] + "], new value=" + value); } } }
public static void Main(string[] args) { int exitCode = 0; XTArgs xtargs = new XTArgs(args); try { if (string.IsNullOrEmpty(xtargs.inputFile)) { Console.Error.WriteLine("missing input-file"); showUsage(1); //throw new ApplicationException("input-file is empty!"); } if (string.IsNullOrEmpty(xtargs.transformFile)) { Console.Error.WriteLine("missing transformation-file"); showUsage(1); //throw new ApplicationException("transformationb-file is empty!"); } exitCode = processArgs(xtargs); } catch (ApplicationException ae) { MiniLogger.log(MethodBase.GetCurrentMethod(), ae); } catch (Exception ex) { MiniLogger.log(MethodBase.GetCurrentMethod(), ex); } Environment.Exit(exitCode); }
public TaskContextMock(MiniLogger logger) { if (logger == null) { logger = new MiniLogger(); } m_logger = logger; }
public void Init() { _imageFromCacheService = Substitute.For <IImageFromCacheService>(); _imageFromWebCamService = Substitute.For <IImageFromWebCamService>(); _dateTimeProvider = Substitute.For <IDateTimeProvider>(); _logger = null; _cacheUpdater = new CacheUpdaterInfo(); _cacheUpdaterExpirationMilliSec = 600; }
void foundUnknownNode(Object sender, XmlNodeEventArgs e) { if (e.ObjectBeingDeserialized != null) { MiniLogger.log(MethodBase.GetCurrentMethod(), "unhandled element: " + e.Name + " with parent " + e.ObjectBeingDeserialized.GetType().Name); } else { MiniLogger.log(MethodBase.GetCurrentMethod(), "unknown node: " + e.Name); } }
void foundUnknownElement(Object sender, XmlElementEventArgs e) { if (e.ObjectBeingDeserialized != null) { MiniLogger.log(MethodBase.GetCurrentMethod(), e.ObjectBeingDeserialized.GetType().Name + " has child: " + e.Element.Name); } else { MiniLogger.log(MethodBase.GetCurrentMethod(), "node " + e.Element.Name + " expecting " + e.ExpectedElements); } }
public void WhenConfiguredWithTestLevelDisplayOnlyErrors() { var mockUIOut = new Mock <ILoggerOut>(); var miniLogger = new MiniLogger( new LogConfig("test"), new [] { mockUIOut.Object }, _mockDateTime.Object ); const string testMsgOne = "Message 1"; const string testMsgTwo = "Message 2"; const string testMsgThree = "Message 3"; miniLogger.Error(testMsgOne); miniLogger.Info(testMsgTwo); miniLogger.Warning(testMsgThree); mockUIOut.Verify(ui => ui.Out(testMsgOne, 0, _testTime)); mockUIOut.Verify(ui => ui.Out(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <DateTime>()), Times.Once); }
public static void Main(string[] args) { int exitCode = 0; bool errorFound = false; //RMArgs xtargs = new RMArgs(args); RMArgs xtargs; XmlWriter xw = null; TextWriterTraceListener twtl = null; StringBuilder sb; #if TRACE Trace.AutoFlush = true; twtl = new TextWriterTraceListener(Console.Out, LISTENER_NAME); Trace.Listeners.Add(twtl); #endif xtargs = new RMArgs(args); if (args.Length < 1) { Console.Error.WriteLine("no args"); showUsage(Console.Out); exitCode = 3; } else { if (xtargs.showHelp) { Console.Error.WriteLine("help requested"); showUsage(Console.Out); } else { if (string.IsNullOrEmpty(xtargs.inputFile)) { errorFound |= true; Console.Error.WriteLine("input-file not specified."); exitCode = 3; } if (errorFound) { showUsage(Console.Error); } else { sb = new StringBuilder(); xw = XmlWriter.Create(sb, settings); //xw=XmlWriter.Create() if (string.IsNullOrEmpty(xtargs.outputFile)) { settings.CloseOutput = false; //xw = XmlWriter.Create(Console.Out, settings); } //else { // ////settings.CloseOutput = true; // //xw = XmlWriter.Create(xtargs.outputFile, settings); //} try { writePackage(xw, xtargs); xw.Flush(); if (!string.IsNullOrEmpty(xtargs.outputFile)) { File.WriteAllText(xtargs.outputFile, sb.ToString()); } else { Console.Out.WriteLine(sb.ToString()); } if (xtargs.verbose) { Trace.WriteLine("[VERBOSE] " + "wrote output to " + (string.IsNullOrEmpty(xtargs.outputFile) ? "<stdout>" : xtargs.outputFile)); } ; } catch (Exception ex) { MiniLogger.log(MethodBase.GetCurrentMethod(), ex); exitCode = 1; } finally { if (xw != null) { xw.Close(); xw.Dispose(); xw = null; } } } } //KC Trace.WriteLine("here"); } #if TRACE if (twtl != null) { Trace.Flush(); Trace.Listeners.Remove(LISTENER_NAME); } #endif Environment.Exit(exitCode); }
void foundUnknownAttribute(Object sender, XmlAttributeEventArgs e) { MiniLogger.log(MethodBase.GetCurrentMethod(), e.ToString()); }
void Xrs_ValidationEventHandler(Object sender, ValidationEventArgs e) { MiniLogger.log(MethodBase.GetCurrentMethod(), e.ToString()); }
void foundUnrefObject(Object sender, UnreferencedObjectEventArgs e) { MiniLogger.log(MethodBase.GetCurrentMethod(), e.ToString()); }
static int processArgs(XTArgs args) { int ret = 0; XslCompiledTransform t; XsltArgumentList argsList; try { t = new XslCompiledTransform(true); argsList = new XsltArgumentList(); foreach (string akey in args.arguments.Keys) { argsList.AddParam(akey, string.Empty, args.arguments[akey]); } if (args.verbose) { MiniLogger.log("[VERBOSE] " + "using transform: " + args.transformFile); } t.Load(args.transformFile); if (args.verbose) { MiniLogger.log("[VERBOSE] " + "transforming " + args.inputFile); } XmlWriter xw = null; if (string.IsNullOrEmpty(args.outputFile)) { settings.CloseOutput = false; settings.ConformanceLevel = ConformanceLevel.Auto; xw = XmlWriter.Create(Console.Out, settings); } else { xw = XmlWriter.Create(args.outputFile, settings); } if (xw != null) { t.Transform(args.inputFile, argsList, xw); xw.Close(); xw.Dispose(); xw = null; } if (args.verbose) { if (string.IsNullOrEmpty(args.outputFile)) { Console.Out.WriteLine(); } MiniLogger.log("[VERBOSE] " + "transformed into :" + (string.IsNullOrEmpty(args.outputFile) ? "<stdout>" : args.outputFile)); } } catch (XmlException xe) { ret = 1; throw new ApplicationException("XML Exception ", xe); } catch (DirectoryNotFoundException dnfe) { ret = 1; throw new ApplicationException("Directory not found", dnfe); } catch (Exception ex) { MiniLogger.log(MethodBase.GetCurrentMethod(), ex); ret = 1; } return(ret); }
public static void Main(string[] args) { int exitCode = 0; //string err, anArg, desc = null, relNotes = null; TesterClass tc; NugetPackage pkg; CmdLineArgs ca; //bool doDefault = false, needsSave = false; bool needsSave = false, otherSave; int nargs; List<string> files; string err; if ((nargs = args.Length) < 1) { Console.Error.WriteLine("no args"); exitCode = 1; } else { try { ca = new CmdLineArgs(typeof(NugetMetadata)); files = ca.parseCmdlineArgs(args); if (ca.showHelp) { ca.showHelpMessage(Console.Error); //Console.Error.WriteLine("no args"); exitCode = 1; } else { if (files.Count < 1) { Console.Error.WriteLine("no args"); exitCode = 1; } else { tc = new TesterClass(); foreach (string aFile in files) { if ((pkg = tc.readPackage(aFile)) != null) { if (ca.doDefault) { pkg.resetValues(); needsSave = true; } otherSave = ca.applyChanges(pkg); //nnedspkg.applyChanges(ca); } if (needsSave) { //tc.savePackage(aFile, pkg); tc.savePackage( Path.Combine( Path.GetDirectoryName(aFile), Path.GetFileNameWithoutExtension(aFile) + ".fix" + Path.GetExtension(aFile)), pkg); } } } } } catch (Exception ex) { err = MiniLogger.decompose(ex); Console.Error.WriteLine(err); Trace.WriteLine(err); exitCode = 2; } } Environment.Exit(exitCode); }
internal RMArgs(string[] args) { int i = 0, n = args == null?0:args.Length, arglen; string arg; char achar; FileVersionInfo fvi; while (i < n) { arg = args[i]; arglen = arg.Length; if (arg[0] == '-' || arg[0] == '/') { if (arglen >= 2) { switch (achar = arg[1]) { case 'o': // outputfile if (arglen > 2) { outputFile = arg.Substring(2); } else { this.outputFile = args[++i]; } if (verbose) { Trace.WriteLine("[VERBOSE] " + "outfile: " + this.outputFile); } break; case 'v': verbose = true; break; case '?': case 'h': this.showHelp = true; break; default: Console.Error.WriteLine("unknown flag:" + achar); break; } } else { MiniLogger.log(MethodBase.GetCurrentMethod(), "short version"); } } else { this.inputFile = args[i]; if (this.verbose && !string.IsNullOrEmpty(this.inputFile)) { Trace.WriteLine("[VERBOSE] " + "inputFile: " + this.inputFile); } if (File.Exists(this.inputFile)) { if (this.verbose) { Trace.WriteLine("[VERBOSE] " + "processing: " + this.inputFile); } fvi = FileVersionInfo.GetVersionInfo(this.inputFile); //Version fileVersion, productVersion; description = fvi.Comments; // AssemblyDescription if (verbose && !string.IsNullOrEmpty(description)) { Trace.WriteLine("[VERBOSE] " + "description: " + description); } if (string.IsNullOrEmpty(fvi.FileVersion)) { throw new ApplicationException("file-version is null!"); } else { fileVersion = new Version(fvi.ProductVersion); } if (string.IsNullOrEmpty(fvi.ProductVersion)) { throw new ApplicationException("product-version is null!"); } else { productVersion = new Version(fvi.ProductVersion); } copyright = fvi.LegalCopyright; // AssemblyCopyright if (verbose && !string.IsNullOrEmpty(copyright)) { Trace.WriteLine("[VERBOSE] " + "copyright: " + copyright); } company = fvi.CompanyName; // AssemblyCompany if (verbose && !string.IsNullOrEmpty(company)) { Trace.WriteLine("[VERBOSE] " + "company: " + company); } fileDescription = fvi.FileDescription; // AssemblyTitle if (verbose && !string.IsNullOrEmpty(fileDescription)) { Trace.WriteLine("[VERBOSE] " + "fileDescription: " + fileDescription); } product = fvi.ProductName; // AssemblyProduct if (verbose && !string.IsNullOrEmpty(product)) { Trace.WriteLine("[VERBOSE] " + "product: " + product); } } } i++; } }
internal XTArgs(string[] args) { int i, n, arglen; string arg, argValues, filename, value; char achar; FileVersionInfo fvi; arguments = new Dictionary <string, string>(); n = args.Length; i = 0; while (i < n) { arg = args[i]; arglen = arg.Length; if (arg[0] == '-' || arg[0] == '/') { if (arglen >= 2) { switch (achar = arg[1]) { case 'a': // xslt arguments if (arglen > 2) { argValues = arg.Substring(2); } else { argValues = args[++i]; } if (!string.IsNullOrEmpty(argValues)) { parseXsltArguments(argValues); } break; case 'f': // file if (arglen > 2) { filename = arg.Substring(2); } else { filename = args[++i]; } if (!File.Exists(filename)) { throw new ApplicationException("Invalid assembly specified."); } if (!string.IsNullOrEmpty(filename)) { fvi = FileVersionInfo.GetVersionInfo(filename); MiniLogger.log(MethodBase.GetCurrentMethod()); if (!string.IsNullOrEmpty(value = fvi.ProductName)) { addArgument("idValue", value); } if (!string.IsNullOrEmpty(value = fvi.FileDescription)) { addArgument("descValue", value); } if (!string.IsNullOrEmpty(value = fvi.FileVersion)) { addArgument("versionValue", value); } if (!string.IsNullOrEmpty(value = fvi.CompanyName)) { addArgument("authorsValue", value); } } break; case 'O': this.overwrite = true; break; case 'o': // outputfile if (arglen > 2) { outputFile = arg.Substring(2); } else { this.outputFile = args[++i]; } break; case 'v': verbose = true; break; case 'x': if (arglen > 2) { transformFile = arg.Substring(2); i++; } else { transformFile = args[++i]; } break; default: Console.Error.WriteLine("unknown flag:" + achar); break; } } else { MiniLogger.log(MethodBase.GetCurrentMethod(), "short version"); } } else { this.inputFile = args[i]; } i++; } }