Giter Site home page Giter Site logo

Comments (9)

casbin-bot avatar casbin-bot commented on May 27, 2024

@sagilio @sociometry @AsakusaRinne

from casbin.net.

AsakusaRinne avatar AsakusaRinne commented on May 27, 2024

Could you please provide the version you used?

from casbin.net.

Aya0wind avatar Aya0wind commented on May 27, 2024

Could you please provide the version you used?

casbin version: 2.0.0-preview.4
.NET version: 7.0.0-rc.2
platform: apple m1 macos 13.0

from casbin.net.

AsakusaRinne avatar AsakusaRinne commented on May 27, 2024

Yes, in 2.0.0-preview.4 please use Request.Create("alice", "data", "read").

I confess it may be confusing due to some early designs. The code above returns the type Request<string, string, string>, while the other way you used has a return type of RequestValues. This difference will raise the error when enforcing.

Thank you for telling us and we'll optimize it in the next release. The current code has removed the constructor with parameters of RequestValues.

from casbin.net.

AsakusaRinne avatar AsakusaRinne commented on May 27, 2024

@sagilio I noticed that the constructor of RequestValues may not need to be exposed to users (no such using in current unit test code). Shall we further hide the default constructor as internal?

from casbin.net.

Aya0wind avatar Aya0wind commented on May 27, 2024

Yes, in 2.0.0-preview.4 please use Request.Create("alice", "data", "read").

I confess it may be confusing due to some early designs. The code above returns the type Request<string, string, string>, while the other way you used has a return type of RequestValues. This difference will raise the error when enforcing.

Thank you for telling us and we'll optimize it in the next release. The current code has removed the constructor with parameters of RequestValues.

Ok, Thanks for your help. By the way, if i really want to pass an array of object as a request, is there a best practice?
In 2.00-preview.1, this code can run correctly, because Enforce has a overloaded version which is
bool Enforce(params object[] requestValues);

var request = new Object[] {"alice", "data", "read"};
var result = enforcer.Enforce(request);

But in 2.00-preview.4, this method is disappeared, if i still use this code, it will call this unexpected
public static bool Enforce<T>(this IEnforcer enforcer, T value) overloaded version and cause error.
Is there any way to pass request from a List<T>, T[],or other IEnumerable<T> types instead of use a fixed amount of parameters version such as
public static bool Enforce<T1, T2, T3>(this IEnforcer enforcer, T1 value1, T2 value2, T3 value3)
in 2.0.0-preview.4?

from casbin.net.

AsakusaRinne avatar AsakusaRinne commented on May 27, 2024

By the way, if i really want to pass an array of object as a request, is there a best practice?

I'm afraid not. I did not take part in the development of 2.00-preview.1 but I believe it removed such API later on account of performance. @sagilio What about adding an API like bool Enforce<T>(params T[] requestValues)?

from casbin.net.

sagilio avatar sagilio commented on May 27, 2024

By the way, if i really want to pass an array of object as a request, is there a best practice?

I'm afraid not. I did not take part in the development of 2.00-preview.1 but I believe it removed such API later on account of performance. @sagilio What about adding an API like bool Enforce<T>(params T[] requestValues)?

The reason for the remove bool Enforce(params object[] requestValues); is because of the problem of calling priority. It may helpful to add the generic list API.

from casbin.net.

hsluoyz avatar hsluoyz commented on May 27, 2024

Fixed by: #303

from casbin.net.

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.