Exemple #1
0
        private static string GetMemberName(SubInsertTreeExpression item, out MemberExpression subMemberException)
        {
            string     subMemberName = null;
            Expression lambdaExpression;

            if (item.Expression is LambdaExpression)
            {
                lambdaExpression = (item.Expression as LambdaExpression).Body;
            }
            else
            {
                lambdaExpression = item.Expression;
            }
            if (lambdaExpression is UnaryExpression)
            {
                lambdaExpression = (lambdaExpression as UnaryExpression).Operand;
            }
            subMemberException = lambdaExpression as MemberExpression;
            subMemberName      = subMemberException.Member.Name;
            return(subMemberName);
        }
Exemple #2
0
        private List <SubInsertTreeExpression> GetSubInsertTree(Expression expression)
        {
            List <SubInsertTreeExpression> resul = new List <SubInsertTreeExpression>();

            if (expression is ListInitExpression)
            {
                ListInitExpression exp = expression as ListInitExpression;
                foreach (var item in exp.Initializers)
                {
                    SubInsertTreeExpression tree = new SubInsertTreeExpression();
                    var memInit = item.Arguments[0] as MemberInitExpression;
                    if (memInit.Bindings != null)
                    {
                        MemberAssignment memberAssignment = (MemberAssignment)memInit.Bindings[0];
                        tree.Expression = memberAssignment.Expression;
                    }
                    resul.Add(tree);
                }
            }
            else
            {
            }
            return(resul);
        }
Exemple #3
0
        private static string GetChildName(SubInsertTreeExpression item, MemberExpression subMemberException)
        {
            string           childName;
            MemberExpression listMember = null;

            if (subMemberException.Expression is MethodCallExpression)
            {
                listMember = (subMemberException.Expression as MethodCallExpression).Arguments.First() as MemberExpression;
            }
            else
            {
                listMember = (subMemberException.Expression as MemberExpression);
            }
            if (listMember == null && item.Expression is LambdaExpression)
            {
                listMember = (item.Expression as LambdaExpression).Body as MemberExpression;
            }
            if (listMember == null && item.Expression is MemberExpression)
            {
                listMember = item.Expression  as MemberExpression;
            }
            childName = listMember.Member.Name;
            return(childName);
        }