public static LoggerSingleton GetInstance() { if (_loggerSingletonInstance == null) { _loggerSingletonInstance = new LoggerSingleton(); } return(_loggerSingletonInstance); }
public static LoggerSingleton GetInstance() { if (instance == null) { instance = new LoggerSingleton("First and single instance of Logger class"); } return(instance); }
static void Main(string[] args) { LoggerSingleton logger = LoggerSingleton.GetInstance(); logger.GetInfo(); LoggerSingleton logger2 = LoggerSingleton.GetInstance(); //it's the same instance of logger Console.WriteLine(logger.Equals(logger2)); Console.ReadKey(); }
public int ProcessTo(int end) { int sum = 0; for (int i = _start; i < end; ++i) { sum += i; } LoggerSingleton.GetInstance().Log("Processor just calculated some value: " + sum); return(sum); }
static void Main(string[] args) { var log = LoggerSingleton.GetInstance(); log.AddToLog("123", "11111111"); Console.WriteLine("message was add to log"); log.AddToLog("D:\\DOCUMENTS\\test", "222"); Console.WriteLine("message was add to log"); Console.ReadLine(); }
public static LoggerSingleton GetInstance() { return(_loggerSingletonInstance ?? (_loggerSingletonInstance = new LoggerSingleton())); }
public HardProcessor(int start) { _start = start; LoggerSingleton.GetInstance().Log("Processor just created"); }