Search code examples
c#c#-4.0dynamicfluent-security

C# Accessing dynamic property on interface


I am playing around with FluentSecurity library for asp.net mvc. One of the interfaces exposed by this library is ISecurityContext as shown below:

public interface ISecurityContext
{
    dynamic Data { get; }
    bool CurrenUserAuthenticated();
    IEnumerable<object> CurrenUserRoles();
}

When I try to access "Data" property (as shown below) it is not available. Although the other two methods seems to be accessible.

public class ExperimentalPolicy : ISecurityPolicy
{
    public PolicyResult Enforce(ISecurityContext context)
    {
        dynamic data = context.Data; // Data property is not accessible.
    }
}

What am I missing ? Thanks.


Solution

  • The Data property on ISecurityContext isn't introduced until version 2.0. The default installed with nuget without including prerelease is 1.4. Which does not have the property. Make sure you are using the right version!