Пример #1
0
        private void ValidateTransitions()
        {
            using (new UndoRedo.DontLogBlock(Controller))
            {
                //  First, mark all the transitions for potential removal

                foreach (Transition groupTransition in TransitionsFrom.Where(t => t.TransitionType == Transition.TransitionTypes.Group))
                {
                    groupTransition.IsValid = false;
                }
                foreach (Transition groupTransition in TransitionsTo.Where(t => t.TransitionType == Transition.TransitionTypes.Group))
                {
                    groupTransition.IsValid = false;
                }

                //  Now figure what transitions we actually need

                if (Members != null)
                {
                    foreach (ObjectModel.ITransitionEndpoint endpoint in Members.Where(m => m.LayerPositions.Any(lp => lp.Layer == Layer && lp.GroupStatus == LayerPosition.GroupStatuses.Explicit)))
                    {
                        AddTransitionsForEndpoint(endpoint);
                    }
                }

                //  And finally, get rid of those not needed

                DeleteInvalidTransitions(TransitionsFrom);
                DeleteInvalidTransitions(TransitionsTo);
            }
            System.Threading.Interlocked.Exchange(ref ValidationPendingCount, 0);
        }
Пример #2
0
 private void AddTransitionsForEndpoint(ObjectModel.ITransitionEndpoint endpoint)
 {
     endpoint.TransitionsFrom.CollectionChanged += MemberTransitionsCollectionChangedHandler;
     foreach (ObjectModel.ITransition transition in endpoint.TransitionsFrom)
     {
         if (transition.SourceState != null && transition.DestinationState != null)
         {
             ObjectModel.LayerPosition layerPosition = transition.DestinationState.LayerPositions.Where(lp => lp.Layer == Layer).FirstOrDefault();
             if (Members.Contains(transition.SourceState) &&
                 this != transition.DestinationState &&
                 (layerPosition == null || layerPosition.GroupStatus != LayerPosition.GroupStatuses.Explicit))
             {
                 Transition groupTransition = TransitionsFrom.FirstOrDefault(t => t.SourceState == this && t.DestinationState == transition.DestinationState && t.TriggerEvent == transition.TriggerEvent) as Transition;
                 if (groupTransition == null)
                 {
                     groupTransition = new Transition(Controller, this, transition.DestinationState, transition.TriggerEvent);
                     MembershipChanged?.Invoke(this, new MembershipChangeArgument(MembershipChangeAction.AddTransition, groupTransition));
                 }
                 groupTransition.IsValid = true;
             }
         }
     }
     endpoint.TransitionsTo.CollectionChanged += MemberTransitionsCollectionChangedHandler;
     foreach (ObjectModel.ITransition transition in endpoint.TransitionsTo)
     {
         if (transition.SourceState != null && transition.DestinationState != null)
         {
             ObjectModel.LayerPosition layerPosition = transition.SourceState.LayerPositions.Where(lp => lp.Layer == Layer).FirstOrDefault();
             if (Members.Contains(transition.DestinationState) &&
                 this != transition.SourceState &&
                 (layerPosition == null || layerPosition.GroupStatus != LayerPosition.GroupStatuses.Explicit))
             {
                 Transition groupTransition = TransitionsTo.FirstOrDefault(t => t.SourceState == transition.SourceState && t.DestinationState == this && t.TriggerEvent == transition.TriggerEvent) as Transition;
                 if (groupTransition == null)
                 {
                     groupTransition = new Transition(Controller, transition.SourceState, this, transition.TriggerEvent);
                     MembershipChanged?.Invoke(this, new MembershipChangeArgument(MembershipChangeAction.AddTransition, groupTransition));
                 }
                 groupTransition.IsValid = true;
             }
         }
     }
 }