本文整理汇总了C#中IReflect.GetMethods方法的典型用法代码示例。如果您正苦于以下问题:C# IReflect.GetMethods方法的具体用法?C# IReflect.GetMethods怎么用?C# IReflect.GetMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReflect
的用法示例。
在下文中一共展示了IReflect.GetMethods方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareTypes
private static IEnumerable<string> CompareTypes(IReflect type1, IReflect type2, BindingFlags bindingFlags)
{
MethodInfo[] typeTMethodInfo = type1.GetMethods(bindingFlags);
MethodInfo[] typeXMethodInfo = type2.GetMethods(bindingFlags);
return typeTMethodInfo.Select(x => x.Name)
.Except(typeXMethodInfo.Select(x => x.Name));
}
示例2: GetMethodExtended
private static object GetMethodExtended(
IReflect type,
string name,
bool staticMethod,
int parameterCount)
{
var haveMethodName = false;
BindingFlags flags = (staticMethod ? BindingFlags.Static :
BindingFlags.Instance) | BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.InvokeMethod;
foreach (var method in type.GetMethods(flags)) {
if (method.Name.Equals(name)) {
haveMethodName = true;
if (method.GetParameters().Length == parameterCount) {
return method;
}
}
}
return haveMethodName ? type.GetMethod(name, flags) : null;
}
示例3: AllMethodsFrom
private static IEnumerable<MethodInfo> AllMethodsFrom(IReflect type)
{
return type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
示例4: MethodInfoCache
private MethodInfoCache(IReflect type)
{
Methods = type.GetMethods(SimpleReflection.BindingFlags);
_methods = Methods.GroupBy(x => x.Name).ToDictionary(x => x.Key, x => x.ToArray(), StringComparer.Ordinal);
}
示例5: GetMethods
private static IEnumerable<string> GetMethods(IReflect myType, BindingFlags flags)
{
var methods = myType.GetMethods(flags).Where(info => !info.IsSpecialName).ToList();
foreach (var methodInfo in methods)
{
var type = ToPrettyString(methodInfo.ReturnType);
if (!returnTypeDictionary.ContainsKey(type))
returnTypeDictionary[type] = new List<string>();
returnTypeDictionary[type].Add(methodInfo.Name);
}
return methods.Select(x => x.Name).Distinct();
}
示例6: GetExtensionMethods
private static void GetExtensionMethods(IReflect type)
{
var methods = type
.GetMethods(BindingFlags.Public | BindingFlags.Static)
.Where(info => info.IsDefined(typeof(ExtensionAttribute), true))
.Where(info => info.GetParameters().Length > 0);
foreach (var info in methods)
{
var t = info.GetParameters()[0].ParameterType;
if (t.IsGenericType)
t = t.GetGenericTypeDefinition();
if (!extensionMethods.ContainsKey(t))
extensionMethods[t] = new HashSet<Tuple<string, string>>();
var returnType = info.ReturnParameter == null ? "null" : ToPrettyString(info.ReturnParameter.ParameterType);
extensionMethods[t].Add(Tuple.Create(info.Name, returnType));
}
}
示例7: GetMethod
private MethodInfo GetMethod(IReflect viewModelType, string actionName)
{
var methodInfo =
viewModelType
.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
.SingleOrDefault(
method =>
method.Name == actionName &&
method.GetParameters().Count() <= 1);
return methodInfo;
}
示例8: GetRestOperations
private static IEnumerable<MethodInfo> GetRestOperations(IReflect type)
{
return type
.GetMethods(BindingFlags.Instance | BindingFlags.Public)
.Where(m => m.HasAttribute<RestOperationAttribute>());
}