Ejemplo n.º 1
0
        public void Run(ReadBytes read)
        {
            int cmd = read.ReadInt32();

            if (CallsMethods.ContainsKey(cmd))
            {
                AutoBuffer buffer = read.ReadObject <AutoBuffer>();

                object[] args = null;

                if (CallsArgsTable.ContainsKey(cmd))
                {
                    var argsTypeTable = CallsArgsTable[cmd];

                    if (argsTypeTable.Count > 0 && argsTypeTable.Count == buffer.Args.Count)
                    {
                        args = new object[argsTypeTable.Count];

                        for (int i = 0; i < argsTypeTable.Count; i++)
                        {
                            args[i] = UnpackSingleObject(argsTypeTable[i], buffer.Args[i]);
                        }
                    }

                    CallsMethods[cmd].Invoke(null, args);
                }
            }
        }
Ejemplo n.º 2
0
        public void Run <T1, T2, T3>(ReadBytes read, T1 obj1, T2 obj2, T3 obj3)
        {
            int cmd = read.ReadInt32();

            if (CallsMethods.ContainsKey(cmd))
            {
                AutoBuffer buffer = read.ReadObject <AutoBuffer>();

                object[] args = null;

                if (CallsArgsTable.ContainsKey(cmd))
                {
                    var argsTypeTable = CallsArgsTable[cmd];

                    if (argsTypeTable.Count > 0 && argsTypeTable.Count == (buffer.Args.Count + 3))
                    {
                        args = new object[argsTypeTable.Count];

                        args[0] = obj1;
                        args[1] = obj2;
                        args[2] = obj3;

                        int x = 3;
                        for (int i = 0; i < (argsTypeTable.Count - 3); i++)
                        {
                            x       = i + 3;
                            args[x] = UnpackSingleObject(argsTypeTable[x], buffer.Args[i]);
                        }
                    }

                    CallsMethods[cmd].Invoke(null, args);
                }
            }
        }