Skip to content

Commit

Permalink
feat: Add go like method
Browse files Browse the repository at this point in the history
Signed-off-by: sagilio <sagilio@outlook.com>
  • Loading branch information
sagilio committed Jul 9, 2023
1 parent 3582194 commit 2884c22
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Casbin/Casbin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<PackageReference Include="CsvHelper" Version="30.0.1"/>
<PackageReference Include="DotNet.Glob" Version="3.1.3"/>
<PackageReference Include="System.Memory" Version="4.5.5"/>
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.Github" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

Expand Down
14 changes: 14 additions & 0 deletions Casbin/Model/DefaultModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ public static IModel CreateFromText(string text)
return model;
}

/// <summary>
/// Creates a default model from file. (go like API)
/// </summary>
/// <param name="path">The path of the model file.</param>
/// <returns></returns>
public static IModel NewModelFromFile(string path) => CreateFromFile(path);

/// <summary>
/// Creates a default model from text. (go like API)
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static IModel NewModelFromText(string text) => CreateFromText(text);

private void LoadModel(IConfig config)
{
Sections.LoadSection(config, PermConstants.Section.RequestSection);
Expand Down
2 changes: 2 additions & 0 deletions Casbin/Model/DefaultPolicyManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Casbin.Model.Holder;
using JetBrains.Annotations;

namespace Casbin.Model
{
[PublicAPI]
public class DefaultPolicyManager : IPolicyManager
{
private readonly AdapterHolder _adapterHolder;
Expand Down

0 comments on commit 2884c22

Please sign in to comment.