Skip to content

Hook to be automatically invoked during runtime? #7126

@justinyoo

Description

@justinyoo

Is your question related to a specific version? If so, please specify:

both v2 and v3, and static and IoC

What language does your question apply to? (e.g. C#, JavaScript, Java, All)

C#

Question

I wonder whether there is a sort of hook interface like IFunctionHook or so, so that we can implement the hook to be invoked while the Functions runtime boots up. Do we have such kind? For example:

public interface IFunctionHook
{
    void Run();
}

public class MyHookClass : IFunctionHook
{
    public void Run()
    {
        // Do Something
    }
}

And, somewhere in the functions host runtime has...

var assembly = Assembly.GetExecutingAssembly();
var types = assembly.GetTypes()
                    .Where(p => p.GetInterface("IFunctionHook", ignoreCase: true) != null);
foreach (var type in types)
{
    var instance = Activator.CreateInstance(type);
    (instance as IFunctionHook).Run();
}

While the Function rumtime boots up, it searches any class implementing IFunctionHook and invokes the Run() method like above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions