Exemple #1
0
        T RunMethod <S, T>(T defaultIfNotExisting, params object[] parameters)
        {
            if (container == null)
            {
                return(defaultIfNotExisting);
            }

            var methodName = typeof(S).Name.Replace("Harmony", "");
            var method     = PatchTools.GetPatchMethod <S>(container, methodName);

            if (method != null)
            {
                if (typeof(T).IsAssignableFrom(method.ReturnType))
                {
                    return((T)method.Invoke(null, Type.EmptyTypes));
                }

                var input            = (parameters ?? new object[0]).Union(new object[] { instance }).ToArray();
                var actualParameters = AccessTools.ActualParameters(method, input);
                method.Invoke(null, actualParameters);
                return(defaultIfNotExisting);
            }

            return(defaultIfNotExisting);
        }
Exemple #2
0
        void RunMethod <S>(params object[] parameters)
        {
            if (container == null)
            {
                return;
            }

            var methodName = typeof(S).Name.Replace("Harmony", "");
            var method     = PatchTools.GetPatchMethod <S>(container, methodName);

            if (method != null)
            {
                var input            = (parameters ?? new object[0]).Union(new object[] { instance }).ToArray();
                var actualParameters = AccessTools.ActualParameters(method, input);
                method.Invoke(null, actualParameters);
            }

            return;
        }