shrey shah
shrey shah

Reputation: 43

Casbin.net Breaking changes while migrating from V1.13.0 to V2.9.1 - Enforcer class

I am trying to migrate Casbin.net package from V1.13.0 to V2.9.1. My Enforcer class used to look like this in the previous version.

public class CustomEnforcer : Enforcer
    {
        public CustomEnforcer() : this("", "")
        {
        }
        public CustomEnforcer(string modelContent, string policyContent) : this(NewModel(modelContent), new DefaultFileContentAdapter(policyContent))
        {

        }

        public CustomEnforcer(Model m, IAdapter adapter)
        {
            SetAdapter(adapter);
            SetWatcher(null, false);
            SetModel(m);
            FunctionMap.LoadFunctionMap();
            EnforcerOptions enforcerOptions = new EnforcerOptions() 
            { 
            
            };
            Initialize(enforcerOptions);
            if (this.adapter != null)
            {
                LoadPolicy();
            }
        }
    }

I have changed it like this.

public class CustomEnforcer : Enforcer
    {
        public CustomEnforcer() : this("", "")
        {
        }
        public CustomEnforcer(string modelContent, string policyContent)
        {
            Model = DefaultModel.CreateFromText(modelContent);
            Adapter = new FileAdapter(policyContent);
        }

    }

is this correct? Do I need to do anything else? earlier version had a separate class with the implementation of DefaultFileContentAdapter. Do we need this in the latest version?

Upvotes: 0

Views: 22

Answers (0)

Related Questions