Exemplo n.º 1
0
        public static void CopyProp(
            this object sourceObj,
            string sourcePropName,
            object targetObj,
            string targetPropName = null,
            IValConverter converter = null
        )
        {
            object sourcePropValue = sourceObj;

            if (sourcePropName != null)
            {
                sourcePropValue = GetPropValue(sourceObj, sourcePropName);
            }

            object targetPropValue = sourcePropValue;

            if (converter != null)
            {
                targetPropValue = converter.Convert(sourcePropValue);
            }

            if (targetPropName == null)
                targetPropName = sourcePropName;

            ReflectionUtils.SetPropValue(targetObj, targetPropName, targetPropValue);
        }
Exemplo n.º 2
0
        public static void CopyProp
        (
            this object sourceObj,
            string sourcePropName,
            object targetObj,
            string targetPropName   = null,
            IValConverter converter = null
        )
        {
            object sourcePropValue = sourceObj;

            if (sourcePropName != null)
            {
                sourcePropValue = GetPropValue(sourceObj, sourcePropName);
            }

            object targetPropValue = sourcePropValue;

            if (converter != null)
            {
                targetPropValue = converter.Convert(sourcePropValue);
            }

            if (targetPropName == null)
            {
                targetPropName = sourcePropName;
            }

            ReflectionUtils.SetPropValue(targetObj, targetPropName, targetPropValue);
        }
Exemplo n.º 3
0
        ToDelegate <InputType, OutputType>
        (
            this IValConverter <InputType, OutputType> converter
        )
        {
            if (converter == null)
            {
                return(null);
            }

            return(converter.Convert);
        }