本文整理汇总了C#中Method.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# Method.GetName方法的具体用法?C# Method.GetName怎么用?C# Method.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Method
的用法示例。
在下文中一共展示了Method.GetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWrite
/// <summary>
/// This is used to acquire a <c>MethodName</c> for the name
/// and annotation of the provided method. This must be a setter
/// method, and so must accept a single argument, if it contains
/// more or less than one argument an exception is thrown.
/// return type that is not void and
/// </summary>
/// <param name="method">
/// this is the method to acquire the name for
/// </param>
/// <param name="type">
/// this is the method type to acquire the name for
/// </param>
/// <returns>
/// this is the method name object for the method
/// </returns>
public MethodName GetWrite(Method method, MethodType type) {
Class[] list = method.getParameterTypes();
String real = method.GetName();
if(list.length != 1) {
throw new MethodException("Set method %s os not a valid property", method);
}
String name = GetTypeName(real, type);
if(name == null) {
throw new MethodException("Could not get name for %s", method);
}
return new MethodName(method, type, name);
}
示例2: GetMethodType
/// <summary>
/// This is used to acquire a <c>MethodType</c> for the name
/// of the method provided. This will determine the method type by
/// examining its prefix. If the name follows Java Bean conventions
/// then either a setter method type is returned. If the name does
/// not comply with the naming conventions then null is returned.
/// </summary>
/// <param name="method">
/// this is the method to acquire the type for
/// </param>
/// <returns>
/// this is the method name object for the method
/// </returns>
public MethodType GetMethodType(Method method) {
String name = method.GetName();
if(name.startsWith("get")) {
return MethodType.GET;
}
if(name.startsWith("is")) {
return MethodType.IS;
}
if(name.startsWith("set")) {
return MethodType.SET;
}
return MethodType.NONE;
}