示例#1
0
        public static string Parse(string cmd, string[] param, Connection c)
        {
            IEnumerable<string> noempty = param.Where(p => !string.IsNullOrEmpty(p));

            if (!Commands.ContainsKey(cmd))
                return null;
            return Commands[cmd].Invoke(noempty, c);
        }
示例#2
0
 public static Connection Add(Connection c)
 {
     Connection get = (Connection)ConnectionFile.Instance().Connections.FirstOrDefault(
         p => p is Connection && ((Connection)p).Name == c.Name);
     if (get != null)
         return get;
     ConnectionFile.Instance().Connections.Add(c);
     ConnectionFile.Instance().WriteImpl(ConnectionFile.Instance().Connections.Where(p => p is Connection).Cast<Connection>().ToList());
     return c;
 }
示例#3
0
 public BIRCViewModel()
 {
     oldServerSelection = null;
     commandTxt = string.Empty;
     defaultConnection = new Connection() { IsDefault = true };
     RetrieveList();
     AddConnectionCmd = new RelayCommand(AddConnectionAction, () => true);
     ConnectionCmd = new RelayCommand(ConnectionAction, () => true);
     CommandCmd = new RelayCommand(CommandAction, () => true);
 }
示例#4
0
        public static AHistory GetActiveAHistory(Connection connection)
        {
            AHistory active = connection.Channels.FirstOrDefault(p => p.IsActive == true);

            if (active == null)
            {
                foreach (Channel cur in connection.Channels)
                {
                    active = cur.Users.FirstOrDefault(p => p.IsActive == true);
                    if (active != null)
                        break;
                }
                if (active == null)
                    active = connection;
            }
            return active;
        }
示例#5
0
        private static string RplMyInfo(IEnumerable<string> list, Connection c)
        {
            List<string> cast = list.ToList();

            return string.Format(MainPage.GetInfoString("RplMyInfo"), cast[1], cast[2], cast[3], cast[4]);
        }
示例#6
0
 private static string Ping(IEnumerable<string> list, Connection c)
 {
     return string.Format(MainPage.GetInfoString("PingRec"), string.Join(SEPARATOR, list));
 }
示例#7
0
 private static string Notice(IEnumerable<string> list, Connection c)
 {
     return string.Join(SEPARATOR, list);
 }
示例#8
0
 private static string Mode(IEnumerable<string> list, Connection c)
 {
     return string.Format(MainPage.GetInfoString("Mode"), list.ToList()[1]);
 }
示例#9
0
 private static string Ignore(IEnumerable<string> list, Connection c)
 {
     return IGNORE;
 }
示例#10
0
        private static string GetInfo(IEnumerable<string> list, Connection c)
        {
            list = list.Where(p => p != c.Nickname);

            return string.Join(SEPARATOR, list);
        }
示例#11
0
        private async static void Server(IList<string> list, AHistory c)
        {
            string pwd = null;
            int port = 0;

            if (list.ElementAtOrDefault(1) == null)
                throw new ErrorBIRC(MainPage.GetErrorString("InvalidServerCmd"));
            if (list.ElementAtOrDefault(2) != null)
            {
                if (int.TryParse(list[2], out port) == false)
                    port = IrcClient.DefaultPort;
            }
            else
                port = IrcClient.DefaultPort;
            if (list.ElementAtOrDefault(3) != null)
                pwd = await Encryption.Protect(list[3]);
            Connection newc = new Connection()
            {
                AutoConnect = true,
                Name = list[1],
                Port = port,
                Password = pwd
            };
            AHistory cur = ConnectionUtils.Add(newc);
            ((BIRCViewModel)MainPage.currentDataContext).ServerSelection = cur;
            if (!cur.Command.IsConnected())
                cur.Command.Connect();
        }