示例#1
0
        public void RunCompile()
        {
            lock (m_Lock)
            {
                UpdateActivitiesTargetResourceDependencies();

                var availableResources = new List <IResource <int> >();
                if (!ResourceSettings.AreDisabled)
                {
                    availableResources.AddRange(m_Mapper.Map <IEnumerable <ResourceModel>, IEnumerable <Resource <int> > >(ResourceSettings.Resources));
                }

                GraphCompilation = m_VertexGraphCompiler.Compile(availableResources);

                Duration = m_VertexGraphCompiler.Duration;

                UpdateActivitiesAllocatedToResources();

                CalculateResourceSeriesSet();

                SetCompilationOutput();

                CalculateCosts();

                IsProjectUpdated = true;

                // Cyclomatic complexity is calculated against the vertex graph without resource dependencies.
                CyclomaticComplexity = null;

                if (!HasCompilationErrors)
                {
                    IList <IDependentActivity <int, int> > dependentActivities =
                        GraphCompilation.DependentActivities
                        .Select(x => (IDependentActivity <int, int>)x.CloneObject())
                        .ToList();

                    if (dependentActivities.Any())
                    {
                        var vertexGraphCompiler = new VertexGraphCompiler <int, int, IDependentActivity <int, int> >();
                        foreach (DependentActivity <int, int> dependentActivity in dependentActivities)
                        {
                            dependentActivity.ResourceDependencies.Clear();
                            vertexGraphCompiler.AddActivity(dependentActivity);
                        }

                        vertexGraphCompiler.TransitiveReduction();
                        CyclomaticComplexity = vertexGraphCompiler.CyclomaticComplexity;
                    }
                }

                HasStaleOutputs = false;
            }

            PublishGraphCompiledPayload();
            PublishGraphCompilationUpdatedPayload();
        }
示例#2
0
 public void RunTransitiveReduction()
 {
     lock (m_Lock)
     {
         UpdateActivitiesTargetResourceDependencies();
         m_VertexGraphCompiler.Compile(new List <IResource <int> >());
         m_VertexGraphCompiler.TransitiveReduction();
         RunCompile();
     }
 }
示例#3
0
        public int RunCalculateResourcedCyclomaticComplexity()
        {
            lock (m_Lock)
            {
                int resourcedCyclomaticComplexity = 0;

                // Cyclomatic complexity is calculated against the transitively reduced
                // vertex graph, where resource dependencies are taken into account along
                // with regular dependencies.
                if (GraphCompilation != null &&
                    !HasCompilationErrors &&
                    !HasStaleOutputs &&
                    !ResourceSettings.AreDisabled)
                {
                    IList <IDependentActivity <int, int> > dependentActivities =
                        GraphCompilation.DependentActivities
                        .Select(x => (IDependentActivity <int, int>)x.CloneObject())
                        .ToList();

                    if (dependentActivities.Any())
                    {
                        var vertexGraphCompiler = new VertexGraphCompiler <int, int, IDependentActivity <int, int> >();
                        foreach (DependentActivity <int, int> dependentActivity in dependentActivities)
                        {
                            dependentActivity.Dependencies.UnionWith(dependentActivity.ResourceDependencies);
                            dependentActivity.ResourceDependencies.Clear();
                            vertexGraphCompiler.AddActivity(dependentActivity);
                        }

                        vertexGraphCompiler.TransitiveReduction();
                        resourcedCyclomaticComplexity = vertexGraphCompiler.CyclomaticComplexity;
                    }
                }

                return(resourcedCyclomaticComplexity);
            }
        }