コード例 #1
0
        public static IEnumerable <SettableInfo> Decompose <T, U>(Expression <PropertyPath <T, U> .Property> property)
        {
            List <SettableInfo> properties = new List <SettableInfo>();

            Expression body = property.Body;

            while (!(body is ParameterExpression))
            {
                var bodyUe = body as UnaryExpression;

                if (bodyUe != null)
                {
                    MemberExpression memEx = bodyUe.Operand as MemberExpression;
                    properties.Add(SettableInfo.New(memEx.Member));

                    body = memEx.Expression;
                    continue;
                }

                var bodyMe = body as MemberExpression;

                if (bodyMe != null)
                {
                    properties.Add(SettableInfo.New(bodyMe.Member));

                    body = bodyMe.Expression;
                    continue;
                }
            }

            return(properties.Reverse <SettableInfo>());
        }
コード例 #2
0
ファイル: SettableInfo.cs プロジェクト: mjr129/mgui
        public static SettableInfo[] GetSettables(this Type type)
        {
            var fields     = type.GetFields().Select(z => SettableInfo.New(z));
            var properties = type.GetProperties().Select(z => SettableInfo.New(z));

            return(fields.Concat(properties).ToArray());
        }