예제 #1
0
        public void SetServer(ServerModel server)
        {
            Trace.Call(server);

            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            server.Save(_UserConfig);
        }
예제 #2
0
        public void AddServer(ServerModel server)
        {
            Trace.Call(server);

            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (String.IsNullOrEmpty(server.Hostname))
            {
                throw new InvalidOperationException(_("Server hostname must not be empty."));
            }
            if (server.Hostname.Contains("\n"))
            {
                throw new InvalidOperationException(_("Server hostname contains invalid characters (newline)."));
            }
            var highestServerId = -1;

            foreach (var s in GetServerList())
            {
                if (s.Protocol == server.Protocol &&
                    s.ServerID == server.ServerID)
                {
                    throw new InvalidOperationException(
                              String.Format(_("Server ID '{0}' already exists."),
                                            server.ServerID)
                              );
                }
                int id;
                if (Int32.TryParse(s.ServerID, out id) && id > highestServerId)
                {
                    highestServerId = id;
                }
            }
            if (String.IsNullOrEmpty(server.ServerID))
            {
                server.ServerID = (++highestServerId).ToString();
            }
            server.Save(_UserConfig);

            string[] servers = (string[])_UserConfig["Servers/Servers"];
            if (servers == null)
            {
                servers = new string[] {};
            }
            List <string> serverList = new List <string>(servers);

            serverList.Add(server.Protocol + "/" + server.ServerID);
            _UserConfig["Servers/Servers"] = serverList.ToArray();
        }
예제 #3
0
        public void AddServer(ServerModel server)
        {
            Trace.Call(server);

            if (server == null) {
                throw new ArgumentNullException("server");
            }
            if (String.IsNullOrEmpty(server.Hostname)) {
                throw new InvalidOperationException(_("Server hostname must not be empty."));
            }
            if (server.Hostname.Contains("\n")) {
                throw new InvalidOperationException(_("Server hostname contains invalid characters (newline)."));
            }
            var highestServerId = -1;
            foreach (var s in GetServerList()) {
                if (s.Protocol == server.Protocol &&
                    s.ServerID == server.ServerID) {
                    throw new InvalidOperationException(
                        String.Format(_("Server ID '{0}' already exists."),
                                      server.ServerID)
                    );
                }
                int id;
                if (Int32.TryParse(s.ServerID, out id) && id > highestServerId) {
                    highestServerId = id;
                }
            }
            if (String.IsNullOrEmpty(server.ServerID)) {
                server.ServerID = (++highestServerId).ToString();
            }
            server.Save(_UserConfig);

            string[] servers = (string[]) _UserConfig["Servers/Servers"];
            if (servers == null) {
                servers = new string[] {};
            }
            List<string> serverList = new List<string>(servers);
            serverList.Add(server.Protocol + "/" + server.ServerID);
            _UserConfig["Servers/Servers"] = serverList.ToArray();
        }
예제 #4
0
        public void SetServer(ServerModel server)
        {
            Trace.Call(server);

            if (server == null) {
                throw new ArgumentNullException("server");
            }
            server.Save(_UserConfig);
        }