示例#1
0
 public static FlowEdge Create(DependencyFlowEdge other)
 {
     return(new FlowEdge(
                other.To.Id,
                other.From.Id,
                other.OnLongestBuildPath,
                other.BackEdge));
 }
示例#2
0
 public static FlowEdge Create(DependencyFlowEdge other)
 {
     return(new FlowEdge(
                other.To.Id,
                other.From.Id,
                other.Subscription.Id,
                other.OnLongestBuildPath,
                other.IsToolingOnly,
                other.PartOfCycle,
                other.BackEdge));
 }
 /// <summary>
 ///     If pruning the graph is desired, determine whether an edge is interesting
 /// </summary>
 /// <param name="edge">Edge</param>
 /// <returns>True if the edge is interesting, false otherwise.</returns>
 private bool IsInterestingEdge(DependencyFlowEdge edge)
 {
     if (!_options.IncludeDisabledSubscriptions && !edge.Subscription.Enabled)
     {
         return false;
     }
     if (!_options.IncludedFrequencies.Any(s => s.Equals(edge.Subscription.Policy.UpdateFrequency.ToString(), StringComparison.OrdinalIgnoreCase)))
     {
         return false;
     }
     return true;
 }
 /// <summary>
 ///     Get an edge style
 /// </summary>
 /// <param name="edge"></param>
 /// <returns></returns>
 private string GetEdgeStyle(DependencyFlowEdge edge)
 {
     switch (edge.Subscription.Policy.UpdateFrequency)
     {
         case UpdateFrequency.EveryBuild:
             // Solid
             return "style=bold";
         case UpdateFrequency.EveryDay:
             return "style=dashed";
         case UpdateFrequency.None:
             return "style=dotted";
         default:
             throw new NotImplementedException("Unknown update frequency");
     }
 }
        /// <summary>
        ///     Get an edge style
        /// </summary>
        /// <param name="edge"></param>
        /// <returns></returns>
        private string GetEdgeStyle(DependencyFlowEdge edge)
        {
            string color = edge.OnLongestBuildPath ? "color=\"red:invis:red\"" : "";

            switch (edge.Subscription.Policy.UpdateFrequency)
            {
            case UpdateFrequency.EveryBuild:
                // Solid
                return($"{color} style=bold");

            case UpdateFrequency.EveryDay:
            case UpdateFrequency.TwiceDaily:
            case UpdateFrequency.EveryWeek:
                return($"{color} style=dashed");

            case UpdateFrequency.None:
                return($"{color} style=dotted");

            default:
                throw new NotImplementedException("Unknown update frequency");
            }
        }
        private DependencyFlowEdge AddEdge(
            DependencyFlowNode fromNode,
            double worstCasePathTime,
            double bestCasePathTime,
            double prBuildTime,
            bool isToolingOnlyEdge)
        {
            var toNode = new DependencyFlowNode("test", "test", Guid.NewGuid().ToString())
            {
                BestCasePathTime  = bestCasePathTime,
                PrBuildTime       = prBuildTime,
                WorstCasePathTime = worstCasePathTime,
            };

            var subscription = new Subscription(Guid.NewGuid(), true, "source", "target", "test");

            subscription.LastAppliedBuild = new Build(
                id: 1,
                dateProduced: DateTimeOffset.Now,
                staleness: 0,
                released: false,
                stable: true,
                commit: "7a7e5c82abd287262a6efaf29902bb84a7bd81af",
                channels: ImmutableList <Channel> .Empty,
                assets: ImmutableList <Asset> .Empty,
                dependencies: new List <BuildRef>
            {
                new BuildRef(buildId: 1, isProduct: !isToolingOnlyEdge, timeToInclusionInMinutes: 1)
            }.ToImmutableList(),
                incoherencies: ImmutableList <BuildIncoherence> .Empty);

            var edge = new DependencyFlowEdge(fromNode, toNode, subscription)
            {
                IsToolingOnly = isToolingOnlyEdge
            };

            fromNode.OutgoingEdges.Add(edge);
            return(edge);
        }