Example #1
0
        public void MemberInitOperationRead()
        {
            var src = new NotificationObject<string>()
            {
                Value1 = "Test",
            };

            var op = new MemberInitOperation<NotificationObject<string>>(new OperationContext(),
                Expression.MemberInit(
                    Expression.New(typeof(NotificationObject<string>)),
                    Expression.Bind(typeof(NotificationObject<string>).GetProperty("Value2"),
                        Expression.MakeMemberAccess(
                            Expression.Constant(src),
                            typeof(NotificationObject<string>).GetProperty("Value1")))));
            Assert.AreEqual("Test", op.Value.Value2);
        }
Example #2
0
        public void MemberInitOperationRead()
        {
            var src = new NotificationObject <string>()
            {
                Value1 = "Test",
            };

            var op = new MemberInitOperation <NotificationObject <string> >(new OperationContext(),
                                                                            Expression.MemberInit(
                                                                                Expression.New(typeof(NotificationObject <string>)),
                                                                                Expression.Bind(typeof(NotificationObject <string>).GetProperty("Value2"),
                                                                                                Expression.MakeMemberAccess(
                                                                                                    Expression.Constant(src),
                                                                                                    typeof(NotificationObject <string>).GetProperty("Value1")))));

            Assert.AreEqual("Test", op.Value.Value2);
        }