예제 #1
0
        public static bool TryGet(MemberInfo info, out AssignableMember member)
        {
            Ensure.Argument.NotNull(info, nameof(info));

            var(m, e) = GetImpl(info);
            member    = m;
            return(e == null);
        }
예제 #2
0
        private static (AssignableMember member, Exception exception) GetImpl(MemberInfo info)
        {
            if (!IsValidMemberType(info.MemberType))
            {
                var e = new ArgumentException(
                    "Only field or property is considered as assignable member.", nameof(info));
                return(null, e);
            }

            if (!_instances.TryGetValue(info, out var member))
            {
                member = new AssignableMember(info);
                _instances.Add(info, member);
            }
            return(member, null);
        }
예제 #3
0
 public static bool TryGet(Type type, string memberName, BindingFlags bindingAttr, out AssignableMember member)
 {
     var(m, e) = GetImpl(type, memberName, bindingAttr);
     member    = m;
     return(e == null);
 }
예제 #4
0
 public static bool TryGet(Type type, string memberName, out AssignableMember member)
 {
     return(TryGet(type, memberName, BindingAttributes.All, out member));
 }