internal Field(ModelSupport.ContentTypeInternal ContentTypeInternal, MessageDelimiters CustomDelimiters, bool Temporary, int?Index, ContentBase Parent) : base(CustomDelimiters) { _Temporary = Temporary; _Index = Index; _Parent = Parent; _ComponentDictonary = ParseFieldRawStringToComponent(string.Empty, ContentTypeInternal); }
internal Element(ModelSupport.ContentTypeInternal ContentTypeInternal, MessageDelimiters CustomDelimiters, bool Temporary, int?Index, ModelBase Parent) : base(CustomDelimiters) { _Temporary = Temporary; _Index = Index; _Parent = Parent; _IsMainSeparator = (ContentTypeInternal == ModelSupport.ContentTypeInternal.MainSeparator); _IsEncodingCharacters = (ContentTypeInternal == ModelSupport.ContentTypeInternal.EncodingCharacters); _RepeatDictonary = ParseElementRawStringToRepeat(string.Empty, ContentTypeInternal); }
internal Content(Support.Standard.EscapeType EscapeType, MessageDelimiters CustomDelimiters, bool Temporary, int?Index, ModelBase Parent) : base(CustomDelimiters) { _Temporary = Temporary; _Index = Index; _Parent = Parent; _InternalContentType = ModelSupport.ContentTypeInternal.Escape; _EscapeMetaData = new EscapeData(EscapeType, String.Empty); _Data = Support.Standard.Escapes.ResolveEscapeChararter(EscapeType).ToString(); SetParent(); }
//Only internal Constructors internal Content(string String, ModelSupport.ContentTypeInternal ContentTypeInternal, MessageDelimiters CustomDelimiters, bool Temporary, int?Index, ModelBase Parent) : base(CustomDelimiters) { _Temporary = Temporary; _Index = Index; _Parent = Parent; _InternalContentType = ContentTypeInternal; if (ContentTypeInternal == ModelSupport.ContentTypeInternal.EncodingCharacters) { SetDataToEncodingCharacters(); _EscapeMetaData = null; } else if (ContentTypeInternal == ModelSupport.ContentTypeInternal.MainSeparator) { SetDataToMainSeparator(); _EscapeMetaData = null; } else if (ContentTypeInternal == ModelSupport.ContentTypeInternal.Escape) { if (String != String.Empty) { if (ValidateData(String)) { _Data = String; _EscapeMetaData = new EscapeData(String); } SetParent(); } else { throw new PeterPiperException("Attempt to set Content as Escape Type yet no Content data given, String was empty."); } } else { if (String != String.Empty) { if (ValidateData(String)) { _EscapeMetaData = null; _Data = String; } SetParent(); } } }
internal Content(string String, MessageDelimiters CustomDelimiters, bool Temporary, int?Index, ModelBase Parent) : base(CustomDelimiters) { _Temporary = Temporary; _Index = Index; _Parent = Parent; _InternalContentType = ModelSupport.ContentTypeInternal.Text; _EscapeMetaData = null; if (ValidateData(String)) { if (String != String.Empty) { _Data = String; SetParent(); } } }
//Parsing and Validation private Dictionary <int, Component> ParseFieldRawStringToComponent(String StringRaw, ModelSupport.ContentTypeInternal ContentTypeInternal) { //Example: "first^Second^Third^\H\Forth bold\N\^fith&SubHere^Six"; _ComponentDictonary = new Dictionary <int, Component>(); if (ContentTypeInternal == ModelSupport.ContentTypeInternal.EncodingCharacters || ContentTypeInternal == ModelSupport.ContentTypeInternal.MainSeparator) { _ComponentDictonary.Add(1, new Component(ContentTypeInternal, this.Delimiters, false, 1, this)); } else { if (StringRaw.Contains(this.Delimiters.Component)) { string[] ComponentParts = StringRaw.Split(this.Delimiters.Component); int CompoenentPositionCounter = 1; foreach (string Part in ComponentParts) { if (Part != string.Empty) { //_ComponentDictonary.Add(CompoenentPositionCounter, new Component(Part, this.Delimiters, false, CompoenentPositionCounter, this)); new Component(Part, this.Delimiters, true, CompoenentPositionCounter, this); } CompoenentPositionCounter++; } } else { //_ComponentDictonary.Add(1, new Component(StringRaw, this.Delimiters, this._Temporary, 1, this)); new Component(StringRaw, this.Delimiters, true, 1, this); } } return(_ComponentDictonary); }
//Parsing and Validation private Dictionary <int, Content> ParseSubComponentRawStringToContent(String StringRaw, ModelSupport.ContentTypeInternal ContentTypeInternal) { //Example: "\\N\\this is not Highlighted\\H\\ This is highlighted \\N\\ This is not"; _ContentDictonary = new Dictionary <int, Content>(); if (ContentTypeInternal == ModelSupport.ContentTypeInternal.EncodingCharacters || ContentTypeInternal == ModelSupport.ContentTypeInternal.MainSeparator) { _ContentDictonary.Add(0, new Content(string.Empty, ContentTypeInternal, this.Delimiters, false, 0, this)); } else { if (StringRaw.Contains(this.Delimiters.Escape)) { string[] ContentParts = StringRaw.Split(this.Delimiters.Escape); bool InEscape = false; int SubCompoenentPositionCounter = 0; foreach (string Part in ContentParts) { if (InEscape) { new Content(Part.Trim(), ModelSupport.ContentTypeInternal.Escape, this.Delimiters, true, SubCompoenentPositionCounter, this); SubCompoenentPositionCounter++; InEscape = false; } else { if (Part != string.Empty) { new Content(Part, ModelSupport.ContentTypeInternal.Text, this.Delimiters, true, SubCompoenentPositionCounter, this); SubCompoenentPositionCounter++; } InEscape = true; } } } else { new Content(StringRaw, ModelSupport.ContentTypeInternal.Text, this.Delimiters, true, 0, this); } } return(_ContentDictonary); }
//Parsing and Validation private Dictionary <int, Field> ParseElementRawStringToRepeat(String StringRaw, ModelSupport.ContentTypeInternal ContentTypeInternal) { //Example: "First1^Second1^Third1^~First2^Second2&\\H\\Second22\\N\\^Third2"; _RepeatDictonary = new Dictionary <int, Field>(); if (ContentTypeInternal == ModelSupport.ContentTypeInternal.EncodingCharacters || ContentTypeInternal == ModelSupport.ContentTypeInternal.MainSeparator) { _RepeatDictonary.Add(1, new Field(ContentTypeInternal, this.Delimiters, false, 1, this)); } else { if (StringRaw.Contains(this.Delimiters.Repeat)) { string[] ElementParts = StringRaw.Split(this.Delimiters.Repeat); int RepeatPositionCounter = 1; foreach (string Part in ElementParts) { if (Part != string.Empty) { //_RepeatDictonary.Add(RepeatPositionCounter, new Field(Part, this.Delimiters, false, RepeatPositionCounter, this)); new Field(Part, this.Delimiters, true, RepeatPositionCounter, this); } RepeatPositionCounter++; } } else { //_RepeatDictonary.Add(1, new Field(StringRaw, this.Delimiters, false, 1, this)); new Field(StringRaw, this.Delimiters, true, 1, this); } } return(_RepeatDictonary); }
//Parsing and Validation private Dictionary <int, SubComponent> ParseComponentRawStringToSubComponent(String StringRaw, ModelSupport.ContentTypeInternal ContentTypeInternal) { //Example: "First&Second&Third\H\bold\N\&forth"; _SubComponentDictonary = new Dictionary <int, SubComponent>(); if (ContentTypeInternal == ModelSupport.ContentTypeInternal.EncodingCharacters || ContentTypeInternal == ModelSupport.ContentTypeInternal.MainSeparator) { _SubComponentDictonary.Add(1, new SubComponent(ContentTypeInternal, this.Delimiters, false, 1, this)); } else { if (StringRaw.Contains(this.Delimiters.SubComponent)) { string[] SubComponentParts = StringRaw.Split(this.Delimiters.SubComponent); int SubCompoenentPositionCounter = 1; foreach (string Part in SubComponentParts) { if (Part != string.Empty) { //_SubComponentDictonary.Add(SubCompoenentPositionCounter, new SubComponent(Part, this.Delimiters, false, SubCompoenentPositionCounter, this)); new SubComponent(Part, this.Delimiters, true, SubCompoenentPositionCounter, this); } SubCompoenentPositionCounter++; } } else { //_SubComponentDictonary.Add(1, new SubComponent(StringRaw, this.Delimiters, this._Temporary, 1, this)); new SubComponent(StringRaw, this.Delimiters, true, 1, this); } } return(_SubComponentDictonary); }