private static Decode FindDecode()

in src/DotPulsar/Internal/Compression/Lz4Compression.cs [97:122]


    private static Decode FindDecode(MethodInfo[] methods)
    {
        const string name = "Decode";

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

            var parameters = method.GetParameters();
            if (parameters.Length != 6)
                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))
                continue;

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

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