Ejemplo n.º 1
0
 private MethodInfo TryGetNetOfficeRegisterMethod(IEnumerable <MethodInfo> methods)
 {
     foreach (MethodInfo item in methods)
     {
         if (MethodUtils.HasAttribute(item, _NetOfficeRegisterName))
         {
             return(item);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
 private MethodInfo TryGetComRegisterMethod(IEnumerable <MethodInfo> methods)
 {
     foreach (MethodInfo item in methods)
     {
         if (MethodUtils.HasAttribute <ComUnregisterFunctionAttribute>(item))
         {
             return(item);
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        internal bool Call(Type addinType, int installScope, int keyState)
        {
            bool result = true;

            IEnumerable <MethodInfo> methods = MethodUtils.GetMethods(addinType, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            MethodInfo method = TryGetNetOfficeRegisterMethod(methods);

            if (null != method)
            {
                ParameterInfo[] arguments = method.GetParameters();
                if (arguments.Length == 3)
                {
                    if (!MethodUtils.CallMethodWithArguments(method, addinType, installScope, keyState))
                    {
                        result = false;
                    }
                }
            }
            else
            {
                method = TryGetComRegisterMethod(methods);
                if (null != method)
                {
                    return(result);
                }

                ParameterInfo[] arguments = method.GetParameters();
                if (arguments.Length == 0)
                {
                    if (!MethodUtils.CallMethodWithoutArguments(method))
                    {
                        result = false;
                    }
                }
                else if (arguments.Length == 1 && arguments[0].ParameterType == typeof(Type))
                {
                    if (!MethodUtils.CallMethodWithArguments(method, addinType))
                    {
                        result = false;
                    }
                }
            }

            return(result);
        }