예제 #1
0
        public void AddImplTest()
        {
            XConvert.AddImplFactory(new MyImplFactory());

            AreEqual("2", XConvert.Convert <string, StringBuilder>("2").ToString());
            AreEqual("2", XConvert.Convert <int, StringBuilder>(2).ToString());
        }
예제 #2
0
 /// <summary>
 /// 转换键,并返回该键对应的值写入器。
 /// </summary>
 /// <param name="key">键</param>
 /// <returns>返回值写入器</returns>
 public IValueWriter this[TOut key]
 {
     get
     {
         return(dataWriter[XConvert <TOut, TIn> .Convert(key)]);
     }
 }
예제 #3
0
 public IValueWriter this[TIn key]
 {
     get
     {
         return(dataWriter[XConvert <TIn, TOut> .Convert(key)]);
     }
 }
예제 #4
0
 public bool Filter(ValueFilterInfo <TIn> valueInfo)
 {
     return(valueFilter.Filter(new ValueFilterInfo <TOut>(
                                   XConvert <TOut> .Convert(valueInfo.Key),
                                   valueInfo.Type,
                                   valueInfo.ValueCopyer
                                   )));
 }
예제 #5
0
        public TDestination?Convert(TSource value)
        {
            if (value is null)
            {
                return(null);
            }

            return(XConvert.Convert <TSource, TDestination>(value));
        }
예제 #6
0
        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))));
        }
예제 #7
0
        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));
        }
예제 #9
0
        public T ReadValue <T>(object obj)
        {
            if (this is XLiteralFieldInfo <T> me)
            {
                return(me.value);
            }

            return(XConvert <TValue, T> .Convert(value));
        }
예제 #10
0
        public T ReadValue <T>(object obj)
        {
            if (typeof(T) == typeof(TValue))
            {
                return(Unsafe.Read <T>(address));
            }

            return(XConvert <T> .Convert(Value));
        }
예제 #11
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)));
     }
 }
예제 #12
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));
     }
 }
예제 #13
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));
     }
 }
예제 #14
0
        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)));
        }
예제 #15
0
        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));
        }
예제 #16
0
        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));
        }
예제 #17
0
        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))));
        }
예제 #18
0
        public void WriteValue <T>(object obj, T value)
        {
            if (typeof(T) == typeof(TValue))
            {
                Unsafe.Write(address, value);

                return;
            }

            Value = XConvert <TValue> .Convert(value);
        }
예제 #19
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));
     }
 }
예제 #20
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)));
     }
 }
예제 #21
0
        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()));
        }
예제 #22
0
        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));
        }
예제 #23
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()));
            }
        }
예제 #24
0
        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));
        }
예제 #25
0
        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));
        }
예제 #26
0
        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));
        }
예제 #27
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)));
            }
        }
예제 #28
0
        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));
        }
예제 #29
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));
            }
        }
예제 #30
0
        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));
        }