当前位置: 首页>>代码示例>>C#>>正文


C# ILogger.GetType方法代码示例

本文整理汇总了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();
        }
开发者ID:xorandor,项目名称:ElasticLoggingDemo,代码行数:28,代码来源:Program.cs

示例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);
     }
 }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:12,代码来源:ALogger.cs

示例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);
            }
        }
开发者ID:BryanApellanes,项目名称:Naizari,代码行数:18,代码来源:MultiTargetLogger.cs

示例4: EchoLogDescription

 private static void EchoLogDescription(ILogger logger)
 {
     Console.WriteLine("ILogger Type: " + logger.GetType() + " Name: " + logger.Name);
 }
开发者ID:dzstoever,项目名称:ZenFacades,代码行数:4,代码来源:King+-+IocDI+-+LogDemo.cs

示例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);
        }
开发者ID:mfilippov,项目名称:msbuild,代码行数:38,代码来源:LoggingService.cs

示例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);
            }
        }
开发者ID:mfilippov,项目名称:msbuild,代码行数:31,代码来源:LoggingService.cs

示例7: Add

 public void Add(ILogger logger)
 {
     if (_loggers.Any(x=>x.GetType() == logger.GetType()) == false)
         _loggers.Add(logger);
 }
开发者ID:KernowCode,项目名称:UBADDAS,代码行数:5,代码来源:Loggers.cs

示例8: UnRegister

 public void UnRegister(ILogger logger)
 {
     _loggers.Remove(logger.GetType().Name);
 }
开发者ID:quziqin,项目名称:NervDog2DGameEngine,代码行数:4,代码来源:LoggerManager.cs

示例9: Register

 public void Register(ILogger logger)
 {
     _loggers.Add(logger.GetType().Name, logger);
 }
开发者ID:quziqin,项目名称:NervDog2DGameEngine,代码行数:4,代码来源:LoggerManager.cs

示例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);
 }
开发者ID:chriswalpen,项目名称:PersistenceMap,代码行数:8,代码来源:Settings.cs

示例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);
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:47,代码来源:Engine.cs


注:本文中的ILogger.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。