internal override void Init(PacketDefinition def) { if (Cases.Count == 0) { throw new ArgumentNullException(string.Format("No Conditions found in Switch {0} for packet {1}", this, def)); } if (ReferenceSegment == null) { if (string.IsNullOrEmpty(ReferenceName)) { throw new ArgumentException(def.PacketIds.ToString(", ") + " defines SwitchSegment without CompareWith-Attribute."); } if ((ReferenceSegment = def.GetSegment(ReferenceName)) == null) { throw new ArgumentException("CompareWith-Segment \"" + ReferenceName + "\" for SwitchSegment " + this + " does not exist."); } } foreach (var condition in Cases) { try { condition.Init(this, def); } catch (Exception e) { throw new Exception(string.Format("Failed to parse Switch {0} - Invalid Case: {1}", this, condition), e); } } }
internal override void Init(PacketDefinition def) { if (Segments.Count == 0) { throw new Exception("List " + Name + " in Defintion for " + def.PacketIds.ToString(", ") + " has no structure defined."); } if (string.IsNullOrEmpty(Name)) { throw new Exception("List in " + def.PacketIds.ToString(", ") + " has no Name but Name is required."); } if (LengthSegment == null) { if (!string.IsNullOrEmpty(LengthSegmentName)) { if ((LengthSegment = def.GetSegment(LengthSegmentName)) == null) { throw new ArgumentException("Length-Segment \"" + LengthSegmentName + "\" for ListSegment " + this + " does not exist."); } } } foreach (var segment in Segments) { segment.Init(def); } }