Ejemplo n.º 1
0
        public static FtpCommandTable LoadFromXml(string InXmlString)
        {
            FtpCommandTable cmdTable = new FtpCommandTable();

            XmlStream xmlStream = new XmlStream(InXmlString);

            XmlElem cmdsElem = xmlStream.GetDocumentElem("FtpCommands");

            // for each FtpCommand of the FtpCommands elem.
            foreach (XmlElem cmdElem in cmdsElem)
            {
                if (cmdElem.ElemName != "FtpCommand")
                {
                    continue;
                }

                // new up the item to add to the table.
                FtpCommandItem cmdItem = new FtpCommandItem();

                // command name.
                XmlElem nameElem = cmdElem.FindChildElem("Name");
                if (nameElem != null)
                {
                    cmdItem.Name = nameElem.ElemValue;
                }

                // text description
                XmlElem textElem = cmdElem.FindChildElem("Text");
                if (textElem != null)
                {
                    cmdItem.Text = textElem.ElemValue;
                }

                // how does the ftp command use the data channel.
                cmdItem.SetDataChannel(cmdElem["DataChannel"]);

                // load the ReplyCodes element. ( the replies expected from the server to
                // this Ftp command )
                LoadFromXml_ReplyCodes(cmdItem, cmdElem);

                // add to the FtpCommandTable.
                cmdTable.Add(cmdItem.Key, cmdItem);
            }

            return(cmdTable);
        }