public string RenderToFile([CanBeNull] string assemblyName, [CanBeNull] string rendererClassName, [CanBeNull] string rendererOptions, [NotNull] WriteTarget target) { if (Option.IsHelpOption(rendererOptions)) { ShowDetailedHelp <ITransformer>(assemblyName, rendererClassName, ""); return(null); } else { try { IRenderer renderer = GetOrCreatePlugin <IRenderer>(assemblyName, rendererClassName); string masterFileName = renderer.GetMasterFileName(this, rendererOptions, target).FullFileName; if (WorkLazily && File.Exists(masterFileName)) { // we dont do anything - TODO check change dates of input files vs. the master file's last update date } else { RestartAbortWatchDog(); renderer.Render(this, CurrentGraph.VisibleDependencies, rendererOptions ?? "", target, IgnoreCase); } SomethingDone = true; return(masterFileName); } finally { StopAbortWatchDog(); } } }
public string RenderTestData([CanBeNull] string assemblyName, [CanBeNull] string rendererClassName, string rendererOptions, [NotNull] WriteTarget target) { IRenderer renderer = GetOrCreatePlugin <IRenderer>(assemblyName, rendererClassName); IEnumerable <Dependency> dependencies = renderer.CreateSomeTestDependencies(CurrentGraph); renderer.Render(this, dependencies, rendererOptions, target, IgnoreCase); SomethingDone = true; return(renderer.GetMasterFileName(this, rendererOptions, target).FullFileName); }
public void LogAboutNDependencies(int maxCount, [CanBeNull] string pattern, [NotNull] WriteTarget target) { IEnumerable <Dependency> matchingDependencies = LogOnlyDependencyCount(pattern); int n = target.IsConsoleOut ? maxCount : int.MaxValue / 2; using (var tw = target.CreateWriter()) { foreach (var d in matchingDependencies.Take(n)) { tw.WriteLine(d.AsLimitableStringWithTypes(false, threeLines: true)); } if (matchingDependencies.Skip(n).Any()) { tw.WriteLine("..."); } } SomethingDone = true; }
// TODO: ---> Option ????????????? or WriteTarget????????? public static WriteTarget CreateFullFileName(WriteTarget target, string extension) { if (target == null || target.IsConsoleOut) { return(new WriteTarget(null, true, limitLinesForConsole: 100)); } else { if (extension != null) { return(new WriteTarget(Path.ChangeExtension(target.FullFileName, extension), target.Append, limitLinesForConsole: 100)); } else { return(new WriteTarget(Path.GetFullPath(target.FileName), target.Append, limitLinesForConsole: 100)); } } }
public void LogAboutNItems(int maxCount, [CanBeNull] string pattern, [NotNull] WriteTarget target) { List <Item> matchingItems = LogOnlyItemCount(pattern).ToList(); int n = target.IsConsoleOut ? maxCount : int.MaxValue / 2; matchingItems.Sort((i1, i2) => string.Compare(i1.Name, i2.Name, IgnoreCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture)); using (var tw = target.CreateWriter()) { foreach (var i in matchingItems.Take(n)) { tw.WriteLine(i.AsFullString()); } if (matchingItems.Skip(n).Any()) { tw.WriteLine("..."); } } SomethingDone = true; }
public InnerTargetWriter(WriteTarget parent, bool logToConsoleInfo, int limitLinesForConsole) { _parent = parent; if (!parent.IsConsoleOut) { _limitLines = int.MaxValue; Log.WriteInfo($"... writing to {parent.FullFileName}"); _sw = new StreamWriter(new FileStream(parent.FullFileName, parent.Append ? FileMode.Append : FileMode.Create)); } else { _limitLines = limitLinesForConsole; if (logToConsoleInfo) { Log.WriteInfo("... writing to console"); } _sw = Console.Out; } }
public void Render([NotNull] GlobalContext globalContext, [NotNull, ItemNotNull] IEnumerable <Dependency> dependencies, [NotNull] string options, [NotNull] WriteTarget target, bool ignoreCase) { Render(globalContext, dependencies, CreateRenderOptions(globalContext, options), target, ignoreCase); }
public abstract WriteTarget GetMasterFileName(GlobalContext globalContext, TRenderOptions options, WriteTarget baseTarget);
public WriteTarget GetMasterFileName(GlobalContext globalContext, string optionsString, WriteTarget baseTarget) { return(GetMasterFileName(globalContext, CreateRenderOptions(globalContext, optionsString), baseTarget)); }
public abstract void Render([NotNull] GlobalContext globalContext, [NotNull, ItemNotNull] IEnumerable <Dependency> dependencies, TRenderOptions options, [NotNull] WriteTarget target, bool ignoreCase);