/// <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); }
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); }
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))); } }
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)); } }
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))); } }
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)); } }
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)); } }
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)); } }
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())); } }
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))); } }
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); } } }
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); } }
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); } } }
/// <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); } }
/// <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); }
/// <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); }
TValue _get(XObjectRW objectRW) { return(Tools.Pointer.GetValue <TValue>((IntPtr)((long)objectRW.Address + offset))); }
public void WriteValue <T>(XObjectRW objectRW, T value) { _throw(); }
public void OnReadValue(XObjectRW objectRW, IValueWriter valueWriter) { assert(CanRead, "get"); ValueInterface <TValue> .Content.WriteValue(valueWriter, _get()); }
public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader) { _throw(); }
public void OnReadValue(XObjectRW objectRW, IValueWriter valueWriter) { ValueInterface <TValue> .Content.WriteValue(valueWriter, value); }
public XFieldValueRW CreateRW(XObjectRW objectRW) { return(new XFieldValueRW <TValue>(objectRW, this)); }
public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader) { assert(CanWrite, "set"); _set(ValueInterface <TValue> .Content.ReadValue(valueReader)); }
public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader) { Tools.Pointer.SetValue(address, ValueInterface <TValue> .Content.ReadValue(valueReader)); }
public void OnReadValue(XObjectRW objectRW, IValueWriter valueWriter) { ValueInterface <TValue> .Content.WriteValue(valueWriter, Tools.Pointer.GetValue <TValue>(address)); }
TValue _get(XObjectRW objectRW) { return(Tools.Pointer.GetValue <TValue>((IntPtr)((long)objectRW.Pointer + TypeHelper.ObjectHandleSize + offset))); }
public void OnWriteValue(XObjectRW objectRW, IValueReader valueReader) { _set(objectRW, ValueInterface <TValue> .Content.ReadValue(valueReader)); }
void _set(XObjectRW objectRW, TValue value) { Tools.Pointer.SetValue((IntPtr)((long)objectRW.Address + offset), value); }
void _set(XObjectRW objectRW, TValue value) { Tools.Pointer.SetValue((IntPtr)((long)objectRW.Pointer + TypeHelper.ObjectHandleSize + offset), value); }