Exemplo n.º 1
0
        public static bool Save(IRCServer server)
        {
            XDocument xd         = new XDocument();
            XElement  connection = new XElement("connection", new XAttribute("ip", server.IP), new XAttribute("port", server.PORT));

            connection.Add(new XElement("name", server.Nick));
            connection.Add(new XElement("pass", server.Pass));
            connection.Add(new XElement("altnick", server.AltNick));
            connection.Add(new XElement("realname", server.RealName));
            connection.Add(new XElement("ssl", server.SSL));
            connection.Add(new XElement("lograw", server.LoggingRaw));
            xd.Add(connection);
            XElement channels = new XElement("channels");

            foreach (IRCChannel chan in server.GetChannels())
            {
                XElement channel = new XElement("channel");
                channel.Add(new XElement("name", chan.Channel)); channel.Add(new XElement("reconnect", chan.Reconnect));
                channels.Add(channel);
            }
            connection.Add(channels);

            XElement users = new XElement("users");

            int index = 0;

            foreach (KeyValuePair <string, UserAccess> access in server.Users)
            {
                XElement user = new XElement("user");
                if (index++ == server.Users.Count)
                {
                    break;
                }
                user.Add(new XElement("host", access.Key));
                user.Add(new XElement("access", UserAccessAttr.GetByValue(access.Value)));
                users.Add(user);
            }
            connection.Add(users);
            xd.Save(server.File);
            return(true);
        }
Exemplo n.º 2
0
        public static bool Save(IRCServer server)
        {
            XDocument xd = new XDocument();
            XElement connection = new XElement("connection", new XAttribute("ip", server.IP), new XAttribute("port", server.PORT));
            connection.Add(new XElement("name", server.Nick));
            connection.Add(new XElement("pass", server.Pass));
            connection.Add(new XElement("altnick", server.AltNick));
            connection.Add(new XElement("realname", server.RealName));
            connection.Add(new XElement("ssl", server.SSL));
            connection.Add(new XElement("lograw", server.LoggingRaw));
            xd.Add(connection);
            XElement channels = new XElement("channels");
            foreach (IRCChannel chan in server.GetChannels())
            {
                XElement channel = new XElement("channel");
                channel.Add(new XElement("name", chan.Channel)); channel.Add(new XElement("reconnect", chan.Reconnect));
                channels.Add(channel);
            }
            connection.Add(channels);

            XElement users = new XElement("users");

            int index = 0;
            foreach (KeyValuePair<string, UserAccess> access in server.Users)
            {
                XElement user = new XElement("user");
                if (index++ == server.Users.Count)
                {
                    break;
                }
                user.Add(new XElement("host", access.Key));
                user.Add(new XElement("access", UserAccessAttr.GetByValue(access.Value)));
                users.Add(user);
            }
            connection.Add(users);
            xd.Save(server.File);
            return true;
        }