コード例 #1
0
 public void DefaultNodeTest()
 {
     ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();
     CreateHierarchyAndAddToHierarchyService(node, CreateDefaultConfiguration());
     Assert.AreEqual(1, node.Nodes.Count);
     Assert.AreEqual(SR.DefaultEncryptionSettingsNodeName, node.Nodes[0].Name);
 }
コード例 #2
0
        /// <summary>
        /// <para>Opens the configuration settings and registers them with the application.</para>
        /// </summary>
        /// <param name="serviceProvider">
        /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para>
        /// </param>
        public void Open(IServiceProvider serviceProvider)
        {
            ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider);
            ConfigurationSectionCollectionNode sectionsNode = null;
            ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider);
            RemoveCurrentConfigurationSectionCollectionNode(serviceProvider);
            try
            {
                string appName = SR.DefaultApplicationName;
                ConfigurationSettings configurationSettings = configurationContext.GetMetaConfiguration();
                if (null != configurationSettings)
                {
                    appName = configurationSettings.ApplicationName;
                    if (configurationSettings.ConfigurationSections.Count > 0)
                    {
                        sectionsNode = new ConfigurationSectionCollectionNode(configurationSettings);
                        configurationNode.Nodes.Add(sectionsNode);
                    }
                }
                if (configurationNode is ApplicationConfigurationNode)
                {
                    ((ApplicationConfigurationNode)configurationNode).Name = appName;
                }
            }
            catch (ConfigurationException e)
            {
                ServiceHelper.LogError(serviceProvider, sectionsNode, e);

            }
        }
コード例 #3
0
        public void DefaultNodeTest()
        {
            ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();

            CreateHierarchyAndAddToHierarchyService(node, CreateDefaultConfiguration());
            Assert.AreEqual(1, node.Nodes.Count);
            Assert.AreEqual(SR.DefaultEncryptionSettingsNodeName, node.Nodes[0].Name);
        }
コード例 #4
0
ファイル: UIHierarchyFixture.cs プロジェクト: bnantz/NCS-V1-1
 public void FindByPathTest()
 {
     ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();
     hierarchy.RootNode = appNode;
     appNode.Nodes.Add(node);
     node.Nodes.Add(new ConfigurationSectionNode());
     ConfigurationNode foundNode = hierarchy.FindNodeByPath(node.Path);
     Assert.AreSame(node, foundNode);
 }
コード例 #5
0
ファイル: UIHierarchyFixture.cs プロジェクト: bnantz/NCS-V1-1
 public void FindByTypeGrandChildTest()
 {
     ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();
     hierarchy.RootNode = appNode;
     appNode.Nodes.Add(node);
     node.Nodes.Add(new ConfigurationSectionCollectionNode());
     ConfigurationNode[] foundNodes = hierarchy.FindNodesByType(typeof(ConfigurationSectionCollectionNode));
     Assert.AreEqual(2, foundNodes.Length);
 }
コード例 #6
0
        public void FindByTypeGrandChildTest()
        {
            ApplicationConfigurationNode       appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            ConfigurationSectionCollectionNode node    = new ConfigurationSectionCollectionNode();

            hierarchy.RootNode = appNode;
            appNode.Nodes.Add(node);
            node.Nodes.Add(new ConfigurationSectionCollectionNode());
            ConfigurationNode[] foundNodes = hierarchy.FindNodesByType(typeof(ConfigurationSectionCollectionNode));
            Assert.AreEqual(2, foundNodes.Length);
        }
コード例 #7
0
        public void OpenTest()
        {
            Assert.AreEqual(0, GeneratedApplicationNode.Nodes.Count);
            manager.Register(Host);
            manager.Open(Host);
            Assert.AreEqual(SR.DefaultConfigurationSectionCollectionNodeName, GeneratedApplicationNode.Nodes[0].Name);
            ConfigurationSectionCollectionNode sectionsNode = GeneratedApplicationNode.Nodes[0] as ConfigurationSectionCollectionNode;

            Assert.IsNotNull(sectionsNode);
            Assert.AreEqual("Test", sectionsNode.Nodes[1].Name);
        }
コード例 #8
0
        public void FindByPathTest()
        {
            ApplicationConfigurationNode       appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            ConfigurationSectionCollectionNode node    = new ConfigurationSectionCollectionNode();

            hierarchy.RootNode = appNode;
            appNode.Nodes.Add(node);
            node.Nodes.Add(new ConfigurationSectionNode());
            ConfigurationNode foundNode = hierarchy.FindNodeByPath(node.Path);

            Assert.AreSame(node, foundNode);
        }
コード例 #9
0
        public void ExecuteTest()
        {
            AddConfigurationSectionCommand command = new AddConfigurationSectionCommand(Host, typeof(MockConfigurationNode), "mySection");

            command.Execute(GeneratedApplicationNode);
            Assert.AreEqual(2, GeneratedApplicationNode.Nodes.Count);
            ConfigurationSectionCollectionNode collectionNode = (ConfigurationSectionCollectionNode)GeneratedHierarchy.FindNodeByType(GeneratedApplicationNode, typeof(ConfigurationSectionCollectionNode));

            Assert.IsNotNull(collectionNode);
            ConfigurationSectionNode sectionNode = GeneratedHierarchy.FindNodeByName(collectionNode, "mySection") as ConfigurationSectionNode;

            Assert.IsNotNull(sectionNode);
        }
コード例 #10
0
 private ConfigurationSectionCollectionNode SelectConfigurationSectionsNode()
 {
     IUIHierarchy hierarchy = UIHierarchyService.SelectedHierarchy;
     ApplicationConfigurationNode applicationNode = hierarchy.RootNode as ApplicationConfigurationNode;
     Debug.Assert(applicationNode != null, "Expected an application node to be root for this node.");
     ConfigurationSectionCollectionNode sectionsNode = (ConfigurationSectionCollectionNode)hierarchy.FindNodeByType(hierarchy.RootNode, typeof(ConfigurationSectionCollectionNode));
     if (sectionsNode == null)
     {
         sectionsNode = new ConfigurationSectionCollectionNode();
         applicationNode.Nodes.AddWithDefaultChildren(sectionsNode);
     }
     return sectionsNode;
 }
コード例 #11
0
 public void CanFindHierarchyTest()
 {
     ConfigurationDesignHost host = new ConfigurationDesignHost();
     UIHierarchyService hierarchyService = host.GetService(typeof(IUIHierarchyService)) as UIHierarchyService;
     Assert.IsNotNull(hierarchyService);
     ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     UIHierarchy hierarchy = new UIHierarchy(appNode, host, new ConfigurationContext(appNode.ConfigurationFile));
     ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();
     appNode.Nodes.Add(node);
     node.Nodes.Add(new ConfigurationSectionNode());
     hierarchyService.AddHierarchy(hierarchy);
     IUIHierarchy foundHierarchy = hierarchyService.GetHierarchy(appNode.Id);
     Assert.AreSame(hierarchy, foundHierarchy);
 }
コード例 #12
0
        public void FindByTypeTwoTopSearchFromOneLowerChildTest()
        {
            ApplicationConfigurationNode       appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            ConfigurationSectionCollectionNode node    = new ConfigurationSectionCollectionNode();

            hierarchy.RootNode = appNode;
            appNode.Nodes.Add(node);
            EncryptionSettingsNode             node2 = new EncryptionSettingsNode();
            ConfigurationSectionCollectionNode node3 = new ConfigurationSectionCollectionNode();

            appNode.Nodes.Add(node2);
            node2.Nodes.Add(node3);
            node3.Nodes.Add(new ConfigurationSectionNode());
            node3.Nodes.Add(new ConfigurationSectionNode());
            ConfigurationNode[] foundNodes = hierarchy.FindNodesByType(typeof(ConfigurationSectionNode));
            Assert.AreEqual(2, foundNodes.Length);
        }
コード例 #13
0
 public void AddHierarchyAndEventFiredTest()
 {
     ConfigurationDesignHost host = new ConfigurationDesignHost();
     UIHierarchyService hierarchyService = host.GetService(typeof(IUIHierarchyService)) as UIHierarchyService;
     hierarchyService.HierarchyAdded += new HierarchyAddedEventHandler(OnHierarchyAdded);
     Assert.IsNotNull(hierarchyService);
     ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     IUIHierarchy hierarchy = new UIHierarchy(appNode, host, new ConfigurationContext(appNode.ConfigurationFile));
     hierarchyService.AddHierarchy(hierarchy);
     Assert.IsTrue(addEventCalled);
     Assert.AreEqual(1, addEventCount);
     Assert.AreSame(hierarchy, eventHierarchy);
     ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();
     appNode.Nodes.Add(node);
     node.Nodes.Add(new ConfigurationSectionNode());
     Assert.AreEqual(1, hierarchyService.hierarchies.Count);
 }
コード例 #14
0
        public void CanFindHierarchyTest()
        {
            ConfigurationDesignHost host             = new ConfigurationDesignHost();
            UIHierarchyService      hierarchyService = host.GetService(typeof(IUIHierarchyService)) as UIHierarchyService;

            Assert.IsNotNull(hierarchyService);
            ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            UIHierarchy hierarchy = new UIHierarchy(appNode, host, new ConfigurationContext(appNode.ConfigurationFile));
            ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();

            appNode.Nodes.Add(node);
            node.Nodes.Add(new ConfigurationSectionNode());
            hierarchyService.AddHierarchy(hierarchy);
            IUIHierarchy foundHierarchy = hierarchyService.GetHierarchy(appNode.Id);

            Assert.AreSame(hierarchy, foundHierarchy);
        }
コード例 #15
0
        public override void SetUp()
        {
            base.SetUp();
            INodeCreationService nodeCreationService = GetService(typeof(INodeCreationService)) as INodeCreationService;

            Assert.IsNotNull(nodeCreationService);

            Type nodeType           = typeof(CustomKeyAlgorithmStorageProviderNode);
            NodeCreationEntry entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(CustomKeyAlgorithmPairStorageProviderData), SR.CustomKeyAlgorithmPairStorageProviderNodeDefaultName);

            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(CustomTransformerNode);
            entry    = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(CustomTransformerData), SR.CustomTransformerNodeDefaultName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(CustomStorageProviderNode);
            entry    = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(CustomStorageProviderData), SR.CustomStorageProviderNodeDefaultName);
            nodeCreationService.AddNodeCreationEntry(entry);


            nodeType = typeof(XmlFileStorageProviderNode);
            entry    = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(XmlFileStorageProviderData), SR.XMLStorageProviderNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(XmlSerializerTransformerNode);
            entry    = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(XmlSerializerTransformerData), SR.XmlSerializerTransformerNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(ConfigurationSectionNode);
            entry    = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(ConfigurationSectionData), SR.ConfigurationSectionNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(ReadOnlyConfigurationSectionNode);
            entry    = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(ReadOnlyConfigurationSectionData), SR.ReadOnlyConfigurationSectionNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(FileKeyAlgorithmPairStorageProviderNode);
            entry    = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddFileKeyAlgorithmPairNodeCommand(Host, nodeType), nodeType, typeof(FileKeyAlgorithmPairStorageProviderData), SR.FileKeyAlgorithmStorageProviderNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            configurationSectionsNode = new ConfigurationSectionCollectionNode(ConfigurationSettingsBuilder.Create());
            Assert.IsNotNull(configurationSectionsNode);
            CreateHierarchyAndAddToHierarchyService(configurationSectionsNode, CreateDefaultConfiguration());
        }
コード例 #16
0
        public void MakeSureThatIncludeTypesAreAddedForTheSection()
        {
            AddConfigurationSectionCommand cmd = new AddConfigurationSectionCommand(Host, typeof(MyConfigurationNode), section);

            cmd.Execute(GeneratedApplicationNode);

            ConfigurationSectionCollectionNode node = (ConfigurationSectionCollectionNode)GeneratedHierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode));

            Assert.IsNotNull(node);
            ConfigurationSectionNode sectionNode = (ConfigurationSectionNode)GeneratedHierarchy.FindNodeByName(node, section);

            ConfigurationNode[] types = GeneratedHierarchy.FindNodesByType(sectionNode, typeof(XmlIncludeTypeNode));
            Assert.AreEqual(1, types.Length);
            XmlIncludeTypeNode xmlIncludeTypeNode = types[0] as XmlIncludeTypeNode;

            Assert.IsNotNull(xmlIncludeTypeNode);
            Assert.AreEqual(xmlIncludeTypeNode.Name, typeof(MyConfigurationData).Name);
        }
コード例 #17
0
        public void AddHierarchyAndEventFiredTest()
        {
            ConfigurationDesignHost host             = new ConfigurationDesignHost();
            UIHierarchyService      hierarchyService = host.GetService(typeof(IUIHierarchyService)) as UIHierarchyService;

            hierarchyService.HierarchyAdded += new HierarchyAddedEventHandler(OnHierarchyAdded);
            Assert.IsNotNull(hierarchyService);
            ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            IUIHierarchy hierarchy = new UIHierarchy(appNode, host, new ConfigurationContext(appNode.ConfigurationFile));

            hierarchyService.AddHierarchy(hierarchy);
            Assert.IsTrue(addEventCalled);
            Assert.AreEqual(1, addEventCount);
            Assert.AreSame(hierarchy, eventHierarchy);
            ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();

            appNode.Nodes.Add(node);
            node.Nodes.Add(new ConfigurationSectionNode());
            Assert.AreEqual(1, hierarchyService.hierarchies.Count);
        }
コード例 #18
0
        public void TwoNodesShareTheSameConfigurationAndIncludeTypeRemoveOneIncludeTypeRemains()
        {
            AddConfigurationSectionCommand cmd = new AddConfigurationSectionCommand(Host, typeof(MyConfigurationNode), section);

            cmd.Execute(GeneratedApplicationNode);
            cmd.Execute(GeneratedApplicationNode);
            ConfigurationNode secondAddedNode = cmd.ChildNode;

            RemoveNodeCommand removeNodeCommand = new RemoveNodeCommand(Host);

            removeNodeCommand.Execute(secondAddedNode);

            ConfigurationSectionCollectionNode node = (ConfigurationSectionCollectionNode)GeneratedHierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode));

            Assert.IsNotNull(node);
            ConfigurationSectionNode sectionNode = (ConfigurationSectionNode)GeneratedHierarchy.FindNodeByName(node, section);

            ConfigurationNode[] types = GeneratedHierarchy.FindNodesByType(sectionNode, typeof(XmlIncludeTypeNode));
            Assert.AreEqual(1, types.Length);
            XmlIncludeTypeNode xmlIncludeTypeNode = types[0] as XmlIncludeTypeNode;

            Assert.IsNotNull(xmlIncludeTypeNode);
            Assert.AreEqual(xmlIncludeTypeNode.Name, typeof(MyConfigurationData).Name);
        }
コード例 #19
0
        public void SaveTest()
        {
            manager.Register(Host);
            manager.Open(Host);
            Assert.AreEqual(SR.DefaultConfigurationSectionCollectionNodeName, GeneratedApplicationNode.Nodes[0].Name);
            ConfigurationSectionCollectionNode sectionsNode = GeneratedApplicationNode.Nodes[0] as ConfigurationSectionCollectionNode;

            Assert.IsNotNull(sectionsNode);
            Assert.AreEqual("Test", sectionsNode.Nodes[1].Name);
            manager.Save(Host);
            GeneratedApplicationNode.Nodes.Clear();
            Assert.AreEqual(0, GeneratedApplicationNode.childNodeLookup.Count);
            ApplicationConfigurationNode node = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
            IUIHierarchy hierarchy            = CreateHierarchyAndAddToHierarchyService(node, CreateDefaultConfiguration());

            base.HierarchyService.SelectedHierarchy = hierarchy;
            manager.Open(Host);
            Assert.AreEqual(1, node.Nodes.Count);
            Assert.AreEqual(SR.DefaultConfigurationSectionCollectionNodeName, node.Nodes[0].Name);
            sectionsNode = node.Nodes[0] as ConfigurationSectionCollectionNode;
            Assert.IsNotNull(sectionsNode);
            Assert.AreEqual("Test", sectionsNode.Nodes[1].Name);
            manager.Save(Host);
        }
コード例 #20
0
ファイル: UIHierarchyFixture.cs プロジェクト: bnantz/NCS-V1-1
 public void FindByTypeTwoTopSearchFromOneLowerChildTest()
 {
     ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();
     hierarchy.RootNode = appNode;
     appNode.Nodes.Add(node);
     EncryptionSettingsNode node2 = new EncryptionSettingsNode();
     ConfigurationSectionCollectionNode node3 = new ConfigurationSectionCollectionNode();
     appNode.Nodes.Add(node2);
     node2.Nodes.Add(node3);
     node3.Nodes.Add(new ConfigurationSectionNode());
     node3.Nodes.Add(new ConfigurationSectionNode());
     ConfigurationNode[] foundNodes = hierarchy.FindNodesByType(typeof(ConfigurationSectionNode));
     Assert.AreEqual(2, foundNodes.Length);
 }
コード例 #21
0
        public override void SetUp()
        {
            base.SetUp();
            INodeCreationService nodeCreationService = GetService(typeof(INodeCreationService)) as INodeCreationService;
            Assert.IsNotNull(nodeCreationService);

            Type nodeType = typeof(CustomKeyAlgorithmStorageProviderNode);
            NodeCreationEntry entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(CustomKeyAlgorithmPairStorageProviderData), SR.CustomKeyAlgorithmPairStorageProviderNodeDefaultName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(CustomTransformerNode);
            entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(CustomTransformerData), SR.CustomTransformerNodeDefaultName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(CustomStorageProviderNode);
            entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(CustomStorageProviderData), SR.CustomStorageProviderNodeDefaultName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(XmlFileStorageProviderNode);
            entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(XmlFileStorageProviderData), SR.XMLStorageProviderNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(XmlSerializerTransformerNode);
            entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(XmlSerializerTransformerData), SR.XmlSerializerTransformerNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(ConfigurationSectionNode);
            entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(ConfigurationSectionData), SR.ConfigurationSectionNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(ReadOnlyConfigurationSectionNode);
            entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddChildNodeCommand(Host, nodeType), nodeType, typeof(ReadOnlyConfigurationSectionData), SR.ReadOnlyConfigurationSectionNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            nodeType = typeof(FileKeyAlgorithmPairStorageProviderNode);
            entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples(new AddFileKeyAlgorithmPairNodeCommand(Host, nodeType), nodeType, typeof(FileKeyAlgorithmPairStorageProviderData), SR.FileKeyAlgorithmStorageProviderNodeFriendlyName);
            nodeCreationService.AddNodeCreationEntry(entry);

            configurationSectionsNode = new ConfigurationSectionCollectionNode(ConfigurationSettingsBuilder.Create());
            Assert.IsNotNull(configurationSectionsNode);
            CreateHierarchyAndAddToHierarchyService(configurationSectionsNode, CreateDefaultConfiguration());
        }