Example #1
0
        protected MemberInfo Normalize(MemberInfo memberInfo)
        {
            if (memberInfo is FickleMethodInfo)
            {
                var methodInfo = (FickleMethodInfo)memberInfo;
                var name       = this.normalize(methodInfo.Name);
                var prefix     = reservedKeywords.Contains(name) ? replacementPrefix : "";

                if (name != methodInfo.Name || prefix != "")
                {
                    methodInfo = new FickleMethodInfo(methodInfo.DeclaringType, methodInfo.ReturnType, prefix + name, methodInfo.GetParameters(), methodInfo.IsStatic);

                    return(methodInfo);
                }
            }
            else if (memberInfo is FicklePropertyInfo)
            {
                var propertyInfo = (FicklePropertyInfo)memberInfo;
                var name         = this.normalize(propertyInfo.Name);
                var prefix       = reservedKeywords.Contains(name) ? replacementPrefix : "";

                if (name != propertyInfo.Name || prefix != "")
                {
                    propertyInfo = new FicklePropertyInfo(propertyInfo.DeclaringType, propertyInfo.PropertyType, prefix + name);

                    return(propertyInfo);
                }
            }

            return(memberInfo);
        }
Example #2
0
        protected MemberInfo Normalize(MemberInfo memberInfo)
        {
            if (memberInfo is FickleMethodInfo)
            {
                var methodInfo = (FickleMethodInfo)memberInfo;
                var name = this.normalize(methodInfo.Name);
                var prefix = reservedKeywords.Contains(name) ? replacementPrefix : "";

                if (name != methodInfo.Name || prefix != "")
                {
                    methodInfo = new FickleMethodInfo(methodInfo.DeclaringType, methodInfo.ReturnType, prefix + name, methodInfo.GetParameters(), methodInfo.IsStatic);

                    return methodInfo;
                }
            }
            else if (memberInfo is FicklePropertyInfo)
            {
                var propertyInfo = (FicklePropertyInfo)memberInfo;
                var name = this.normalize(propertyInfo.Name);
                var prefix = reservedKeywords.Contains(name) ? replacementPrefix : "";

                if (name != propertyInfo.Name || prefix != "")
                {
                    propertyInfo = new FicklePropertyInfo(propertyInfo.DeclaringType, propertyInfo.PropertyType, prefix + name);

                    return propertyInfo;
                }
            }

            return memberInfo;
        }
Example #3
0
        public static MemberExpression Property(Expression instance, Type propertyType, string propertyName)
        {
            var propertyInfo = instance.Type.GetProperty(propertyName);

            if (propertyInfo == null || propertyInfo is FicklePropertyInfo)
            {
                propertyInfo = new FicklePropertyInfo(instance.Type, propertyType, propertyName);
            }

            return(Expression.Property(instance, propertyInfo));
        }
Example #4
0
        public static MemberExpression Property(Expression instance, Type propertyType, string propertyName)
        {
            var propertyInfo = instance.Type.GetProperty(propertyName);

            if (propertyInfo == null || propertyInfo is FicklePropertyInfo)
            {
                propertyInfo = new FicklePropertyInfo(instance.Type, propertyType, propertyName);
            }

            return Expression.Property(instance, propertyInfo);
        }