本文整理汇总了C#中System.Reflection.MemberInfo.Where方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.Where方法的具体用法?C# MemberInfo.Where怎么用?C# MemberInfo.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.Where方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterMembers
private MemberInfo[] FilterMembers(MemberInfo[] members)
{
var ignore = new[] {"GetType", "ToString", "CompareTo", "GetTypeCode", "Equals", "GetHashCode"};
return
members.Where(
m =>
!(m.MemberType == MemberTypes.Constructor || m.MemberType == MemberTypes.NestedType ||
ignore.Contains(m.Name))).ToArray();
}
示例2: PropertyDropDown
private void PropertyDropDown(BindingBase.BindingInfo info)
{
var type = Target.Context.DataType;
var members = new MemberInfo[0];
// filter
switch (info.Filters)
{
case BindingBase.BindingFilter.Commands:
members = EditorMembersHelper.GetMethods(type);
break;
case BindingBase.BindingFilter.Properties:
members = EditorMembersHelper.GetProperties(type);
break;
}
//filter
if (info.FilterTypes != null)
{
members = members.Where(o => info.FilterTypes.Any(t => ValidType(t, o.GetParamaterType()))).ToArray();
}
if (members.Length == 0)
{
EditorGUILayout.LabelField(string.Format("{0}->{1} has no valid members.", info.BindingName, type.Name));
return;
}
var labels = members.Select(o => string.Format("{0} : {1}", o.Name, o.GetParamaterType())).ToList();
var names = members.Select(o => o.Name).ToList();
labels.Insert(0, "Null");
names.Insert(0, "");
var index = Array.IndexOf(names.ToArray(), info.MemberName);
var i = EditorGUILayout.Popup(info.BindingName, index, labels.ToArray());
if (i != index)
{
info.MemberName = names[i];
EditorUtility.SetDirty(target);
}
}
示例3: GetPublicUnpreventedMembers
private static IEnumerable<SerializingMember> GetPublicUnpreventedMembers( MemberInfo[] members )
{
return members.Where(
member => member.GetIsPublic()
#if !SILVERLIGHT && !NETFX_CORE
&& !Attribute.IsDefined( member, typeof( NonSerializedAttribute ) )
#endif // !SILVERLIGHT && !NETFX_CORE
&& !member.IsDefined( typeof( MessagePackIgnoreAttribute ) )
).Select( member => new SerializingMember( member, new DataMemberContract( member ) ) );
}
示例4: AreAccessorsValid
private static bool AreAccessorsValid(MemberTypes memberType, MemberInfo[] accessors, out string errorMessage)
{
errorMessage = string.Empty;
if (accessors == null)
{
errorMessage = Strings.LazyMemberInfo_AccessorsNull;
return false;
}
if (accessors.All(accessor => accessor == null))
{
errorMessage = Strings.LazyMemberInfo_NoAccessors;
return false;
}
switch (memberType)
{
case MemberTypes.Property:
if (accessors.Length != 2)
{
errorMessage = Strings.LazyMemberInfo_InvalidPropertyAccessors_Cardinality;
return false;
}
if (accessors.Where(accessor => (accessor != null) && (accessor.MemberType != MemberTypes.Method)).Any())
{
errorMessage = Strings.LazyMemberinfo_InvalidPropertyAccessors_AccessorType;
return false;
}
break;
case MemberTypes.Event:
if (accessors.Length != 3)
{
errorMessage = Strings.LazyMemberInfo_InvalidEventAccessors_Cardinality;
return false;
}
if (accessors.Where(accessor => (accessor != null) && (accessor.MemberType != MemberTypes.Method)).Any())
{
errorMessage = Strings.LazyMemberinfo_InvalidEventAccessors_AccessorType;
return false;
}
break;
default:
if (
(accessors.Length != 1) ||
((accessors.Length == 1) && (accessors[0].MemberType != memberType)))
{
errorMessage = string.Format(CultureInfo.CurrentCulture, Strings.LazyMemberInfo_InvalidAccessorOnSimpleMember, memberType);
return false;
}
break;
}
return true;
}
示例5: getPossibleMembers
/// <summary>
/// Filter the not name like, and also if parameters are added, the not methods.
/// </summary>
/// <param name="nextNode">The next node.</param>
/// <param name="initialMembers">The initial members.</param>
/// <param name="parameters">The parameters.</param>
/// <returns></returns>
private List<MemberInfo> getPossibleMembers(ExecutionNode nextNode, MemberInfo[] initialMembers, List<object> parameters)
{
var possibleMembers = initialMembers.Where(possibleMember => possibleMember.Name.ToLower() == nextNode.executionText.ToLower()).ToList();
if (parameters.Count > 0)
{
List<MemberInfo> replaceList = new List<MemberInfo>();
foreach (var memberInfo in possibleMembers)
{
if (memberInfo.MemberType == MemberTypes.Method)
replaceList.Add(memberInfo);
}
possibleMembers = replaceList;
}
return possibleMembers;
}