static Task HandleCommand(IrcConnection conn, string prefix, string command, string[] args)
        {
            Func <IrcConnection, string, string, string[], Task> handler;

            if (!_handlers.TryGetValue(command, out handler))
            {
                // handler not yet registered
                MethodInfo mi;
                if (!_handlerInfos.TryGetValue(command, out mi))
                {
                    mi = _defaultHandler;
                }

                ParameterExpression pInstance = Expression.Parameter(typeof(IrcConnection), "instance"),
                                    pPrefix   = Expression.Parameter(typeof(string), "prefix"),
                                    pCmd      = Expression.Parameter(typeof(string), "cmd"),
                                    pArgs     = Expression.Parameter(typeof(string[]), "args");
                ParameterExpression[] all     = new[] { pInstance, pPrefix, pCmd, pArgs };

                var lambda = Expression.Lambda <Func <IrcConnection, string, string, string[], Task> >(
                    Expression.Call(
                        pInstance,
                        mi,
                        pPrefix,
                        pCmd,
                        pArgs
                        ),
                    all
                    );

                handler = _handlers[command] = lambda.Compile();
            }
            return(handler(conn, prefix, command, args));
        }
示例#2
0
        static Task HandleCommand(IrcConnection conn, string prefix, string command, string[] args)
        {
            Func<IrcConnection, string, string, string[], Task> handler;
            if (!_handlers.TryGetValue(command, out handler))
            {
                // handler not yet registered
                MethodInfo mi;
                if (!_handlerInfos.TryGetValue(command, out mi))
                    mi = _defaultHandler;

                ParameterExpression pInstance = Expression.Parameter(typeof(IrcConnection), "instance"),
                    pPrefix = Expression.Parameter(typeof(string), "prefix"),
                    pCmd = Expression.Parameter(typeof(string), "cmd"),
                    pArgs = Expression.Parameter(typeof(string[]), "args");
                ParameterExpression[] all = new[] { pInstance, pPrefix, pCmd, pArgs };

                var lambda = Expression.Lambda<Func<IrcConnection, string, string, string[], Task>>(
                    Expression.Call(
                        pInstance,
                        mi,
                        pPrefix,
                        pCmd,
                        pArgs
                    ),
                    all
                );

                handler = _handlers[command] = lambda.Compile();
            }
            return handler(conn, prefix, command, args);
        }
示例#3
0
 public IrcChannel(IrcConnection connection, string name)
 {
     _connection = connection;
     _name = name;
     _users = new List<Guid>();
     _userStates = new Dictionary<Guid, UserMode>();
     _loaded = new TaskCompletionSource<IIrcChannel>();
     _state = State.WaitingForJoin;
     _userList = new ChannelUserList(this);
     _userObjects = new Dictionary<Guid, IrcChannelUser>();
 }
示例#4
0
 public IrcChannel(IrcConnection connection, string name)
 {
     _connection  = connection;
     _name        = name;
     _users       = new List <Guid>();
     _userStates  = new Dictionary <Guid, UserMode>();
     _loaded      = new TaskCompletionSource <IIrcChannel>();
     _state       = State.WaitingForJoin;
     _userList    = new ChannelUserList(this);
     _userObjects = new Dictionary <Guid, IrcChannelUser>();
 }
示例#5
0
 public IrcCurrentUser(IrcConnection conn)
 {
     _conn = conn;
 }
示例#6
0
 public IrcUser(IrcConnection connection, Guid guid)
 {
     _connection = connection;
     _guid       = guid;
 }
示例#7
0
 public IrcCurrentUser(IrcConnection conn)
 {
     _conn = conn;
 }
示例#8
0
 public ChannelList(IrcConnection connection)
 {
     _connection = connection;
 }
示例#9
0
 public IrcUser(IrcConnection connection, Guid guid)
 {
     _connection = connection;
     _guid = guid;
 }