RegisterExtendedItems() private méthode

Registers items in NLog.Extended.dll using late-bound types, so that we don't need a reference to NLog.Extended.dll.
private RegisterExtendedItems ( ) : void
Résultat void
        /// <summary>
        /// Builds the default configuration item factory.
        /// </summary>
        /// <returns>Default factory.</returns>
        private static ConfigurationItemFactory BuildDefaultFactory()
        {
            var nlogAssembly = typeof(ILogger).Assembly;
            var factory      = new ConfigurationItemFactory(nlogAssembly);

            factory.RegisterExtendedItems();
#if !SILVERLIGHT
            var assemblyLocation = GetNLogAssemblyLocation(nlogAssembly);
            if (assemblyLocation == null)
            {
                InternalLogger.Warn("No auto loading because Nlog.dll location is unknown");
                return(factory);
            }

            var extensionDlls = Directory.GetFiles(assemblyLocation, "NLog*.dll")
                                .Select(Path.GetFileName)
                                .Where(x => !x.Equals("NLog.dll", StringComparison.OrdinalIgnoreCase))
                                .Where(x => !x.Equals("NLog.UnitTests.dll", StringComparison.OrdinalIgnoreCase))
                                .Where(x => !x.Equals("NLog.Extended.dll", StringComparison.OrdinalIgnoreCase))
                                .Select(x => Path.Combine(assemblyLocation, x));

            InternalLogger.Debug("Start auto loading, location: {0}", assemblyLocation);
            foreach (var extensionDll in extensionDlls)
            {
                InternalLogger.Info("Auto loading assembly file: {0}", extensionDll);
                var extensionAssembly = Assembly.LoadFrom(extensionDll);
                factory.RegisterItemsFromAssembly(extensionAssembly);
            }
            InternalLogger.Debug("Auto loading done");
#endif

            return(factory);
        }
        /// <summary>
        /// Builds the default configuration item factory.
        /// </summary>
        /// <returns>Default factory.</returns>
        private static ConfigurationItemFactory BuildDefaultFactory()
        {
            var factory = new ConfigurationItemFactory(typeof(Logger).Assembly);

            factory.RegisterExtendedItems();

            return(factory);
        }
        /// <summary>
        /// Builds the default configuration item factory.
        /// </summary>
        /// <returns>Default factory.</returns>
        private static ConfigurationItemFactory BuildDefaultFactory()
        {
            var nlogAssembly = typeof(ILogger).Assembly;
            var factory      = new ConfigurationItemFactory(nlogAssembly);

            factory.RegisterExtendedItems();
#if !SILVERLIGHT
            var assemblyLocation = Path.GetDirectoryName(new Uri(nlogAssembly.CodeBase).LocalPath);
            if (assemblyLocation == null)
            {
                InternalLogger.Warn("No auto loading because Nlog.dll location is unknown");
                return(factory);
            }
            if (!Directory.Exists(assemblyLocation))
            {
                InternalLogger.Warn("No auto loading because '{0}' doesn't exists", assemblyLocation);
                return(factory);
            }

            var extensionDlls = Directory.GetFiles(assemblyLocation, "NLog*.dll")
                                .Select(Path.GetFileName)
                                .Where(x => !x.Equals("NLog.dll", StringComparison.OrdinalIgnoreCase))
                                .Where(x => !x.Equals("NLog.UnitTests.dll", StringComparison.OrdinalIgnoreCase))
                                .Where(x => !x.Equals("NLog.Extended.dll", StringComparison.OrdinalIgnoreCase))
                                .Select(x => Path.Combine(assemblyLocation, x));

            InternalLogger.Debug("Start auto loading, location: {0}", assemblyLocation);
            foreach (var extensionDll in extensionDlls)
            {
                InternalLogger.Info("Auto loading assembly file: {0}", extensionDll);
                var success = false;
                try
                {
                    var extensionAssembly = Assembly.LoadFrom(extensionDll);
                    InternalLogger.LogAssemblyVersion(extensionAssembly);
                    factory.RegisterItemsFromAssembly(extensionAssembly);
                    success = true;
                }
                catch (Exception ex)
                {
                    if (ex.MustBeRethrownImmediately())
                    {
                        throw;
                    }

                    InternalLogger.Warn(ex, "Auto loading assembly file: {0} failed! Skipping this file.", extensionDll);
                    //TODO NLog 5, check MustBeRethrown()
                }
                if (success)
                {
                    InternalLogger.Info("Auto loading assembly file: {0} succeeded!", extensionDll);
                }
            }
            InternalLogger.Debug("Auto loading done");
#endif

            return(factory);
        }
        /// <summary>
        /// Builds the default configuration item factory.
        /// </summary>
        /// <returns>Default factory.</returns>
        private static ConfigurationItemFactory BuildDefaultFactory()
        {
            var factory = new ConfigurationItemFactory(typeof(Logger).Assembly);
            factory.RegisterExtendedItems();

            return factory;
        }
        /// <summary>
        /// Builds the default configuration item factory.
        /// </summary>
        /// <returns>Default factory.</returns>
        private static ConfigurationItemFactory BuildDefaultFactory()
        {
            var nlogAssembly = typeof(ILogger).Assembly;
            var factory = new ConfigurationItemFactory(nlogAssembly);
            factory.RegisterExtendedItems();
#if !SILVERLIGHT
            var assemblyLocation = Path.GetDirectoryName(nlogAssembly.Location);
            if (assemblyLocation == null)
            {
                return factory;
            }

            var extensionDlls = Directory.GetFiles(assemblyLocation, "NLog*.dll")
                .Select(Path.GetFileName)
                .Where(x => !x.Equals("NLog.dll", StringComparison.OrdinalIgnoreCase))
                .Where(x => !x.Equals("NLog.UnitTests.dll", StringComparison.OrdinalIgnoreCase))
                .Where(x => !x.Equals("NLog.Extended.dll", StringComparison.OrdinalIgnoreCase))
                .Select(x => Path.Combine(assemblyLocation, x));
            foreach (var extensionDll in extensionDlls)
            {
                InternalLogger.Info("Auto loading assembly file: {0}", extensionDll);
                var extensionAssembly = Assembly.LoadFrom(extensionDll);
                factory.RegisterItemsFromAssembly(extensionAssembly);
            }
#endif

            return factory;
        }
        /// <summary>
        /// Builds the default configuration item factory.
        /// </summary>
        /// <returns>Default factory.</returns>
        private static ConfigurationItemFactory BuildDefaultFactory()
        {
            var nlogAssembly = typeof(ILogger).Assembly;
            var factory = new ConfigurationItemFactory(nlogAssembly);
            factory.RegisterExtendedItems();
#if !SILVERLIGHT

            var assemblyLocation = Path.GetDirectoryName(new Uri(nlogAssembly.CodeBase).LocalPath);
            if (assemblyLocation == null)
            {
                InternalLogger.Warn("No auto loading because Nlog.dll location is unknown");
                return factory;
            }
            if (!Directory.Exists(assemblyLocation))
            {
                InternalLogger.Warn("No auto loading because '{0}' doesn't exists", assemblyLocation);
                return factory;
            }

            try
            {

                var extensionDlls = Directory.GetFiles(assemblyLocation, "NLog*.dll")
                    .Select(Path.GetFileName)
                    .Where(x => !x.Equals("NLog.dll", StringComparison.OrdinalIgnoreCase))
                    .Where(x => !x.Equals("NLog.UnitTests.dll", StringComparison.OrdinalIgnoreCase))
                    .Where(x => !x.Equals("NLog.Extended.dll", StringComparison.OrdinalIgnoreCase))
                    .Select(x => Path.Combine(assemblyLocation, x));

                InternalLogger.Debug("Start auto loading, location: {0}", assemblyLocation);
                foreach (var extensionDll in extensionDlls)
                {
                    InternalLogger.Info("Auto loading assembly file: {0}", extensionDll);
                    var success = false;
                    try
                    {
                        var extensionAssembly = Assembly.LoadFrom(extensionDll);
                        InternalLogger.LogAssemblyVersion(extensionAssembly);
                        factory.RegisterItemsFromAssembly(extensionAssembly);
                        success = true;
                    }
                    catch (Exception ex)
                    {
                        if (ex.MustBeRethrownImmediately())
                        {
                            throw;
                        }

                        InternalLogger.Warn(ex, "Auto loading assembly file: {0} failed! Skipping this file.", extensionDll);
                        //TODO NLog 5, check MustBeRethrown()
                    }
                    if (success)
                    {
                        InternalLogger.Info("Auto loading assembly file: {0} succeeded!", extensionDll);
                    }

                }
            }
            catch (UnauthorizedAccessException ex)
            {
                InternalLogger.Warn(ex, "Seems that we do not have permission");
                if (ex.MustBeRethrown())
                {
                    throw;
                }
            }
            InternalLogger.Debug("Auto loading done");
#endif

            return factory;
        }