本文整理汇总了C#中ILogger.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.GetType方法的具体用法?C# ILogger.GetType怎么用?C# ILogger.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoStuff
public static void DoStuff(ILogger logger)
{
Console.WriteLine($"doing stuff with {logger.GetType().Name}");
var jobFactory = new JobFactory(logger);
int count = 50000;
int completed = 0;
double errorRate = 0.01;
var cancellation = new CancellationTokenSource();
Task.Run(async () =>
{
while (!cancellation.IsCancellationRequested)
{
Console.WriteLine($"Completed {completed}/{count} jobs");
await Task.Delay(1000, cancellation.Token);
}
}, cancellation.Token);
foreach (var job in jobFactory.GetJobsForExecution(count).AsParallel())
{
job.Execute(errorRate);
Interlocked.Increment(ref completed);
}
cancellation.Cancel();
}
示例2: C2V
internal static VLogger C2V(ILogger contract)
{
if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) &&
(contract.GetType().Equals(typeof(LoggerV2C))))
{
return ((LoggerV2C)(contract)).GetSourceView();
}
else
{
return new LoggerC2V(contract);
}
}
示例3: AddLogger
/// <summary>
/// Adds the specified logger if it hasn't already been added. If
/// the specified logger is the current MultiTargetLogger it will not be added.
/// If the specified logger is a NullLoger it will not be added.
/// </summary>
/// <param name="logger"></param>
public void AddLogger(ILogger logger)
{
if (logger.IsNull)
{
return;
}
if (!_loggers.Contains(logger) && logger != this && _loggers.Where(l => l.GetType() == logger.GetType()).FirstOrDefault() == null)
{
_loggers.Add(logger);
}
}
示例4: EchoLogDescription
private static void EchoLogDescription(ILogger logger)
{
Console.WriteLine("ILogger Type: " + logger.GetType() + " Name: " + logger.Name);
}
示例5: InitializeLogger
/// <summary>
/// Initializes the logger and adds it to the list of loggers maintained by the engine.
/// This method is not expected to be called from multiple threads
/// </summary>
/// <exception cref="LoggerException">A logger exception thrown by a logger when its initialize call is made</exception>
/// <exception cref="InternalLoggerException">Any exceptions from initializing the logger which are not loggerExceptions are caught and wrapped in a InternalLoggerException</exception>
/// <exception cref="Exception">Any exception which is a ExceptionHandling.IsCriticalException will not be wrapped</exception>
private void InitializeLogger(ILogger logger, IEventSource sourceForLogger)
{
try
{
INodeLogger nodeLogger = logger as INodeLogger;
if (null != nodeLogger)
{
nodeLogger.Initialize(sourceForLogger, _maxCPUCount);
}
else
{
logger.Initialize(sourceForLogger);
}
}
catch (LoggerException)
{
throw;
}
catch (Exception e)
{
if (ExceptionHandling.IsCriticalException(e))
{
throw;
}
InternalLoggerException.Throw(e, null, "FatalErrorWhileInitializingLogger", true, logger.GetType().Name);
}
// Keep track of the loggers so they can be unregistered later on
_iloggerList.Add(logger);
}
示例6: ShutdownLogger
/// <summary>
/// Shutdown an ILogger
/// Rethrow LoggerExceptions
/// Wrap all other exceptions in an InternalLoggerException
/// </summary>
/// <param name="logger">Logger to shutdown</param>
/// <exception cref="InternalLoggerException">Any exception comming from a logger during shutdown that is not a LoggerException is wrapped in an InternalLoggerException and thrown</exception>
/// <exception cref="LoggerException">Errors during logger shutdown may throw a LoggerException, in this case the exception is re-thrown</exception>
private void ShutdownLogger(ILogger logger)
{
try
{
if (logger != null)
{
logger.Shutdown();
}
}
catch (LoggerException)
{
throw;
}
catch (Exception e)
{
if (ExceptionHandling.IsCriticalException(e))
{
throw;
}
InternalLoggerException.Throw(e, null, "FatalErrorDuringLoggerShutdown", false, logger.GetType().Name);
}
}
示例7: Add
public void Add(ILogger logger)
{
if (_loggers.Any(x=>x.GetType() == logger.GetType()) == false)
_loggers.Add(logger);
}
示例8: UnRegister
public void UnRegister(ILogger logger)
{
_loggers.Remove(logger.GetType().Name);
}
示例9: Register
public void Register(ILogger logger)
{
_loggers.Add(logger.GetType().Name, logger);
}
示例10: AddLogger
/// <summary>
/// Adds a logger to the factory to the already defined loggers from the configuration
/// </summary>
/// <param name="logger">The logger to add to the loggerfactory</param>
public void AddLogger(ILogger logger)
{
LoggerFactory.AddLogger(logger.GetType().Name, logger);
}
示例11: RegisterLoggerInternal
/// <summary>
/// Initializes the logger and adds it to the list of loggers maintained by the engine
/// </summary>
/// <exception cref="LoggerException">Logger indicating it failed in a controlled way</exception>
/// <exception cref="InternalLoggerException">Logger threw arbitrary exception</exception>
private void RegisterLoggerInternal(ILogger logger, EventSource sourceForLogger, bool forwardingLogger)
{
try
{
if (logger is INodeLogger)
{
((INodeLogger)logger).Initialize(sourceForLogger, this.numberOfCpus);
}
else
{
logger.Initialize(sourceForLogger);
}
}
// Polite logger failure
catch (LoggerException)
{
throw;
}
catch (Exception e)
{
InternalLoggerException.Throw(e, null, "FatalErrorWhileInitializingLogger", false, logger.GetType().Name);
}
if (forwardingLogger)
{
if (forwardingLoggers == null)
{
forwardingLoggers = new ArrayList();
}
forwardingLoggers.Add(logger);
}
else
{
if (loggers == null)
{
loggers = new ArrayList();
}
loggers.Add(logger);
}
}