示例#1
0
文件: Utils.cs 项目: maryasov/server
        protected override void PackToCore(MsgPack.Packer packer, T objectTree)
        {
            var index = Resources.InternalCallRefHandler.Get().AddCallback(objectTree as Delegate);

            var resourceNameBytes = Encoding.UTF8.GetBytes("__internal");
            var delegateData      = new byte[8 + resourceNameBytes.Length];

            Array.Copy(BitConverter.GetBytes(index).Reverse().ToArray(), 0, delegateData, 0, 4);
            Array.Copy(BitConverter.GetBytes(0).Reverse().ToArray(), 0, delegateData, 4, 4);
            Array.Copy(resourceNameBytes, 0, delegateData, 8, resourceNameBytes.Length);

            packer.PackExtendedTypeValue(1, delegateData);
        }