public ACConfig parseinobject(StreamReader Reader)
        {
            Configureviop             vo                  = new Configureviop();
            ConfigureNetwork          co                  = new ConfigureNetwork();
            List <Networkdev>         networkDevs         = new List <Networkdev>();
            List <Interfacenetworkif> interfaceNetworkIfs = new List <Interfacenetworkif>();
            List <Proxyip>            proxyIps            = new List <Proxyip>();
            List <Proxyset>           proxySets           = new List <Proxyset>();
            ACConfig AC = new ACConfig();


            AC.configureNetwork = co;
            AC.configureviop    = vo;

            AC.configureNetwork.networkdev         = networkDevs;
            AC.configureNetwork.interfacenetworkif = interfaceNetworkIfs;

            AC.configureviop.proxyip  = proxyIps;
            AC.configureviop.proxyset = proxySets;

            string ident                      = String.Empty;
            bool   configureExit              = true;
            string subIdent                   = String.Empty;
            bool   subIdentExit               = true;
            string subIdentValue              = String.Empty;
            int    networkDevListTndex        = -1;
            int    interfaceNetwokIfListTndex = -1;
            int    proxySetListTndex          = -1;
            int    proxyIpListTndex           = -1;
            string Name = string.Empty;

            using (Reader)
            {
                string line = " ";
                while ((line = Reader.ReadLine()) != null)                                                  // zu editierende File einlesen (Zeile für Zeile)
                {
                    if (line == string.Empty || line == "")                                                 // wenn leere Zeile überspringe
                    {
                        continue;
                    }
                    if (configureExit)                                                                      // wenn True -> kein Überbereich(configure voip // configure network) in dem die Konfig definiert wird
                    {
                        getConfigureIdent(line, out configureExit, out ident);
                        continue;
                    }
                    if (subIdentExit)
                    {
                        getIdentNameAndValue(line, out configureExit, out subIdentExit, out subIdent, out subIdentValue);                   // wenn true -> keien Bereich(networkDev / interfaceNetworkIf) in dem Konfig konfiguriert wird
                        Name = returnRealName(subIdent);
                        if (Name == null)
                        {
                            continue;
                        }
                        switch (subIdent)
                        {
                        case ParserVariables.networkDev:
                            Networkdev newListNetworkDev = new Networkdev();
                            networkDevs.Add(newListNetworkDev);
                            networkDevListTndex++;
                            AC = ListParsing(AC, Name, subIdentValue, networkDevListTndex, AC.configureNetwork.networkdev, subIdent);
                            continue;

                        case ParserVariables.interfaceNetwokIf:
                            Interfacenetworkif newListInterfaceNetworkIf = new Interfacenetworkif();
                            interfaceNetworkIfs.Add(newListInterfaceNetworkIf);
                            interfaceNetwokIfListTndex++;
                            AC = ListParsing(AC, Name, subIdentValue, interfaceNetwokIfListTndex, AC.configureNetwork.interfacenetworkif, subIdent);
                            continue;

                        case ParserVariables.proxyIp:
                            Proxyip newListProxyIp = new Proxyip();
                            proxyIps.Add(newListProxyIp);
                            proxyIpListTndex++;
                            AC = ListParsing(AC, Name, subIdentValue, proxyIpListTndex, AC.configureviop.proxyip, subIdent);
                            continue;

                        case ParserVariables.proxySet:
                            Proxyset newListProxySet = new Proxyset();
                            proxySets.Add(newListProxySet);
                            proxySetListTndex++;
                            AC = ListParsing(AC, Name, subIdentValue, proxySetListTndex, AC.configureviop.proxyset, subIdent);
                            continue;

                        default:
                            continue;;
                        }
                    }
                    Name = ParserGrammar.NameParser.Parse(line);
                    if (Name == ParserVariables.exit)
                    {
                        subIdentExit = true;

                        continue;
                    }
                    Name = returnRealName(Name);
                    if (Name == null)
                    {
                        continue;
                    }
                    switch (subIdent)
                    {
                    case ParserVariables.networkDev:
                        AC = AddToList(AC, Name, AC.configureNetwork.networkdev, subIdent, networkDevListTndex, getVar(Name, line));
                        continue;

                    case ParserVariables.interfaceNetwokIf:
                        AC = AddToList(AC, Name, AC.configureNetwork.interfacenetworkif, subIdent, interfaceNetwokIfListTndex, getVar(Name, line));
                        continue;

                    case ParserVariables.proxyIp:
                        AC = AddToList(AC, Name, AC.configureviop.proxyip, subIdent, proxyIpListTndex, getVar(Name, line));
                        continue;

                    case ParserVariables.proxySet:
                        AC = AddToList(AC, Name, AC.configureviop.proxyset, subIdent, proxySetListTndex, getVar(Name, line));
                        continue;

                    default:
                        break;
                    }
                }
            }
            return(AC);
        }
Esempio n. 2
0
        protected ACConfig parseinobject(StreamReader Reader)
        {
            Configureviop             vo                  = new Configureviop();
            ConfigureNetwork          co                  = new ConfigureNetwork();
            List <Networkdev>         networkDevs         = new List <Networkdev>();
            List <Interfacenetworkif> interfaceNetworkIfs = new List <Interfacenetworkif>();
            List <Proxyip>            proxyIps            = new List <Proxyip>();
            List <Proxyset>           proxySets           = new List <Proxyset>();
            ACConfig AC = new ACConfig();


            AC.configureNetwork = co;
            AC.configureviop    = vo;

            AC.configureNetwork.networkdev         = networkDevs;
            AC.configureNetwork.interfacenetworkif = interfaceNetworkIfs;

            AC.configureviop.proxyip  = proxyIps;
            AC.configureviop.proxyset = proxySets;

            string ident                      = " ";
            bool   configureExit              = true;
            string subIdent                   = " ";
            bool   subIdentExit               = true;
            string subIdentValue              = "";
            int    networkDevListTndex        = 0;
            int    interfaceNetwokIfListTndex = 0;
            int    proxySetListTndex          = 0;
            int    proxyIpListTndex           = 0;

            using (Reader)
            {
                string line = " ";
                while ((line = Reader.ReadLine()) != null)                                                  // zu editierende File einlesen (Zeile für Zeile)
                {
                    if (line == string.Empty || line == "")                                                 // wenn leere Zeile überspringe
                    {
                        continue;
                    }
                    if (configureExit)                                                                      // wenn True -> kein Überbereich(configure voip // configure network) in dem die Konfig definiert wird
                    {
                        getConfigureIdent(line, out configureExit, out ident);
                        continue;
                    }
                    if (subIdentExit)
                    {
                        getIdentNameAndValue(line, out configureExit, out subIdentExit, out subIdent, out subIdentValue);  // wenn true -> keien Bereich(networkDev / interfaceNetworkIf) in dem Konfig konfiguriert wird
                        var Name = returnRealName(subIdent);
                        if (Name != null && subIdent == ParserVariables.networkDev)
                        {
                            Networkdev newListNetworkDev = new Networkdev();
                            networkDevs.Add(newListNetworkDev);                                            //neue Liste wird erstellt für jede Bereich von networkDev
                            AC = ListParsing(AC, Name, subIdentValue, networkDevListTndex, AC.configureNetwork.networkdev, subIdent);
                        }
                        else if (Name != null && subIdent == ParserVariables.interfaceNetwokIf)
                        {
                            Interfacenetworkif newListInterfaceNetworkIf = new Interfacenetworkif();
                            interfaceNetworkIfs.Add(newListInterfaceNetworkIf);
                            AC = ListParsing(AC, Name, subIdentValue, interfaceNetwokIfListTndex, AC.configureNetwork.interfacenetworkif, subIdent);
                        }
                        else if (Name != null && subIdent == ParserVariables.proxySet)
                        {
                            Proxyset newListProxySet = new Proxyset();
                            proxySets.Add(newListProxySet);
                            AC = ListParsing(AC, Name, subIdentValue, proxySetListTndex, AC.configureviop.proxyset, subIdent);
                        }
                        else if (Name != null && subIdent == ParserVariables.proxyIp)
                        {
                            Proxyip newListProxyIp = new Proxyip();
                            proxyIps.Add(newListProxyIp);
                            AC = ListParsing(AC, Name, subIdentValue, proxyIpListTndex, AC.configureviop.proxyip, subIdent);
                        }
                        continue;
                    }

                    if (configureExit == false && subIdentExit == false && ident == "configure network" && subIdent == ParserVariables.networkDev)
                    {
                        var Name = ParserGrammar.NameParser.Parse(line);
                        if (Name == ParserVariables.exit) // Bereich wird durch exit beendet -> Listenindex wird erhöht und es gibt keinen Bereich in dem definiert die Konfig defoiniert wird
                        {
                            subIdentExit = true;
                            networkDevListTndex++;
                            continue;
                        }
                        Name = returnRealName(Name);
                        if (Name == null)
                        {
                            continue;
                        }
                        if (Name == ParserVariables.activate) //boolscher wert der in der KOnfiguration keinen weiteren Wert zugewieden bekommt -> entweder da oder nicht
                        {
                            var Value = true;
                            AC = ListParsing(AC, Name, Value, networkDevListTndex, AC.configureNetwork.networkdev, subIdent);
                        }
                        else
                        {
                            var Value = ParserGrammar.ValueParser.Parse(line);
                            AC = ListParsing(AC, Name, Value, networkDevListTndex, AC.configureNetwork.networkdev, subIdent);
                        }


                        continue;
                    }
                    else if (configureExit == false && subIdentExit == false && ident == "configure network" && subIdent == ParserVariables.interfaceNetwokIf)
                    {
                        var Name = ParserGrammar.NameParser.Parse(line);
                        if (Name == ParserVariables.exit)
                        {
                            subIdentExit = true;
                            interfaceNetwokIfListTndex++;
                            continue;
                        }
                        Name = returnRealName(Name);
                        if (Name == null)
                        {
                            continue;
                        }
                        if (Name == ParserVariables.activate)
                        {
                            var Value = true;
                            AC = ListParsing(AC, Name, Value, interfaceNetwokIfListTndex, AC.configureNetwork.interfacenetworkif, subIdent);
                        }
                        else
                        {
                            var Value = ParserGrammar.ValueParser.Parse(line);
                            AC = ListParsing(AC, Name, Value, interfaceNetwokIfListTndex, AC.configureNetwork.interfacenetworkif, subIdent);
                        }
                        continue;
                    }
                    if (configureExit == false && subIdentExit == false && ident == "configure voip" && subIdent == ParserVariables.proxySet)
                    {
                        var Name = ParserGrammar.NameParser.Parse(line);
                        if (Name == ParserVariables.exit)
                        {
                            subIdentExit = true;
                            proxySetListTndex++;
                            continue;
                        }
                        Name = returnRealName(Name);
                        if (Name == null)
                        {
                            continue;
                        }
                        if (Name == ParserVariables.activate)
                        {
                            var Value = true;
                            AC = ListParsing(AC, Name, Value, proxySetListTndex, AC.configureviop.proxyset, subIdent);
                        }
                        else
                        {
                            var Value = ParserGrammar.ValueParser.Parse(line);
                            AC = ListParsing(AC, Name, Value, proxySetListTndex, AC.configureviop.proxyset, subIdent);
                        }
                        continue;
                    }
                    else if (configureExit == false && subIdentExit == false && ident == "configure voip" && subIdent == ParserVariables.proxyIp)
                    {
                        var Name = ParserGrammar.NameParser.Parse(line);
                        if (Name == ParserVariables.exit)
                        {
                            subIdentExit = true;
                            proxyIpListTndex++;
                            continue;
                        }
                        Name = returnRealName(Name);
                        if (Name == null)
                        {
                            continue;
                        }
                        if (Name == ParserVariables.activate)
                        {
                            var Value = true;
                            AC = ListParsing(AC, Name, Value, proxyIpListTndex, AC.configureviop.proxyip, subIdent);
                        }
                        else
                        {
                            var Value = ParserGrammar.ValueParser.Parse(line);
                            AC = ListParsing(AC, Name, Value, proxyIpListTndex, AC.configureviop.proxyip, subIdent);
                        }
                        continue;
                    }
                }
            }
            return(AC);
        }