Skip to content

lsoft/Proxy

Repository files navigation

Proxy, also known as YetAnotherProxy :)

Build status

Without Ninject NuGet Version NuGet Version

As Ninject extension NuGet Version NuGet Version

Runtime code generation proxy. Useful telemetry for your C# application. It easily binds with Ninject, but not require it, and is able to store telemetry to SQL Server, binary files or others containers.

Proxy

public interface IInterface1ThatNeedToBeProxied
{
    [ProxyAttribute]
    SomeObject DoSomething(SomeOtherObject argument);
}

public class Class1ThatNeedToBeProxied : IInterface1ThatNeedToBeProxied
{
    public SomeObject DoSomething(SomeOtherObject argument)
    {
        //useful code
    }
}

You can create a proxy manually:

var proxiedObject = constructor.CreateProxy<IInterface1ThatNeedToBeProxied, Class1ThatNeedToBeProxied>(
    payloadFactory,
    typeof (ProxyAttribute)
    );

or through Ninject:

kernel
    .Bind<IInterface1ThatNeedToBeProxied>()
    .ToProxy<IInterface1ThatNeedToBeProxied, Class1ThatNeedToBeProxied, ProxyAttribute>()
;

var proxiedObject = kernel.Get<IInterface1ThatNeedToBeProxied>();

and use it instead of Class1ThatNeedToBeProxied. For example usage (in Ninject scope, or not) please refer to 2 demo projects.

Payload

Default payload stores a class name, method name, start time, execution time span, and execution exception if raised. Also default payload combines profiling events in stack order for each execution thread. Default payload can be replaced by the user's one.

About

Runtime code generation proxy. Useful telemetry for your C# application.

Resources

Stars

Watchers

Forks

Packages

No packages published