Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of <see cref="InstrumentationManager"/> class.
        /// </summary>
        private InstrumentationManager()
        {
            //
            // First off, check whether the configuration section is present. If
            // it is, proceed with configuring InstrumentationManager.
            if (ConfigurationManager.ConfigurationSection != null)
            {
                //
                // Adding persisters.
                foreach (PersisterElement persister in ConfigurationManager.ConfigurationSection.Persisters)
                {
                    IPersister persisterInstance =
                        ObjectFactory.CreatePersister(persister);
                    persisterInstance.Configure(persister.CustomProperties.ToStringDictionary());

                    Persisters.Add(persister.Name, persisterInstance);
                } // foreach

                //
                // Adding formatters.
                foreach (FormatterElement formatter in ConfigurationManager.ConfigurationSection.Formatters)
                {
                    IFormatter formatterInstance = ObjectFactory.CreateFormatter(formatter);
                    FormattingManager.AddFormatter(formatterInstance);
                }

                //
                // Creating binders.
                foreach (BindingElement binding in ConfigurationManager.ConfigurationSection.Bindings)
                {
                    Binders.Add(binding.PersisterName, CreateBinder(binding));
                }

                isInstrumentationEnabled = true;
            } // if
        }