public TransitionDTO(int Id, StateDTO From, StateDTO To, DirectionValue Value) { this.Id = Id; this.From = From; this.To = To; this.Value = new TransitionValue { Letter = Value.Letter.IsEpsilon ? new Letter('ε') : Value.Letter, LetterToPush = Value.LetterToPush != null ? Value.LetterToPush.IsEpsilon ? new Letter('ε') : Value.LetterToPush : null, LetterToPop = Value.LetterToPop != null ? Value.LetterToPop.IsEpsilon ? new Letter('ε') : Value.LetterToPop : null, }; }
public FiniteAutomataStructureDto(HashSet <IState> states) { this.Transitions = new HashSet <TransitionDTO>(); this.States = new HashSet <StateDTO>(); int counter = 0; foreach (var state in states) { this.States.Add(StateDTO.FromModel(state)); } foreach (var state in states) { foreach (var direciton in state.Directions) { foreach (var value in direciton.Value) { this.Transitions.Add(new TransitionDTO(++counter, StateDTO.FromModel(state), StateDTO.FromModel(direciton.Key), value)); } } } }