Exemple #1
0
        /// <summary>
        /// Opens the instrumenation section, builds the design time nodes and adds them to the application node.
        /// </summary>
        /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
        /// <param name="rootNode">The root node of the application.</param>
        /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
        protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
        {
            if (null != section)
            {
                InstrumentationNode node = new InstrumentationNode((InstrumentationConfigurationSection)section);
                SetProtectionProvider(section, node);

                rootNode.AddNode(node);
            }
        }
        public void SerializationUtilityCanDeserializeConfigurationNode()
        {
            InstrumentationNode instrumentationNode = new InstrumentationNode();
            ApplicationNode.AddNode(instrumentationNode);

            string relativePathToInstrumentationNode = SerializationUtility.CreatePathRelativeToRootNode(instrumentationNode.Path, ApplicationNode.Hierarchy);
            Assert.IsNotNull(relativePathToInstrumentationNode);

            InstrumentationNode deserializedInstance = SerializationUtility.DeserializeFromString(relativePathToInstrumentationNode, typeof(InstrumentationNode), ApplicationNode.Hierarchy) as InstrumentationNode;

            Assert.AreEqual(instrumentationNode, deserializedInstance);
        }
Exemple #3
0
        /// <summary>
        /// Gets the a <see cref="ConfigurationSectionInfo"/> for the instrumentation section.
        /// </summary>
        /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
        /// <returns>A <see cref="ConfigurationSectionInfo"/> for the configuration for the configuration sources.</returns>
        protected override ConfigurationSectionInfo GetConfigurationSectionInfo(IServiceProvider serviceProvider)
        {
            ConfigurationNode   rootNode = ServiceHelper.GetCurrentRootNode(serviceProvider);
            InstrumentationNode node     = null;

            if (null != rootNode)
            {
                node = rootNode.Hierarchy.FindNodeByType(rootNode, typeof(InstrumentationNode)) as InstrumentationNode;
            }
            InstrumentationConfigurationSection instrumentationSection = null;

            if (node == null)
            {
                instrumentationSection = null;
            }
            else
            {
                instrumentationSection = node.InstrumentationConfigurationSection;
            }
            return(new ConfigurationSectionInfo(node, instrumentationSection, InstrumentationConfigurationSection.SectionName));
        }
        public void SerializationUtilityCanSerializeConfigurationNode()
        {
            InstrumentationNode instrumentationNode = new InstrumentationNode();
            ApplicationNode.AddNode(instrumentationNode);

            string serializedNode = SerializationUtility.SerializeToString(instrumentationNode, instrumentationNode.Hierarchy);
            string relativeNodePath = SerializationUtility.CreatePathRelativeToRootNode(instrumentationNode.Path, instrumentationNode.Hierarchy);
            Assert.AreEqual(relativeNodePath, serializedNode);
        }