public CreatePetriNet WithPlaces(params string[] placeNames) { Contract.Requires(placeNames.Count() != 0); Contract.Requires(placeNames.All(s1 => !string.IsNullOrWhiteSpace(s1))); Contract.Requires(placeNames.All(s1 => s1.All(Char.IsLetterOrDigit))); if (Places == null) { Places = new Dictionary <int, string>(); } var tmp = placeNames.Select((s, i) => Tuple.Create(i, s)).ToDictionary(tuple => tuple.Item1, tuple1 => tuple1.Item2); int count = (Places.Count > 0? Places.Keys.Max():-1) + 1; foreach (var item in tmp) { if (!Places.ContainsValue(item.Value)) { Places[count] = item.Value; count++; } } return(this); }
public Marking CreateMarking() { var result = new Marking(Places.Count); foreach (var marking in PlaceMarkings) { if (Places.ContainsValue(marking.Key)) { result[PlaceIndex(marking.Key)] = marking.Value; } } return(result); }