public void AddImplTest() { XConvert.AddImplFactory(new MyImplFactory()); AreEqual("2", XConvert.Convert <string, StringBuilder>("2").ToString()); AreEqual("2", XConvert.Convert <int, StringBuilder>(2).ToString()); }
/// <summary> /// 转换键,并返回该键对应的值写入器。 /// </summary> /// <param name="key">键</param> /// <returns>返回值写入器</returns> public IValueWriter this[TOut key] { get { return(dataWriter[XConvert <TOut, TIn> .Convert(key)]); } }
public IValueWriter this[TIn key] { get { return(dataWriter[XConvert <TIn, TOut> .Convert(key)]); } }
public bool Filter(ValueFilterInfo <TIn> valueInfo) { return(valueFilter.Filter(new ValueFilterInfo <TOut>( XConvert <TOut> .Convert(valueInfo.Key), valueInfo.Type, valueInfo.ValueCopyer ))); }
public TDestination?Convert(TSource value) { if (value is null) { return(null); } return(XConvert.Convert <TSource, TDestination>(value)); }
public T ReadValue <T>(object obj) { if (typeof(T) == typeof(TValue)) { return(Unsafe.ReadUnaligned <T>(ref GetAddress(obj))); } return(XConvert <T> .Convert(Unsafe.ReadUnaligned <TValue>(ref GetAddress(obj)))); }
public T ReadValue <T>(object obj) { if (TypeInfo <T> .Int64TypeHandle == TypeInfo <TValue> .Int64TypeHandle) { return(Pointer.GetValue <T>(GetAddress(obj))); } return(XConvert <TValue, T> .Convert(Pointer.GetValue <TValue>(GetAddress(obj)))); }
public T ReadValue <T>(object obj) { if (typeof(T) == typeof(TValue)) { return(Unsafe.As <TValue, T>(ref value)); } return(XConvert <T> .Convert(value)); }
public T ReadValue <T>(object obj) { if (this is XLiteralFieldInfo <T> me) { return(me.value); } return(XConvert <TValue, T> .Convert(value)); }
public T ReadValue <T>(object obj) { if (typeof(T) == typeof(TValue)) { return(Unsafe.Read <T>(address)); } return(XConvert <T> .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 ((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(((XLiteralFieldInfo <T>)(object) this).value); } else { return(XConvert <TValue, T> .Convert(value)); } }
public T ReadValue <T>(object obj) { Assert(CanRead, "get"); if (_get is XClassGetValueHandler <T> __get) { return(__get(obj)); } return(XConvert <TValue, T> .Convert(_get(obj))); }
public void WriteValue <T>(object obj, T value) { if (typeof(T) == typeof(TValue)) { Unsafe.WriteUnaligned(ref GetAddress(obj), value); return; } Unsafe.WriteUnaligned(ref GetAddress(obj), XConvert <TValue> .Convert(value)); }
public void WriteValue <T>(object obj, T value) { if (TypeInfo <T> .Int64TypeHandle == TypeInfo <TValue> .Int64TypeHandle) { Pointer.SetValue(GetAddress(obj), value); return; } Pointer.SetValue(GetAddress(obj), XConvert <T, TValue> .Convert(value)); }
public T ReadValue <T>(object obj) { Assert(CanRead, "get"); if (_get is XStructGetValueHandler <TStruct, T> __get) { return(__get(ref GetRef(obj))); } return(XConvert <TValue, T> .Convert(_get(ref GetRef(obj)))); }
public void WriteValue <T>(object obj, T value) { if (typeof(T) == typeof(TValue)) { Unsafe.Write(address, value); return; } Value = XConvert <TValue> .Convert(value); }
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 ((object)this is XStructFieldInfo <T> typedThis) { return(typedThis._get(objectRW)); } else { return(XConvert <TValue, T> .Convert(_get(objectRW))); } }
public T ReadValue <T>(object obj) { Assert(CanRead, "get"); if (_get is XStaticGetValueHandler <T> ) { var __get = _get as XStaticGetValueHandler <T>; return(__get()); } return(XConvert <TValue, T> .Convert(_get())); }
public void WriteValue <T>(object obj, T value) { Assert(CanWrite, "set"); if (_set is XStructSetValueHandler <TStruct, T> __set) { __set(ref GetRef(obj), value); return; } _set(ref GetRef(obj), 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 void WriteValue <T>(object obj, T value) { Assert(CanWrite, "set"); if (typeof(T) == typeof(TValue)) { _set(obj, Unsafe.As <T, TValue>(ref value)); return; } _set(obj, XConvert <TValue> .Convert(value)); }
public void WriteValue <T>(object obj, T value) { Assert(CanWrite, "set"); if (_set is XClassSetValueHandler <T> __set) { __set(obj, value); return; } _set(obj, XConvert <T, TValue> .Convert(value)); }
public T ReadValue <T>(object obj) { Assert(CanRead, "get"); var value = _get(obj); if (typeof(T) == typeof(TValue)) { return(Unsafe.As <TValue, T>(ref value)); } return(XConvert <T> .Convert(value)); }
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 WriteValue <T>(object obj, T value) { Assert(CanWrite, "set"); if (typeof(T) == typeof(TValue)) { _set(ref GetRef(obj), (TValue)(object)value); return; } _set(ref GetRef(obj), XConvert <TValue> .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 void WriteValue <T>(object obj, T value) { Assert(CanWrite, "set"); if (_set is XStaticSetValueHandler <T> ) { var __set = _set as XStaticSetValueHandler <T>; __set(value); return; } _set(XConvert <T, TValue> .Convert(value)); }