示例#1
0
            public Lifetime CreateLifetimeThatIsBoundedByDiagram()
            {
                BoundedLifetime lifetime = new BoundedLifetime(_graphTree, this);

                SetOutlastsRelationship(DiagramLifetime, lifetime);
                return(lifetime);
            }
示例#2
0
            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);
            }
示例#3
0
        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);
        }
示例#4
0
            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)));
            }
示例#5
0
        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);
            }
        }
示例#6
0
 public BoundedLifetimeGraph(LifetimeGraphTree graphTree)
 {
     _graphTree      = graphTree;
     DiagramLifetime = new BoundedLifetime(_graphTree, this);
 }