public Lifetime CreateLifetimeThatIsBoundedByDiagram() { BoundedLifetime lifetime = new BoundedLifetime(_graphTree, this); SetOutlastsRelationship(DiagramLifetime, lifetime); return(lifetime); }
public void SetOutlastsRelationship(Lifetime outlaster, Lifetime outlasted) { BoundedLifetime boundedOutlaster = outlaster as BoundedLifetime, boundedOutlasted = outlasted as BoundedLifetime; if (boundedOutlaster == null || boundedOutlasted == null) { return; } if (IsSubtypeLifetimeOf(boundedOutlasted, boundedOutlaster)) { throw new ArgumentException("outlasted already outlasts outlaster"); } if (IsSubtypeLifetimeOf(boundedOutlaster, boundedOutlaster)) { return; } HashSet <BoundedLifetime> supertypes; if (!_lifetimeSupertypes.TryGetValue(boundedOutlaster, out supertypes)) { supertypes = new HashSet <BoundedLifetime>(); _lifetimeSupertypes[boundedOutlaster] = supertypes; } supertypes.Add(boundedOutlasted); }
public LifetimeGraphIdentifier GetBoundedLifetimeGraphIdentifier(Lifetime lifetime) { BoundedLifetime boundedLifetime = lifetime as BoundedLifetime; if (boundedLifetime == null) { return(default(LifetimeGraphIdentifier)); } return(_diagramGraphs.First(pair => pair.Value == boundedLifetime.DiagramGraph).Key); }
private bool IsSubtypeLifetimeOf(BoundedLifetime toCheck, BoundedLifetime comparison) { HashSet <BoundedLifetime> supertypes; if (!_lifetimeSupertypes.TryGetValue(toCheck, out supertypes)) { return(false); } if (supertypes.Contains(comparison)) { return(true); } return(supertypes.Any(supertype => IsSubtypeLifetimeOf(supertype, comparison))); }
private bool DoesLifetimeOutlastLifetimeGraph(BoundedLifetime boundedLifetime, LifetimeGraphIdentifier graphIdentifier) { BoundedLifetimeGraph boundedLifetimeGraph = boundedLifetime.DiagramGraph; BoundedLifetimeGraph diagramGraph = _diagramGraphs[graphIdentifier]; if (boundedLifetimeGraph == diagramGraph) { return(boundedLifetimeGraph.DoesOutlast(boundedLifetime, boundedLifetimeGraph.DiagramLifetime)); } else { LifetimeGraphIdentifier currentGraphIdentifier = graphIdentifier, parentGraphIdentifier; while (_graphParents.TryGetValue(currentGraphIdentifier, out parentGraphIdentifier)) { diagramGraph = _diagramGraphs[currentGraphIdentifier]; if (diagramGraph == boundedLifetimeGraph) { return(true); } currentGraphIdentifier = parentGraphIdentifier; } return(false); } }
public BoundedLifetimeGraph(LifetimeGraphTree graphTree) { _graphTree = graphTree; DiagramLifetime = new BoundedLifetime(_graphTree, this); }