コード例 #1
0
        public static TRet As <TRet>(this Object t, Expression <Func <TRet, object> > expr, object val)
        {
            var memberAccess = new ExpressionWithMemberAccess <TRet, object>();

            memberAccess.Lambda(expr);
            var propertyName   = memberAccess.MemberName;
            var createInstance = new CreateInstanceFromValues <TRet>(t.GetType());

            return(createInstance.Create(t, new[] { new NameAndValue(propertyName, val) }));
        }
コード例 #2
0
        public static TRet As <TRet>(this Object t, Expression <Func <TRet, bool> > expr)
        {
            var eqeq = new ExpressionWithEqualEqualOrCall <TRet>(t);

            eqeq.Lambda(expr);
            var propertyNameAndValues = eqeq.Parsed.ToArray();
            var createInstance        = new CreateInstanceFromValues <TRet>(t.GetType());

            return(createInstance.Create(t, propertyNameAndValues));
        }
コード例 #3
0
        public static T With <T>(this T t, Expression <Action <T> > expr)
        {
            var eqeq = new ExpressionWithEqualEqualOrCall <T>(t);

            eqeq.Lambda(expr);
            var propertyNameAndValues = eqeq.Parsed.ToArray();
            var createInstance        = new CreateInstanceFromValues <T>();

            return(createInstance.Create(t, propertyNameAndValues));
        }
コード例 #4
0
        public static T With <T>(this T t, Expression <Func <T, bool> > expr)
        {
            var eqeq = new ExpressionWithEqualEqualOrCall <T>(t);

            eqeq.Lambda(expr);

            var createInstance = new CreateInstanceFromValues <T> ();

            return(createInstance.Create(t, eqeq.Parsed.ToArray()));
        }
コード例 #5
0
        public static T With <T, TVal>(this T t, Expression <Func <T, TVal> > expr, TVal val)
        {
            var memberAccess = new ExpressionWithMemberAccess <T, TVal>();

            memberAccess.Lambda(expr);
            var propertyName = memberAccess.MemberName;

            var createInstance = new CreateInstanceFromValues <T> ();

            return(createInstance.Create(t, new[] { NameAndValues.Create(propertyName, val) }));
        }
コード例 #6
0
        public static TRet As <TRet>(this Object t, IDictionary <string, object> parameters)
        {
            var createInstance = new CreateInstanceFromValues <TRet>(t.GetType());

            return(createInstance.Create(t, parameters.Select(v => new NameAndValue(v.Key, v.Value))));
        }
コード例 #7
0
        public static T With <T>(this T t, IDictionary <string, object> parameters)
        {
            var createInstance = new CreateInstanceFromValues <T> ();

            return(createInstance.Create(t, parameters));
        }