Comments (9)
@sagilio @sociometry @AsakusaRinne
from casbin.net.
Could you please provide the version you used?
from casbin.net.
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.
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.
@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.
Yes, in
2.0.0-preview.4
please useRequest.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 ofRequestValues
. 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.
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.
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 likebool 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.
Fixed by: #303
from casbin.net.
Related Issues (20)
- .NET 6 support HOT 6
- InvalidOperationException when Enforcing HOT 4
- Fix CI error HOT 4
- An expression cannot be used in this context because it cannot be passed or returned by reference HOT 4
- Enforcer.Enforce throws exception when model contains similar definitions HOT 3
- Does using Casbin.NET support defining multiple M's in matchers? For example, m1 m2 HOT 3
- Casbin .NET doesn't support commas in policy HOT 3
- Where can I find ASP.NET 6 examples? HOT 7
- Check collection in ABAC with policy HOT 4
- Updating Policies directly on the IPolicyStore model not reflected in Enforcer HOT 4
- Rules work on Casbin Editor but not on Casbin.Net HOT 6
- Use semantic-release to auto release new versions HOT 2
- Apply politic to objects of different class going to excaption, but in posible in Go version HOT 5
- .NET library does not support multi-line mode with '\' line feeds HOT 1
- Cannot add named groups in Casbin v2 HOT 3
- Cannot get Policy with null value in EF core Adapter. HOT 8
- Enforcer hangs during multi-threaded modifications HOT 8
- bug: fix CI error: error: Response status code does not indicate success: 413 (The total packages size for the pending uploads is too large. The feed owner may have to upgrade the MyGet subscription to resolve this issue.). HOT 2
- How to return a custom type instead of using IQueryable type in IPolicyFilter HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from casbin.net.