Пример #1
0
        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();
                }
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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;
        }
Пример #4
0
 // 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));
         }
     }
 }
Пример #5
0
        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;
        }
Пример #6
0
            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;
                }
            }
Пример #7
0
 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);
 }
Пример #8
0
 public abstract WriteTarget GetMasterFileName(GlobalContext globalContext, TRenderOptions options,
                                               WriteTarget baseTarget);
Пример #9
0
 public WriteTarget GetMasterFileName(GlobalContext globalContext, string optionsString, WriteTarget baseTarget)
 {
     return(GetMasterFileName(globalContext, CreateRenderOptions(globalContext, optionsString), baseTarget));
 }
Пример #10
0
 public abstract void Render([NotNull] GlobalContext globalContext,
                             [NotNull, ItemNotNull] IEnumerable <Dependency> dependencies,
                             TRenderOptions options, [NotNull] WriteTarget target, bool ignoreCase);