示例#1
0
    public static void Ser(IntPtr ptr)
    {
        int offset = 0;

        StoreDelegateType storeDelegate = StoreDelegateAction;

        Marshal.WriteIntPtr(ptr, offset, Marshal.GetFunctionPointerForDelegate(storeDelegate));
        offset += IntPtr.Size;

        GetHandler = GetHandle;
        Marshal.WriteIntPtr(ptr, offset, Marshal.GetFunctionPointerForDelegate(GetHandler));
        offset += IntPtr.Size;

        StoreStringType storeString = StringStore.OnReceiveStr;

        Marshal.WriteIntPtr(ptr, offset, Marshal.GetFunctionPointerForDelegate(storeString));
        offset += IntPtr.Size;

        RemoveHandle = ObjectStore.OnRemove;
        Marshal.WriteIntPtr(ptr, offset, Marshal.GetFunctionPointerForDelegate(RemoveHandle));
        offset += IntPtr.Size;

        //init ObjectStore
        ObjectStore.Get(0);
    }
示例#2
0
    public static void DeSer(IntPtr ptr)
    {
        int offset = 0;

        StoreDelegate = Marshal.GetDelegateForFunctionPointer <StoreDelegateType>(Marshal.ReadIntPtr(ptr, offset));
        offset       += IntPtr.Size;

        GetHandler = Marshal.GetDelegateForFunctionPointer <GetHandlerType>(Marshal.ReadIntPtr(ptr, offset));
        offset    += IntPtr.Size;

        StoreString = Marshal.GetDelegateForFunctionPointer <StoreStringType>(Marshal.ReadIntPtr(ptr, offset));
        offset     += IntPtr.Size;

        RemoveHandle = Marshal.GetDelegateForFunctionPointer <RemoveHandleType>(Marshal.ReadIntPtr(ptr, offset));
        offset      += IntPtr.Size;

        StoreStringType storeString = StringStore.OnReceiveStr;

        StoreDelegate((int)DelegateType.StoreString, Marshal.GetFunctionPointerForDelegate(storeString));
    }