Пример #1
0
        internal CTRunDelegateCallbacks GetCallbacks()
        {
            var callbacks = new CTRunDelegateCallbacks()
            {
                version = CTRunDelegateVersion.Version1,
                dealloc = Deallocate,
            };

            var        flags = BindingFlags.Public | BindingFlags.Instance;
            MethodInfo m;

            if ((m = this.GetType().GetMethod("GetAscent", flags)) != null &&
                m.DeclaringType != typeof(CTRunDelegateOperations))
            {
                callbacks.getAscent = GetAscent;
            }
            if ((m = this.GetType().GetMethod("GetDescent", flags)) != null &&
                m.DeclaringType != typeof(CTRunDelegateOperations))
            {
                callbacks.getDescent = GetDescent;
            }
            if ((m = this.GetType().GetMethod("GetWidth", flags)) != null &&
                m.DeclaringType != typeof(CTRunDelegateOperations))
            {
                callbacks.getWidth = GetWidth;
            }

            return(callbacks);
        }
Пример #2
0
        static IntPtr Create(CTRunDelegateOperations operations)
        {
            if (operations == null)
            {
                throw new ArgumentNullException(nameof(operations));
            }

            CTRunDelegateCallbacks callbacks = operations.GetCallbacks();

            return(CTRunDelegateCreate(ref callbacks, operations.Handle));
        }
Пример #3
0
        internal CTRunDelegateCallbacks GetCallbacks()
        {
            var callbacks = new CTRunDelegateCallbacks()
            {
                version    = 1,              // kCTRunDelegateVersion1
                dealloc    = Deallocate,
                getAscent  = GetAscent,
                getDescent = GetDescent,
                getWidth   = GetWidth,
            };

            return(callbacks);
        }
Пример #4
0
        CTRunDelegateCallbacks callbacks;         // prevent GC since they are called from native code

        public CTRunDelegate(CTRunDelegateOperations operations)
        {
            if (operations == null)
            {
                throw ConstructorError.ArgumentNull(this, "operations");
            }

            callbacks = operations.GetCallbacks();
            handle    = CTRunDelegateCreate(callbacks, GCHandle.ToIntPtr(operations.handle));
            if (handle == IntPtr.Zero)
            {
                throw ConstructorError.Unknown(this);
            }
        }
Пример #5
0
 static extern IntPtr CTRunDelegateCreate(ref CTRunDelegateCallbacks callbacks, IntPtr refCon);