beantownace
Active member
- Joined
- Feb 15, 2019
- Messages
- 26
- Programming Experience
- 5-10
If I have a class that has a constructor that loads a static class I want to access anytime the service is running, how do I call that within a method I have? Essentially I have a class that has methods for loading up a customer object where I only need to set it once for each day then just access it from that point on. I just need to be able to initialize the Customer class in a method that will get called in my service once in the morning. Thanks maybe this is not the best approach but wanting to just set it once and then access it when needed. Thanks
Code Example:
namespace Framework
{
public class Customer
{
private readonly ICustomerRepository _customerRepository;
public CustomerSetup(ICustomerRepository customerRepository)
{
Customer.CustomerSetup(GetCustomerGroup(), GetCustomerLocation(), GetCustomerActive());
}
private string GetCustomerGroup()
{
....
}
private string GetCustomerLocation()
{
....
}
private string GetCustomerActive()
{
....
}
}
}
Then I have my static class different project:
namespace Common.Domain
{
public static class Customer
{
public static string CustomerGroup { get; private set; }
public static string CustomerLocation { get; private set; }
public static bool CustomerActive { get; private set; }
public static void CustomerSetup(string customerGroup, string customerLocation, bool customerActive)
{
CustomerGroup = customerGroup;
CustomerLocation = customerLocation;
CustomerActive = customerActive;
}
}
}