Example #1
0
            public StorageHandler(string dataPath)
            {
                _dataPath      = dataPath;
                openDelegate   = new FileOpenDelegate(FileOpen);
                readDelegate   = new FileReadDelegate(FileRead);
                closeDelegate  = new FileCloseDelegate(FileClose);
                unlinkDelegate = new FileUnlinkDelegate(FileUnlink);
                writeDelegate  = new FileWriteDelegate(FileWrite);
                var h1 = GCHandle.Alloc(openDelegate, GCHandleType.Normal);
                var h2 = GCHandle.Alloc(readDelegate, GCHandleType.Normal);
                var h3 = GCHandle.Alloc(writeDelegate, GCHandleType.Normal);
                var h4 = GCHandle.Alloc(closeDelegate, GCHandleType.Normal);
                var h5 = GCHandle.Alloc(unlinkDelegate, GCHandleType.Normal);

                pinnedDelegates = new GCHandle[] { h1, h2, h3, h4, h5 };

                //Handle = new OCPersistentStorage()
                //{
                //    Open = openDelegate,
                //    Read = readDelegate,
                //    Write = writeDelegate,
                //    Close = closeDelegate,
                //    Unlink = unlinkDelegate,
                //};
                Handle = new OCPersistentStorage()
                {
                    Open   = Marshal.GetFunctionPointerForDelegate(openDelegate),
                    Read   = Marshal.GetFunctionPointerForDelegate(readDelegate),
                    Write  = Marshal.GetFunctionPointerForDelegate(writeDelegate),
                    Close  = Marshal.GetFunctionPointerForDelegate(closeDelegate),
                    Unlink = Marshal.GetFunctionPointerForDelegate(unlinkDelegate),
                };
                pHandle = GCHandle.Alloc(Handle);
            }
Example #2
0
 internal void FileClose(IntPtr handle)
 {
     this.ThrowIfDisposed();
     if(this._FileCloseDelegate == null){
         this._FileCloseDelegate = this.LoadMethod<FileCloseDelegate>("gflFileClose");
     }
     this._FileCloseDelegate(handle);
 }