Пример #1
0
        public static Type ResultType(this MemberInfo memberInfo)
        {
            var resultType = memberInfo.MaybeAs <PropertyInfo>().Bind(x => x.PropertyType)
                             .OrElse(() => memberInfo.MaybeAs <MethodInfo>().Bind(x => x.ReturnType))
                             .OrElse(() => memberInfo.MaybeAs <FieldInfo>().Bind(x => x.FieldType)).Value;

            return(resultType);
        }
Пример #2
0
 public static Type ResultType(this MemberInfo memberInfo)
 {
     return(memberInfo.MaybeAs <PropertyInfo>(true)
            .Bind((PropertyInfo x) => x.PropertyType)
            .OrElse(() =>
                    memberInfo.MaybeAs <MethodInfo>(true)
                    .Bind((MethodInfo x) => x.ReturnType))
            .OrElse(() =>
                    memberInfo.MaybeAs <FieldInfo>(true)
                    .Bind((FieldInfo x) => x.FieldType)).Value);
 }