Пример #1
0
        /// <summary>Returns an enumerator that iterates throught this accessor.</summary>
        /// <returns>An enumerator to walk through the acessor items.</returns>
        public IEnumerator <T> GetEnumerator()
        {
            if (Handle == IntPtr.Zero)
            {
                throw new ObjectDisposedException(base.GetType().Name);
            }

            IntPtr tmp      = MemoryNative.Alloc(Marshal.SizeOf(typeof(IntPtr)));
            uint   position = 0;

            try
            {
                while (eina_accessor_data_get(Handle, position, tmp))
                {
                    IntPtr data = (IntPtr)Marshal.PtrToStructure(tmp, typeof(IntPtr));
                    yield return(Convert(data));

                    position += 1;
                }
            }
            finally
            {
                MemoryNative.Free(tmp);
            }
        }
Пример #2
0
        public static IntPtr ManagedStringToNativeUtf8Alloc(string managedString)
        {
            if (managedString == null)
            {
                return(IntPtr.Zero);
            }

            byte[] strbuf = Encoding.UTF8.GetBytes(managedString);
            IntPtr native = MemoryNative.Alloc(strbuf.Length + 1);

            Marshal.Copy(strbuf, 0, native, strbuf.Length);
            Marshal.WriteByte(native + strbuf.Length, 0); // write the terminating null
            return(native);
        }