Example #1
0
        public PinBlittable(object item)
        {
            if (item != null)
            {
                this.handle = new SafePinHandle(item);
            }
            else
            {
                this.handle = null;
            }

            this.item    = item;
            this.address = this.AddrOfPinnedObject();
        }
Example #2
0
        public PinArray(IEnumerable enumerable, PinCallback pinCallback)
        {
            if (enumerable != null)
            {
                var count = this.CountItems(enumerable);
                this.nodes       = new IPinNode[count];
                this.pinnedItems = new IntPtr[count];
                this.arrayHandle = new SafePinHandle(this.pinnedItems);

                int i = 0;
                foreach (var item in enumerable)
                {
                    this.nodes[i]       = pinCallback(item);
                    this.pinnedItems[i] = this.nodes[i].AddrOfPinnedObject();
                    i++;
                }
            }
        }