Coder Social home page Coder Social logo

Comments (2)

remogloor avatar remogloor commented on July 26, 2024

Implemented in 6182460

Interface procies allow now interception attributes. They must be declared on the implementation type not on the interface due to a limitation of .NET.

from ninject.extensions.interception.

coreConvention avatar coreConvention commented on July 26, 2024

Remo, can you please explain what you mean by, 'They must be declared on the implementation type not on the interface due to a limitation of .NET'? I am currently struggling with the issue of how to get the parameters from attributes applied to methods, from inside the interceptor. I gather fromt he context of this bug when it was logged that this might be the answer but when I do:

var attrs = invocation.Request.Method.GetCustomAttributes(typeof(AuthorizeAttribute), true);

..attrs is empty.

My Attribute is simple:

public class AuthorizeAttribute : InterceptAttribute
{
    public string[] AttributeParameters { get; private set; }

    public AuthorizeAttribute(params string[] parameters) {
        AttributeParameters = parameters;
    }

    public override IInterceptor CreateInterceptor(IProxyRequest request) {
        return request.Context.Kernel.Get<AuthorizationInterceptor>();
    }
}

Being applied in its most simplistic form possible at the moment:

    [Authorize("Test")]
    public virtual Result<Vault> Vault(DateTime date, bool LiveMode = true, int? SnapshotId = null)
    {
         ...
    }

I had tried doing the following at first. and adding a constructor in my IInterceptor implementation but it doesnt work:

    public override IInterceptor CreateInterceptor(IProxyRequest request) {
        var param = new List<Parameter>();
        int index = 0;
        foreach(string p in AttributeParameters) {
            param.Add(new ConstructorArgument(index++.ToString(), p));
        }
        return request.Context.Kernel.Get<AuthorizationInterceptor>(param.ToArray());
    }

when on my interceptor I had this:

    public AuthorizationInterceptor(IParameter[] parameters) {
        AttributeParameters = parameters;
    }

It actually calls into the constructor, but parameters has no values.

from ninject.extensions.interception.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.