Пример #1
0
        static ValueGetter <T> BuildValueGetter <T>()
        {
            var enumCount = ReflectionUtils.CountEnumerables(typeof(T));

            if (enumCount > 0)
            {
                var singleGetter     = ValueGetters.GetValueGetter <T>(true, false);
                var enumerableGetter = ValueGetters.GetValueGetter <T>(enumCount > 1, true);

                return(new ValueGetter <T>(singleGetter, enumerableGetter));
            }
            else
            {
                var getter = ValueGetters.GetValueGetter <T>(false, false);
                return(new ValueGetter <T>(getter));
            }
        }
Пример #2
0
        static PropertySetter <TObject> BuildPropertySetter <TObject, TProperty>(string propertyName)
        {
            var enumCount = ReflectionUtils.CountEnumerables(typeof(TProperty));

            if (enumCount > 0)
            {
                var singleGetter = ValueGetters.GetValueGetter <TProperty>(true, false);
                var singleSetter = BuildPropertySetter <TObject, TProperty>(propertyName, singleGetter);

                var enumerableGetter = ValueGetters.GetValueGetter <TProperty>(enumCount > 1, true);
                var enumerableSetter = BuildPropertySetter <TObject, TProperty>(propertyName, enumerableGetter);

                return(new PropertySetter <TObject>(singleSetter, enumerableSetter));
            }
            else
            {
                var getter = ValueGetters.GetValueGetter <TProperty>(false, false);
                var setter = BuildPropertySetter <TObject, TProperty>(propertyName, getter);

                return(new PropertySetter <TObject>(setter));
            }
        }