Question

I have designed a multi-layer solution and created a bunch of Manager classes to implement Business Logic. All the managers are derived from BaseManager class. To be more clear, here's UserManager class:

public class UserManager : BaseManager
{
    public void Add(User user)
    {
       ...
    }
    public void Update(User user)
    {
       ...
    }
    public void Delete(User user)
    {
       ...
    }
    public bool GetAccessPermissions(User user)
    {
       ...
    }
}  

BaseManager is as follows:

public class BaseManager
{  
    protected IRepository repository = IoCLocator.Resolve<IRepository>();
    public BaseManager()
    {
        ...
    }
    // Some shared methods among manager classes.
}  

Now I skeptical that my manager classes should all be defined static, since they get their related entities on which they want to operate, as parameters. But As you see, I have some shared private/protected members which I should instantiate upon every call. (e.g. repository should be instantiated on each manager class's creation).

What are my choices to define managers classes as static and still have the protected members instantiated on each call to managers' methods?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top