Ejemplo n.º 1
0
        /// <devdoc>
        /// Creates a new ConfigurationSectionNode with storage and transformer.
        /// </devdoc>
        internal static ReadOnlyConfigurationSectionNode CreateReadOnlyDefault(string sectionName, ConfigurationNode parent)
        {
            ReadOnlyConfigurationSectionNode sectionNode = new ReadOnlyConfigurationSectionNode(new ReadOnlyConfigurationSectionData(sectionName));

            parent.Nodes.Add(sectionNode);
            XmlFileStorageProviderNode storageNode = new XmlFileStorageProviderNode(new XmlFileStorageProviderData(SR.XMLStorageProviderNodeFriendlyName, sectionName + ".config"));

            sectionNode.Nodes.Add(storageNode);
            XmlSerializerTransformerNode transformerNode = new XmlSerializerTransformerNode();

            sectionNode.Nodes.Add(transformerNode);
            return(sectionNode);
        }
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ConfigurationSectionCollectionNode configurationSectionCollectionNode = CurrentHierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode)) as ConfigurationSectionCollectionNode;

            if (configurationSectionCollectionNode == null)
            {
                return;
            }

            IXmlIncludeTypeService service = XmlIncludeTypeService;

            Type[] types = null;
            XmlSerializerTransformerNode transformerNode = null;

            foreach (ConfigurationNode configurationNode in configurationSectionCollectionNode.Nodes)
            {
                transformerNode = CurrentHierarchy.FindNodeByType(configurationNode, typeof(XmlSerializerTransformerNode)) as XmlSerializerTransformerNode;
                if (transformerNode == null)
                {
                    continue;
                }
                types = service.GetXmlIncludeTypes(configurationNode.Name);
                if (types == null)
                {
                    continue;
                }
                ArrayList nodesToRemove = new ArrayList();
                foreach (Type t in types)
                {
                    if (!FindNodTypeToDataTypeMatchRecursive(node, t))
                    {
                        continue;
                    }
                    foreach (XmlIncludeTypeNode xmlIncludeTypeNode in transformerNode.Nodes)
                    {
                        Type includeType = Type.GetType(xmlIncludeTypeNode.TypeName, false, true);
                        if (includeType.Equals(t))
                        {
                            nodesToRemove.Add(xmlIncludeTypeNode);
                        }
                    }
                }
                foreach (ConfigurationNode nodeToRemove in nodesToRemove)
                {
                    nodeToRemove.Remove();
                }
            }
        }
Ejemplo n.º 3
0
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ConfigurationSectionCollectionNode configurationSectionCollectionNode = node.Hierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode)) as ConfigurationSectionCollectionNode;

            if (configurationSectionCollectionNode == null)
            {
                return;
            }

            IXmlIncludeTypeService service = GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;

            Type[] types = null;
            XmlSerializerTransformerNode transformerNode = null;

            foreach (ConfigurationNode configurationNode in configurationSectionCollectionNode.Nodes)
            {
                transformerNode = node.Hierarchy.FindNodeByType(configurationNode, typeof(XmlSerializerTransformerNode)) as XmlSerializerTransformerNode;
                if (transformerNode == null)
                {
                    continue;
                }
                types = service.GetXmlIncludeTypes(configurationNode.Name);
                if (types == null)
                {
                    continue;
                }
                foreach (Type t in types)
                {
                    INodeCreationService nodeCreationService = (INodeCreationService)GetService(typeof(INodeCreationService));
                    if (!nodeCreationService.DoesNodeTypeMatchDataType(nodeType, t))
                    {
                        continue;
                    }
                    if (node.Hierarchy.FindNodeByName(transformerNode, t.Name) == null)
                    {
                        transformerNode.Nodes.Add(new XmlIncludeTypeNode(new XmlIncludeTypeData(t.Name, t.AssemblyQualifiedName)));
                    }
                }
            }
        }
Ejemplo n.º 4
0
 /// <devdoc>
 /// Creates a new ConfigurationSectionNode with storage and transformer.
 /// </devdoc>
 internal static ReadOnlyConfigurationSectionNode CreateReadOnlyDefault(string sectionName, ConfigurationNode parent)
 {
     ReadOnlyConfigurationSectionNode sectionNode = new ReadOnlyConfigurationSectionNode(new ReadOnlyConfigurationSectionData(sectionName));
     parent.Nodes.Add(sectionNode);
     XmlFileStorageProviderNode storageNode = new XmlFileStorageProviderNode(new XmlFileStorageProviderData(SR.XMLStorageProviderNodeFriendlyName, sectionName + ".config"));
     sectionNode.Nodes.Add(storageNode);
     XmlSerializerTransformerNode transformerNode = new XmlSerializerTransformerNode();
     sectionNode.Nodes.Add(transformerNode);
     return sectionNode;
 }