Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 776
user1599610 Avatar asked Nov 04 '22 18:11

user1599610


1 Answers

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!

like image 150
jbtule Avatar answered Nov 09 '22 06:11

jbtule