private MemberAccessPath FollowPath(Type type, string[] memberNames, IMemberProvider memberProvider) { var accessPath = new MemberAccessPath(); var bindingAttributes = BindingFlags.Instance | BindingFlags.Public; if (!memberProvider.IgnoreNonPublicMembers) { bindingAttributes |= BindingFlags.NonPublic; } foreach (var splitName in memberNames) { var members = type.GetMember(splitName, bindingAttributes); if (members == null || members.Length == 0) { return(null); } var sourceMember = members?[0]; type = sourceMember.GetMemberType(); accessPath.Add(sourceMember); } return(accessPath); }
private MemberAccessPath FollowPathFlattening(Type type, IEnumerable <string> memberNames, IMemberProvider memberProvider) { var accessPath = new MemberAccessPath(); var bindingAttributes = BindingFlags.Instance | BindingFlags.Public; if (!memberProvider.IgnoreNonPublicMembers) { bindingAttributes |= BindingFlags.NonPublic; } foreach (var splitName in memberNames) { var members = type.GetMember(splitName, bindingAttributes); if (members.Length == 0) { var getMethodPrefixes = new string[] { "Get_", "Get", "get", "get_" }; foreach (var prefix in getMethodPrefixes) { members = type.GetMember(prefix + splitName, bindingAttributes); if (members.Length > 0) { break; } } if (members.Length == 0) { return(null); } } var sourceMember = members?[0]; type = sourceMember.GetMemberType(); accessPath.Add(sourceMember); } return(accessPath); }
private MemberAccessPath FollowPathFlattening(Type type, IEnumerable <string> memberNames, IMemberProvider memberProvider) { var accessPath = new MemberAccessPath(type); foreach (var splitName in memberNames) { var members = memberProvider.GetMembers(type) .Where(m => m.Name == splitName).ToArray(); if (members.Length == 0) { var getMethodPrefixes = new string[] { "Get_", "Get", "get", "get_" }; foreach (var prefix in getMethodPrefixes) { members = memberProvider.GetMembers(type) .Where(m => m.Name == prefix + splitName).ToArray(); if (members.Length > 0) { break; } } if (members.Length == 0) { return(null); } } var sourceMember = members?[0]; type = sourceMember.GetMemberType(); accessPath.Add(sourceMember); } return(accessPath); }