Ejemplo n.º 1
0
        public int Transform([CanBeNull] string assemblyName, [NotNull] string transformerClass,
                             [CanBeNull] string transformerOptions, ref int maxNumberOfNewImplicitGraphs)
        {
            if (Option.IsHelpOption(transformerOptions))
            {
                ShowDetailedHelp <ITransformer>(assemblyName, transformerClass, "");
                return(Program.OPTIONS_PROBLEM);
            }
            else
            {
                try {
                    ITransformer transformer = GetOrCreatePlugin <ITransformer>(assemblyName, transformerClass);
                    Log.WriteInfo($"Transforming with {assemblyName}.{transformerClass}");

                    RestartAbortWatchDog();

                    var workingGraphsAtStartOfTransform = new List <WorkingGraph>(_workingGraphs);

                    if (maxNumberOfNewImplicitGraphs > 0 && _autoGraphsForTransform > 0)
                    {
                        CreateWorkingGraph(CurrentGraph.StickyId + "->" + transformerClass, GraphCreationType.AutoTransform, Clone(CurrentGraph.VisibleDependencies));
                        RemoveSuperfluousGraphs(_autoGraphsForTransform, GraphCreationType.AutoTransform);
                        maxNumberOfNewImplicitGraphs--;
                    }

                    var newDependenciesCollector = new List <Dependency>();
                    int result = transformer.Transform(this, CurrentGraph.VisibleDependencies, transformerOptions, newDependenciesCollector,
                                                       s => FindDependenciesInFirstGraphMatchingName(s, workingGraphsAtStartOfTransform));

                    if (newDependenciesCollector.Contains(null))
                    {
                        throw new ArgumentNullException(nameof(newDependenciesCollector), "Contains null item");
                    }

                    CurrentGraph.ReplaceVisibleDependencies(newDependenciesCollector);

                    Log.WriteInfo($"... now {CurrentGraph.DependencyCount} dependencies");

                    SomethingDone = true;
                    return(result);
                } catch (Exception ex) {
                    Log.WriteError(
                        $"Error while transforming with '{transformerClass}': {ex.GetType().Name} - {ex.Message}");
                    return(Program.EXCEPTION_RESULT);
                } finally {
                    StopAbortWatchDog();
                }
            }
        }
Ejemplo n.º 2
0
        public void TransformTestData(string assemblyName, string transformerClass, string transformerOptions)
        {
            ITransformer transformer = GetOrCreatePlugin <ITransformer>(assemblyName, transformerClass);
            var          workingGraphsAtStartOfTransform = new List <WorkingGraph>(_workingGraphs);

            CreateWorkingGraph(transformerClass + ".TestDependencies", GraphCreationType.AutoTransform,
                               transformer.CreateSomeTestDependencies(CurrentGraph));

            var newDependenciesCollector = new List <Dependency>();

            transformer.Transform(this, CurrentGraph.VisibleDependencies, transformerOptions, newDependenciesCollector,
                                  s => FindDependenciesInFirstGraphMatchingName(s, workingGraphsAtStartOfTransform));

            CurrentGraph.ReplaceVisibleDependencies(newDependenciesCollector);

            SomethingDone = true;
        }