Esempio n. 1
0
  public final ITargetMethod GetMethod(String methodName, int overload) {
    ITargetMethod targetMethod = null;
    if (_target != null) {
      java.lang.reflect.Method[] members =
          _target
              .getClass()
              .getMethods(); // GetMethods(BindingFlags.Instance | BindingFlags.Public);

      for (int i = 0; i < members.length; i++) {
        java.lang.reflect.Method member = members[i];

        Annotation[] customAttributes = member.getDeclaredAnnotations();
        ; // member.GetCustomAttributes(TargetMethodAttribute.class, true);

        if (customAttributes != null && customAttributes.length > 0) {
          TargetMethodAttribute targetMethodAttribute =
              (TargetMethodAttribute)
                  ((customAttributes[0] instanceof TargetMethodAttribute)
                      ? customAttributes[0]
                      : null);

          if (targetMethodAttribute.privateMethod().equals(methodName)
              && targetMethodAttribute.privateOverload() == overload) {
            targetMethod =
                new TargetMethod(
                    _target,
                    member,
                    targetMethodAttribute.privateMethod(),
                    targetMethodAttribute.privateOverload());
          }
        }
      }
    }
    return targetMethod;
  }
Esempio n. 2
0
  public final ITargetMethod[] GetAllMethods() {
    java.util.ArrayList<ITargetMethod> methods = new java.util.ArrayList<ITargetMethod>();
    if (_target != null) {
      java.lang.reflect.Method[] members =
          _target.getClass().getMethods(/*BindingFlags.Instance | BindingFlags.Public*/ );

      for (int i = 0; i < members.length; i++) {
        java.lang.reflect.Method member = members[i];

        Annotation[] customAttributes =
            member
                .getDeclaredAnnotations(); // member.GetCustomAttributes(TargetMethodAttribute.class, true);

        if (customAttributes != null && customAttributes.length > 0) {
          TargetMethodAttribute targetMethodAttribute =
              (TargetMethodAttribute)
                  ((customAttributes[0] instanceof TargetMethodAttribute)
                      ? customAttributes[0]
                      : null);
          TargetMethod targetMethod =
              new TargetMethod(
                  _target,
                  member,
                  targetMethodAttribute.privateMethod(),
                  targetMethodAttribute.privateOverload());
          methods.add(targetMethod);
        }
      }

      members =
          _target
              .getClass()
              .getSuperclass()
              .getMethods(/*BindingFlags.Instance | BindingFlags.Public*/ );

      for (int i = 0; i < members.length; i++) {
        java.lang.reflect.Method member = members[i];

        Annotation[] customAttributes =
            member
                .getDeclaredAnnotations(); // member.GetCustomAttributes(TargetMethodAttribute.class, true);

        if (customAttributes != null && customAttributes.length > 0) {
          TargetMethodAttribute targetMethodAttribute =
              (TargetMethodAttribute)
                  ((customAttributes[0] instanceof TargetMethodAttribute)
                      ? customAttributes[0]
                      : null);
          TargetMethod targetMethod =
              new TargetMethod(
                  _target,
                  member,
                  targetMethodAttribute.privateMethod(),
                  targetMethodAttribute.privateOverload());
          methods.add(targetMethod);
        }
      }
    }
    return methods.toArray(new ITargetMethod[0]);
  }