예제 #1
0
        /// <summary>
        /// 设置当前实例指定类型的值读写器。
        /// </summary>
        /// <typeparam name="T">指定类型</typeparam>
        /// <param name="valueInterface">值读写器</param>
        public void SetValueInterface <T>(IValueInterface <T> valueInterface)
        {
            if (valueInterface == null)
            {
                throw new ArgumentNullException(nameof(valueInterface));
            }

            lock (this)
            {
                if (id == 0)
                {
                    id = (long)Unsafe.AsPointer(ref Unsafe.AsRef(this));
                }

                ValueInterface <T> .SetTargetedInterface(this, valueInterface);
            }
        }
예제 #2
0
        /// <summary>
        /// 设置当前实例指定类型的值读写器。
        /// </summary>
        /// <typeparam name="T">指定类型</typeparam>
        /// <param name="valueInterface">值读写器</param>
        public void SetValueInterface <T>(IValueInterface <T> valueInterface)
        {
            if (valueInterface == null)
            {
                throw new ArgumentNullException(nameof(valueInterface));
            }

            lock (this)
            {
                if (Id == 0)
                {
                    Id = (long)Pointer.UnBox(this);
                }

                ValueInterface <T> .SetTargetedInterface(Id, valueInterface);
            }
        }
예제 #3
0
        /// <summary>
        /// 设置对象读写器接口为 XObjectInterface,并设置一个支持针对性接口的对象的默认绑定标识。
        /// </summary>
        /// <param name="targeted">支持针对性接口的对象</param>
        /// <param name="flags">默认绑定标识</param>
        public static void SetXObjectRWFlags(this ITargetedBind targeted, XBindingFlags flags)
        {
            ValueInterface.DefaultObjectInterfaceType = typeof(XObjectInterface <>);

            ValueInterface <XAssistant> .SetTargetedInterface(targeted, new XAssistant(flags));
        }