예제 #1
0
 internal void AddInboundTransition(Transition transition)
 {
     inboundTransitions[transition.Name] = transition;
 }
예제 #2
0
 internal void AddOutboundTransition(Transition transition)
 {
     outboundTransitions[transition.Name] = transition;
 }
        /// <summary>
        /// Adds a transition between two children of the <see cref="CompositeActor"/>.
        /// </summary>
        /// <param name="transition"><see cref="Transition"/> to be added.</param>
        /// <exception cref="ArgumentException">Source or target child names are not registered on the <see cref="CompositeActor"/>.</exception>
        /// <exception cref="ArgumentException">Target child name has not a vale.</exception>
        /// <exception cref="ArgumentException">A transition with the same name was already added.</exception>
        public CompositeActorProps AddTransition(Transition transition)
        {
            if (!string.IsNullOrEmpty(transition.Source) && !children.ContainsKey(transition.Source))
                throw new ArgumentException(string.Format("There is not a registered child with name \"{0}\".", transition.Source), "transition");

            if (string.IsNullOrEmpty(transition.Destination))
                throw new ArgumentException("Target child name must have a value.", "transition");

            if (!children.ContainsKey(transition.Destination))
                throw new ArgumentException(string.Format("There is not a registered child with name \"{0}\".", transition.Destination), "transition");

            if (transitions.ContainsKey(transition.Name))
                throw new ArgumentException(string.Format("A transition with name \"{0}\" was already added.", transition.Name), "transition");

            if (!actorTransitions.ContainsKey(transition.Source))
                actorTransitions[transition.Source] = new List<Transition>();

            actorTransitions[transition.Source].Add(transition);
            transitions[transition.Name] = transition;

            if (!string.IsNullOrEmpty(transition.Source))
                children[transition.Source].AddOutboundTransition(transition);
            children[transition.Destination].AddInboundTransition(transition);

            return this;
        }