CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
CslaPolicy.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="CslaPolicy.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Contains methods to manage CSLA permission policy information</summary>
7//-----------------------------------------------------------------------
8using System;
9
10namespace Csla.Blazor
11{
15 public static class CslaPolicy
16 {
17 private static string PolicyPrefix = "Csla:";
18
25 public static string GetPolicy(Rules.AuthorizationActions action, Type objectType)
26 {
27 var actionName = action.ToString();
28 var typeName = objectType.AssemblyQualifiedName;
29 return $"{PolicyPrefix}{actionName}|{typeName}";
30 }
31
39 public static bool TryGetPermissionRequirement(string policy, out CslaPermissionRequirement requirement)
40 {
41 if (policy.StartsWith(PolicyPrefix))
42 {
43 var parts = policy.Substring(PolicyPrefix.Length).Split('|');
44 var action = (Rules.AuthorizationActions)Enum.Parse(typeof(Rules.AuthorizationActions), parts[0]);
45 var type = Type.GetType(parts[1]);
46 requirement = new CslaPermissionRequirement(action, type);
47 return true;
48 }
49 else
50 {
51 requirement = null;
52 return false;
53 }
54 }
55 }
56}