public ConfigurationalApi UseContext(object globalContext) { // Sets the global context. In most cases this context should inherit from the StandardGlobalContext as it would provide most of the default systems. XContextualBase.SetGlobal(globalContext); return(this); }
public IdContextHost_I GetHost() { var context = XContextualBase.GetGlobalAs <IdContextHost_I>(); if (context == null) { throw new IdentificationSubSystemNotSupportedException(); } ; return(context); }
public LogEntry_I LogError <TMessage>(TMessage message, [CallerMemberName] string callerMemberName = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) where TMessage : LogMessage_I { return(Log <TMessage>(new LogSignal() { GlobalContext = XContextualBase.GetGlobal(), Message = message, CallerMemberName = callerMemberName, CallerFilePath = callerFilePath, CallerLineNumber = callerLineNumber, LogLevel = LogLevels.Error })); }
public LogEntry_I LogException <TException>(TException exception, string message, [CallerMemberName] string callerMemberName = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) where TException : System.Exception { return(Log <TException>(new LogSignal() { GlobalContext = XContextualBase.GetGlobal(), Exception = exception, Message = new ExceptionMessage <TException>() { Message = new Message() { Value = message ?? exception?.Message } }, CallerMemberName = callerMemberName, CallerFilePath = callerFilePath, CallerLineNumber = callerLineNumber, LogLevel = LogLevels.Error })); }
public void WriteLine(string line) { var context = XContextualBase.GetAs <DebugContextHost_I>(); if (!context.Debug.IsEnabled) { return; } XLog.LogDebug(new DebugLogMessage() { Message = new Message() { Value = line } }); System.Diagnostics.Debug.WriteLine(line); if (context.Debug.IsConsoleEnabled) // useful when writing test cases { Console.WriteLine(line); } }
public TPhenotype GetGlobal <TPhenotype, TGenotype>() where TGenotype : TPhenotype { return(XContextualBase.GetGlobal <TPhenotype, TGenotype>()); }
public TPhenotype GetGlobal <TPhenotype>() where TPhenotype : class { return(XContextualBase.GetGlobal <TPhenotype>()); }
public object GetGlobal() { return(XContextualBase.GetGlobal()); }
public T Get <T, TClass>() where TClass : class, T, new() { return(XContextualBase.Get <T, TClass>()); }
public T Get <T>() where T : class { return(XContextualBase.Get <T>()); }
public TypeGlobalContext_I GetGlobalContext() { TypeGlobalContext_I context = XContextualBase.GetGlobal <TypeGlobalContext_I>(); return(context); }
public void Dispose(bool disposing) { XContextualBase.Dispose(); }
public bool CanLog(LogLevels logLevel) { return(CanLog(XContextualBase.GetGlobal(), logLevel)); }