protected override void ProcessValue() { List <string> allSubComponents; if (this.isDelimiter) { allSubComponents = new List <string>(new [] { this.Value }); } else { allSubComponents = MessageHelper.SplitString(_value, this.Encoding.SubComponentDelimiter); } if (allSubComponents.Count > 1) { this.IsSubComponentized = true; } this.SubComponentList = new List <SubComponent>(); foreach (string strSubComponent in allSubComponents) { SubComponent subComponent = new SubComponent(this.Encoding.Decode(strSubComponent), this.Encoding); SubComponentList.Add(subComponent); } }
public override string SerializeValue() { var serialized = new StringBuilder(); serialized.Append(string.Join(Encoding.SubComponentDelimiter.ToString(), SubComponentList.Select(sc => sc.SerializeValue()))); return(serialized.ToString()); }
public void AddSubComponent(SubComponent subComponent) { if (!this.IsSubComponentized) { throw new HL7Exception("Component must be subcomponentized (IsSubComponentized = true)"); } if (SubComponentList == null) { SubComponentList = new List <SubComponent>(); } SubComponentList.Add(subComponent); }
public SubComponent EnsureSubComponent(int position) { if (position < 1) { throw new HL7Exception($"Invalid subcomponents index ({position} < 1)"); } if (position > SubComponentList.Count) { SubComponentList.Add(new SubComponent(string.Empty, this.Encoding), position); } return(SubComponentList[position - 1]); }
public override void RemoveTrailingDelimiters(RemoveDelimitersOptions options) { foreach (var subComponent in SubComponentList) { subComponent.RemoveTrailingDelimiters(options); } if (options.SubComponent) { while (SubComponentList.Count > 1 && SubComponentList[SubComponentList.Count - 1].SerializeValue() == string.Empty) { SubComponentList.RemoveAt(SubComponentList.Count - 1); } if (SubComponentList.Count == 1) { IsSubComponentized = false; } } }