Exemple #1
0
 public dynamic GetProperty(string setting)
 {
     return(Channel.Setting(setting));
 }
Exemple #2
0
        /*
         * Set up the channel by simply traversing the XML node and calling
         * the Settings method for each entry.  Example XML file will look
         * like the following:
         *
         * <Table>
         *   <Channel>
         *     <Type>1</Type>
         *   </Channel>
         *   <Setup>
         *     <Server>c:\temp</Server>
         *     <Debug>9</Debug>
         *   </Setup>
         * </Table>
         *
         */
        private void SetUpChannel(string ConfigFileUNC, string SectionName)
        {
            Channel = null;

            XmlDocument xmldoc = new XmlDocument();
            XmlNodeList xmlnode;
            FileStream  fs = new FileStream(ConfigFileUNC, FileMode.Open, FileAccess.Read);

            if (startupDebug)
            {
                dbug("In SetUpChannel");
            }

            xmldoc.Load(fs);

            xmlnode = xmldoc.GetElementsByTagName("Channel");
            for (int i = 0; i <= xmlnode.Count - 1; i++)
            {
                for (int j = 0; j < xmlnode[i].ChildNodes.Count; j++)
                {
                    try
                    {
                        // Fill it up
                        switch (xmlnode[i].ChildNodes.Item(j).Name.Trim().ToUpper())
                        {
                        case "TYPE":
                            switch (xmlnode[i].ChildNodes.Item(j).InnerText.Trim().ToUpper())
                            {
                            case "COMFILE":
                                Channel = null;
                                Channel = new ComFile();
                                break;

                            case "COMIRC":
                                Channel = null;
                                Channel = new ComIRC();
                                break;

                            case "COMCHAT":
                                Channel = null;
                                Channel = new ComChat();
                                break;

                            case "COMTCP":
                                Channel = null;
                                Channel = new ComTCP();
                                break;
                            }
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        dbug("SetUpChannel Error: " + ex.Message + "\r\nFrom " + ex.Source);
                    }
                }
            }

            if (Channel != null)
            {
                xmlnode = xmldoc.GetElementsByTagName(SectionName);
                for (int i = 0; i <= xmlnode.Count - 1; i++)
                {
                    for (int j = 0; j < xmlnode[i].ChildNodes.Count; j++)
                    {
                        if (startupDebug)
                        {
                            dbug(string.Format("Setting {0} to {1}", xmlnode[i].ChildNodes.Item(j).Name.Trim(), xmlnode[i].ChildNodes.Item(j).InnerText.Trim()));
                        }
                        Channel.Setting(xmlnode[i].ChildNodes.Item(j).Name.Trim(), xmlnode[i].ChildNodes.Item(j).InnerText.Trim());
                    }
                }

                if (Channel.SetEncrypt)
                {
                    SetChannelEncryption(Channel.EncryptInfo);
                }

                if (startupDebug)
                {
                    dbug("Running " + Channel.Name + "\r\n-----------------------------------------------------------------------\r\n");
                }
            }

            fs.Close();
        }