Example #1
0
 public void Add(TLV tlvMember)
 {
     _tlvMembers.Add(tlvMember);
 }
Example #2
0
 public TLV setParent(TLV parent)
 {
     this.parent = parent;
     return(this);
 }
Example #3
0
 public void Remove(TLV tlvMember)
 {
     _tlvMembers.Remove(tlvMember);
 }
Example #4
0
        private TLVList Encode(TLV Parent, string FileToParse, SymbolTable DocFile)
        {
            var NewTlvList = new TLVList();

            while (true)
            {
                int PosLine  = FileToParse.IndexOf(';');
                int PosGroup = FileToParse.IndexOf('{');
                if (PosLine < 0 && PosGroup < 0)
                {
                    break;
                }
                if (PosLine > PosGroup && PosGroup > -1)
                {
                    // Exclude Comment Before Began // # /* */
                    //We Find Post Group Recursive Call
                    string Name =
                        FileToParse.Substring(0, PosGroup).Replace('\n', ' ').Replace('\r', ' ').Replace('\t', ' ').Trim
                            ();
                    if (Name.StartsWith("/*"))
                    {
                        Name = Name.Substring(Name.IndexOf("*/") + 2).Trim();
                    }
                    LastCommand = Name;
                    if (Name != "Main")
                    {
                        Param  FindElem      = DocFile[Name];
                        string FileToParse2  = Split(FileToParse.Substring(PosGroup));
                        string Manage        = FileToParse2.Substring(1, FileToParse2.Length - 2);
                        TLV    newTlvElement = TLV.Create(FindElem, "");
                        newTlvElement.setParent(Parent);
                        newTlvElement.children = Encode(newTlvElement, Manage, FindElem.Group);
                        FileToParse            = FileToParse.Substring(PosGroup + FileToParse2.Length);
                        NewTlvList.Add(newTlvElement);
                        DebugEvent(ref newTlvElement);
                    }
                    else
                    {
                        string FileToParse2 = Split(FileToParse.Substring(PosGroup));
                        string Manage       = FileToParse2.Substring(1, FileToParse2.Length - 2);
                        NewTlvList  = Encode(null, Manage, DocFile);
                        FileToParse = FileToParse.Substring(PosGroup + FileToParse2.Length);
                    }
                }
                else
                {
                    var    getRegEx = new Regex(@"\b.*?;");
                    string NewValue = getRegEx.Match(FileToParse).ToString().Replace('\t', ' ').Replace('\n', ' ');
                    // string NewVal = FileToParse.Substring(0, PosLine ).Trim();
                    string SymbolName = NewValue.Split(' ')[0];
                    LastCommand = SymbolName;
                    NewValue    = NewValue.Substring(SymbolName.Length + 1, NewValue.IndexOf(';') - SymbolName.Length - 1);
                    FileToParse = FileToParse.Substring(PosLine + 1);
                    if (SymbolName != "GenericTLV")
                    {
                        TLV NewTlvElement = TLV.Create(DocFile[SymbolName], NewValue);

                        NewTlvElement.setParent(Parent);
                        DebugEvent(ref NewTlvElement);
                        NewTlvList.Add(NewTlvElement);
                    }
                    else
                    {
                        TLV NewTlvElement = new TLVGeneric(SymbolName, NewValue);
                        NewTlvElement.setParent(Parent);
                        DebugEvent(ref NewTlvElement);
                        NewTlvList.Add(NewTlvElement);
                    }
                }
            }
            return(NewTlvList);
        }