StatLight.Core.Configuration.InputOptions.DumpValuesForDebug C# (CSharp) Méthode

DumpValuesForDebug() public méthode

public DumpValuesForDebug ( ILogger logger ) : InputOptions
logger ILogger
Résultat InputOptions
        public InputOptions DumpValuesForDebug(ILogger logger)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            var properties = GetType().GetProperties().OrderBy(o => o.Name);
            const string stringFormat = "{0,-35}: {1}";

            logger.Debug("****************** Input options as configured ******************");
            foreach (var propertyInfo in properties)
            {
                var propertyValue = propertyInfo.GetValue(this, new object[0]);
                var enumerablePropertyValue = propertyValue as IEnumerable<string>;
                if (enumerablePropertyValue != null)
                {
                    logger.Debug(stringFormat.FormatWith(propertyInfo.Name, "IEnumerable<string>"));
                    logger.Debug("{0,-35}  {{".FormatWith(""));
                    foreach (var itemValue in enumerablePropertyValue)
                    {
                        logger.Debug("{0,-35}    '{1}'".FormatWith("", itemValue));
                    }
                    logger.Debug("{0,-35}  }}".FormatWith(""));
                }
                else
                {
                    logger.Debug(stringFormat.FormatWith(propertyInfo.Name, propertyValue));
                }
            }
            logger.Debug("*****************************************************************");
            return this;
        }

Usage Example

Exemple #1
0
        public static TinyIoCContainer Initialize(InputOptions inputOptions,
            ILogger overrideLogger = null)
        {
            if (inputOptions == null) throw new ArgumentNullException("inputOptions");
            var ioc = new TinyIoCContainer();
            ILogger logger = overrideLogger ?? GetLogger(inputOptions.IsRequestingDebug);
            ioc.Register(logger);

            ioc.Resolve<SettingsOverrideApplicator>()
                .ApplySettingsFrom(inputOptions.SettingsOverride, Properties.Settings.Default);

            inputOptions.DumpValuesForDebug(logger);
            ioc.Register(ioc);
            ioc.Register(inputOptions);
            ioc.Register<WebServerLocation>().AsSingleton();
            ioc.Register<IStatLightRunnerFactory, StatLightRunnerFactory>();

            var eventAggregator = ioc.Resolve<EventAggregatorFactory>().Create();
            ioc.Register(eventAggregator);
            ioc.Register<IEventPublisher>(eventAggregator);
            ioc.Register<IEventSubscriptionManager>(eventAggregator);

            ioc.Register<ResponseFactory>().AsSingleton();

            ioc.Register<IPostHandler, PostHandler>().AsSingleton();
            ioc.Register<ICurrentStatLightConfiguration, CurrentStatLightConfiguration>();

            return ioc;
        }