Exemple #1
0
        /// <summary>
        /// 在值读取器中读取该类型的实例。
        /// </summary>
        /// <param name="valueReader">值读取器</param>
        /// <returns>返回该类型的实例</returns>
        public T ReadValue(IValueReader valueReader)
        {
            var objectRW = XObjectRW.Create <T>(CurrentBindingFlags);

            valueReader.ReadObject(objectRW);

            return((T)objectRW.Content);
        }
Exemple #2
0
        public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader)
        {
            assert(CanWrite, "set");

            var value = ValueInterface <TValue> .Content.ReadValue(valueReader);

            _set(ref ((XObjectRW <TStruct>)objectRW).Reference, value);
        }
        /// <summary>
        /// 在值读取器中读取该类型的实例。
        /// </summary>
        /// <param name="valueReader">值读取器</param>
        /// <returns>返回该类型的实例</returns>
        public T ReadValue(IValueReader valueReader)
        {
            var objectRW = XObjectRW.Create <T>();

            valueReader.ReadObject(objectRW);

            return((T)objectRW.Content);
        }
Exemple #4
0
 public T ReadValue <T>(XObjectRW objectRW)
 {
     if ((object)this is XStructFieldInfo <T> typedThis)
     {
         return(typedThis._get(objectRW));
     }
     else
     {
         return(XConvert <TValue, T> .Convert(_get(objectRW)));
     }
 }
Exemple #5
0
 public void WriteValue <T>(XObjectRW objectRW, T value)
 {
     if ((object)this is XStructFieldInfo <T> typedThis)
     {
         typedThis._set(objectRW, value);
     }
     else
     {
         _set(objectRW, XConvert <T, TValue> .Convert(value));
     }
 }
Exemple #6
0
 public T ReadValue <T>(XObjectRW objectRW)
 {
     if (TypeInfo <T> .Int64TypeHandle == TypeInfo <TValue> .Int64TypeHandle)
     {
         return(Tools.Pointer.GetValue <T>(address));
     }
     else
     {
         return(XConvert <TValue, T> .Convert(Tools.Pointer.GetValue <TValue>(address)));
     }
 }
Exemple #7
0
 public void WriteValue <T>(XObjectRW objectRW, T value)
 {
     if (TypeInfo <T> .Int64TypeHandle == TypeInfo <TValue> .Int64TypeHandle)
     {
         Tools.Pointer.SetValue(address, value);
     }
     else
     {
         Tools.Pointer.SetValue(address, XConvert <T, TValue> .Convert(value));
     }
 }
Exemple #8
0
 public T ReadValue <T>(XObjectRW objectRW)
 {
     if (TypeInfo <T> .Int64TypeHandle == TypeInfo <TValue> .Int64TypeHandle)
     {
         return(((XLiteralFieldInfo <T>)(object) this).value);
     }
     else
     {
         return(XConvert <TValue, T> .Convert(value));
     }
 }
Exemple #9
0
        public void WriteValue <T>(XObjectRW objectRW, T value)
        {
            assert(CanWrite, "set");

            if ((object)this is XStaticPropertyInfo <T> typedThis)
            {
                typedThis._set(value);
            }
            else
            {
                _set(XConvert <T, TValue> .Convert(value));
            }
        }
Exemple #10
0
        public T ReadValue <T>(XObjectRW objectRW)
        {
            assert(CanRead, "get");

            if ((object)this is XStaticPropertyInfo <T> typedThis)
            {
                return(typedThis._get());
            }
            else
            {
                return(XConvert <TValue, T> .Convert(_get()));
            }
        }
Exemple #11
0
        public T ReadValue <T>(XObjectRW objectRW)
        {
            assert(CanRead, "get");

            if ((object)this is XStructPropertyInfo <TStruct, T> typedThis)
            {
                return(typedThis._get(ref Tools.Pointer.Box <TStruct>(objectRW.Address)));
            }
            else
            {
                return(XConvert <TValue, T> .Convert(_get(ref ((XObjectRW <TStruct>)objectRW).Reference)));
            }
        }
Exemple #12
0
 public void WriteTo(XObjectRW objectRW, IDataWriter <string> dataWriter)
 {
     if ((flags & XBindingFlags.SkipDefaultValue) == 0)
     {
         ValueInterface <TValue> .Content.WriteValue(dataWriter[name], value);
     }
     else
     {
         if (!TypeHelper.IsEmptyValue(value))
         {
             ValueInterface <TValue> .Content.WriteValue(dataWriter[name], value);
         }
     }
 }
Exemple #13
0
        public void WriteValue <T>(XObjectRW objectRW, T value)
        {
            assert(CanWrite, "set");

            if ((object)this is XStructPropertyInfo <TStruct, T> typedThis)
            {
                typedThis._set(ref ((XObjectRW <TStruct>)objectRW).Reference, value);
            }
            else
            {
                var tValue = XConvert <T, TValue> .Convert(value);

                _set(ref ((XObjectRW <TStruct>)objectRW).Reference, tValue);
            }
        }
Exemple #14
0
        public void WriteTo(XObjectRW objectRW, IDataWriter <string> dataWriter)
        {
            if ((flags & XBindingFlags.SkipDefaultValue) == 0)
            {
                ValueInterface <TValue> .Content.WriteValue(dataWriter[name], _get(ref ((XObjectRW <TStruct>)objectRW).Reference));
            }
            else
            {
                var value = _get(ref ((XObjectRW <TStruct>)objectRW).Reference);

                if (!TypeHelper.IsEmptyValue(value))
                {
                    ValueInterface <TValue> .Content.WriteValue(dataWriter[name], value);
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// 在数据写入器中写入该类型的实例。
        /// </summary>
        /// <param name="valueWriter">值写入器</param>
        /// <param name="value">该类型的实例</param>
        public void WriteValue(IValueWriter valueWriter, T value)
        {
            if (value is null)
            {
                valueWriter.DirectWrite(null);
            }
            else if (CheckDerivedInstance && TypeHandle != TypeHelper.GetTypeHandle(value))
            {
                /* 父类引用,子类实例时使用 Type 获取写入器。 */

                ValueInterface.WriteValue(valueWriter, value);
            }
            else
            {
                var objectRW = XObjectRW.Create <T>(GetBindingFlags(valueWriter));

                objectRW.Initialize(value);

                valueWriter.WriteObject(objectRW);
            }
        }
Exemple #16
0
        /// <summary>
        /// 在数据写入器中写入该类型的实例。
        /// </summary>
        /// <param name="valueWriter">值写入器</param>
        /// <param name="value">该类型的实例</param>
        public void WriteValue(IValueWriter valueWriter, T value)
        {
            if (value == null)
            {
                valueWriter.DirectWrite(null);

                return;
            }

            /* 父类引用,子类实例时使用 Type 获取写入器。 */
            if (CheckChildrenInstance && Int64TypeHandle != (long)TypeHelper.GetTypeHandle(value))
            {
                ValueInterface.GetInterface(value).Write(valueWriter, value);

                return;
            }

            var objectRW = XObjectRW.Create(typeof(T));

            objectRW.Initialize(value);

            valueWriter.WriteObject(objectRW);
        }
Exemple #17
0
        /// <summary>
        /// 在数据写入器中写入该类型的实例。
        /// </summary>
        /// <param name="valueWriter">值写入器</param>
        /// <param name="value">该类型的实例</param>
        public void WriteValue(IValueWriter valueWriter, T value)
        {
            if (value == null)
            {
                valueWriter.DirectWrite(null);

                return;
            }

            /* 父类引用,子类实例时使用 Type 获取写入器。 */
            if (CheckChildrenInstance && TypeHandle != TypeHelper.GetTypeHandle(value))
            {
                ValueInterface.WriteValue(valueWriter, value);

                return;
            }

            var objectRW = XObjectRW.Create <T>(CurrentBindingFlags);

            objectRW.Initialize(value);

            valueWriter.WriteObject(objectRW);
        }
Exemple #18
0
 TValue _get(XObjectRW objectRW)
 {
     return(Tools.Pointer.GetValue <TValue>((IntPtr)((long)objectRW.Address + offset)));
 }
Exemple #19
0
 public void WriteValue <T>(XObjectRW objectRW, T value)
 {
     _throw();
 }
Exemple #20
0
        public void OnReadValue(XObjectRW objectRW, IValueWriter valueWriter)
        {
            assert(CanRead, "get");

            ValueInterface <TValue> .Content.WriteValue(valueWriter, _get());
        }
Exemple #21
0
 public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader)
 {
     _throw();
 }
Exemple #22
0
 public void OnReadValue(XObjectRW objectRW, IValueWriter valueWriter)
 {
     ValueInterface <TValue> .Content.WriteValue(valueWriter, value);
 }
Exemple #23
0
 public XFieldValueRW CreateRW(XObjectRW objectRW)
 {
     return(new XFieldValueRW <TValue>(objectRW, this));
 }
Exemple #24
0
        public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader)
        {
            assert(CanWrite, "set");

            _set(ValueInterface <TValue> .Content.ReadValue(valueReader));
        }
Exemple #25
0
 public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader)
 {
     Tools.Pointer.SetValue(address, ValueInterface <TValue> .Content.ReadValue(valueReader));
 }
Exemple #26
0
 public void OnReadValue(XObjectRW objectRW, IValueWriter valueWriter)
 {
     ValueInterface <TValue> .Content.WriteValue(valueWriter, Tools.Pointer.GetValue <TValue>(address));
 }
Exemple #27
0
 TValue _get(XObjectRW objectRW)
 {
     return(Tools.Pointer.GetValue <TValue>((IntPtr)((long)objectRW.Pointer + TypeHelper.ObjectHandleSize + offset)));
 }
Exemple #28
0
 public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader)
 {
     _set(objectRW, ValueInterface <TValue> .Content.ReadValue(valueReader));
 }
Exemple #29
0
 void _set(XObjectRW objectRW, TValue value)
 {
     Tools.Pointer.SetValue((IntPtr)((long)objectRW.Address + offset), value);
 }
Exemple #30
0
 void _set(XObjectRW objectRW, TValue value)
 {
     Tools.Pointer.SetValue((IntPtr)((long)objectRW.Pointer + TypeHelper.ObjectHandleSize + offset), value);
 }