https://github.com/niroula-kushal/permissionreader
https://github.com/niroula-kushal/permissionreader
console csharp netcore3
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/niroula-kushal/permissionreader
- Owner: niroula-kushal
- Created: 2020-04-19T04:34:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T08:58:51.000Z (about 3 years ago)
- Last Synced: 2025-05-15T00:22:56.409Z (8 months ago)
- Topics: console, csharp, netcore3
- Language: C#
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PermissionReader
C# implementation of permission reader.
Reads a JSON representation of permission listing and creates permission objects accordingly.
```c#
string json = getJsonFromSomeWhere();
List permissions = PermissionJsonParser.parse(json);
// Gives the parent permission of a permission. Null for top level permission
var parent = permission.parent;
// Gives the permissions nested under this permission
var childrenPermissions = permission.children;
// Returns true if the permission is a leaf node, else false
bool isLeaf = permission.isLeaf;
/*
* Returns the level of permission.
{
"Inventory": {
"Item" : ["Create"]
}
}
For permission representing "Inventory", permission.level = 1
For "Item", permission.level = 2
*/
//
//
int level = permission.level;
// Gives the name of the permission. "Inventory", "Item" ...
string name = permission.name;
// Gives permission name appended with parent permission "Inventory.Item", "Inventory.Item.Create" etc
string resolvedName = permission.resolveName();
```