Пример #1
0
            public IntPtr Init(string name, Func <NativeArray, NativeArray, int> cmp)
            {
                // TODO: Complete member initialization
                this.cmp = cmp;

                this.namePinned = GCHandle.Alloc(
                    Encoding.ASCII.GetBytes(name),
                    GCHandleType.Pinned);

                var thisHandle = GCHandle.Alloc(this);

                var chandle = LevelDBInterop.leveldb_comparator_create(
                    GCHandle.ToIntPtr(thisHandle),
                    Marshal.GetFunctionPointerForDelegate(destructor),
                    Marshal.GetFunctionPointerForDelegate(compare),
                    Marshal.GetFunctionPointerForDelegate(nameAccessor)
                    );

                if (chandle == default(IntPtr))
                {
                    thisHandle.Free();
                }
                return(chandle);
            }