private static Encode FindEncode()

in src/DotPulsar/Internal/Compression/Lz4Compression.cs [124:150]


    private static Encode FindEncode(MethodInfo[] methods, Type lz4Level)
    {
        const string name = "Encode";

        foreach (var method in methods)
        {
            if (method.Name != name || method.ReturnType != typeof(int))
                continue;

            var parameters = method.GetParameters();
            if (parameters.Length != 7)
                continue;

            if (parameters[0].ParameterType != typeof(byte[]) ||
                parameters[1].ParameterType != typeof(int) ||
                parameters[2].ParameterType != typeof(int) ||
                parameters[3].ParameterType != typeof(byte[]) ||
                parameters[4].ParameterType != typeof(int) ||
                parameters[5].ParameterType != typeof(int) ||
                parameters[6].ParameterType != lz4Level)
                continue;

            return (Encode) method.CreateDelegate(typeof(Encode));
        }

        throw new Exception($"A method with the name '{name}' matching the delegate was not found");
    }