/// <summary>
        /// Adds a node map that can only be created more than once.
        /// </summary>
        /// <param name="text">The text to display to the user.</param>
        /// <param name="nodeType">The type of node to create.</param>
        /// <param name="dataType">The configuration type for the node.</param>
        protected void AddMultipleNodeMap(string text, Type nodeType, Type dataType)
        {
            INodeCreationService nodeCreationService = ServiceHelper.GetNodeCreationService(serviceProvider);

            nodeCreationService.AddNodeCreationEntry(NodeCreationEntry.CreateNodeCreationEntryWithMultiples(
                                                         new AddChildNodeCommand(serviceProvider, nodeType),
                                                         nodeType,
                                                         dataType,
                                                         text));
        }
Beispiel #2
0
        /// <summary>
        /// Creates a map between the node and the data that it represents.
        /// </summary>
        /// <param name="nodeCreationEntry">
        /// A <see cref="NodeCreationEntry"/> object.
        /// </param>
        public void AddNodeCreationEntry(NodeCreationEntry nodeCreationEntry)
        {
            if (null == nodeCreationEntry) throw new ArgumentNullException("nodeCreationEntry");

            string displayName = nodeCreationEntry.DisplayName;
            nodeTypesByDataType[nodeCreationEntry.DataType.FullName] = nodeCreationEntry.NodeType;

            Type baseType = nodeCreationEntry.NodeType.BaseType;
            Type nodeTypeToStore = nodeCreationEntry.NodeType;
            while(baseType != typeof(ConfigurationNode))
            {
                nodeTypeToStore = baseType;
                baseType = baseType.BaseType;
            }
            nodeCreationEntry.BaseTypeToCompare = nodeTypeToStore;
            AddNamesForBaseType(nodeTypeToStore.FullName, displayName);
        }
Beispiel #3
0
        /// <devdoc>
        /// Creates a map between the node and the data that it represents.
        /// </devdoc>
        public void AddNodeCreationEntry(NodeCreationEntry nodeCreationEntry)
        {
            ArgumentValidation.CheckForNullReference(nodeCreationEntry, "nodeCreationEntry");

            nodeEntryByDisplayName[nodeCreationEntry.DisplayName] = nodeCreationEntry;
            string displayName = nodeCreationEntry.DisplayName;
            nodeTypesByDataType[nodeCreationEntry.DataType.FullName] = nodeCreationEntry.NodeType;

            Type baseType = nodeCreationEntry.NodeType.BaseType;
            Type nodeTypeToStore = nodeCreationEntry.NodeType;
            while(baseType != typeof(ConfigurationNode))
            {
                nodeTypeToStore = baseType;
                baseType = baseType.BaseType;
            }
            nodeTypeByDisplayName[displayName] = nodeTypeToStore;
            nodeCreationEntry.BaseTypeToCompare = nodeTypeToStore;
            AddNamesForBaseType(nodeTypeToStore.FullName, displayName);
        }
Beispiel #4
0
        /// <summary>
        /// <para>Create menu items based on the nodes registered with the <see cref="INodeCreationService"/> for the spefied type.</para>
        /// </summary>
        /// <param name="nodeType">
        /// <para>The type to create menu items.</para>
        /// </param>
        protected void CreateDynamicMenuItems(Type nodeType)
        {
            INodeCreationService  service = ServiceHelper.GetNodeCreationService(Site);
            StringCollection      names   = service.GetDisplayNames(nodeType);
            ConfigurationMenuItem item    = null;

            foreach (string name in names)
            {
                NodeCreationEntry entry = service.GetNodeCreationEntry(name);
                item = new ConfigurationMenuItem(name, entry.ConfigurationNodeCommand, this, Shortcut.None, SR.GenericCreateStatusText(name), InsertionPoint.New);
                if (!entry.AllowMultiple)
                {
                    if (Hierarchy.ContainsNodeType(this, nodeType /*entry.BaseTypeToCompare*/))
                    {
                        item.Enabled = false;
                    }
                }
                AddMenuItem(item);
            }
        }
Beispiel #5
0
        /// <devdoc>
        /// Creates a map between the node and the data that it represents.
        /// </devdoc>
        public void AddNodeCreationEntry(NodeCreationEntry nodeCreationEntry)
        {
            ArgumentValidation.CheckForNullReference(nodeCreationEntry, "nodeCreationEntry");

            nodeEntryByDisplayName[nodeCreationEntry.DisplayName] = nodeCreationEntry;
            string displayName = nodeCreationEntry.DisplayName;

            nodeTypesByDataType[nodeCreationEntry.DataType.FullName] = nodeCreationEntry.NodeType;

            Type baseType        = nodeCreationEntry.NodeType.BaseType;
            Type nodeTypeToStore = nodeCreationEntry.NodeType;

            while (baseType != typeof(ConfigurationNode))
            {
                nodeTypeToStore = baseType;
                baseType        = baseType.BaseType;
            }
            nodeTypeByDisplayName[displayName]  = nodeTypeToStore;
            nodeCreationEntry.BaseTypeToCompare = nodeTypeToStore;
            AddNamesForBaseType(nodeTypeToStore.FullName, displayName);
        }
        /// <summary>
        /// Creates a map between the node and the data that it represents.
        /// </summary>
        /// <param name="nodeCreationEntry">
        /// A <see cref="NodeCreationEntry"/> object.
        /// </param>
        public void AddNodeCreationEntry(NodeCreationEntry nodeCreationEntry)
        {
            if (null == nodeCreationEntry)
            {
                throw new ArgumentNullException("nodeCreationEntry");
            }

            string displayName = nodeCreationEntry.DisplayName;

            nodeTypesByDataType[nodeCreationEntry.DataType.FullName] = nodeCreationEntry.NodeType;

            Type baseType        = nodeCreationEntry.NodeType.BaseType;
            Type nodeTypeToStore = nodeCreationEntry.NodeType;

            while (baseType != typeof(ConfigurationNode))
            {
                nodeTypeToStore = baseType;
                baseType        = baseType.BaseType;
            }
            nodeCreationEntry.BaseTypeToCompare = nodeTypeToStore;
            AddNamesForBaseType(nodeTypeToStore.FullName, displayName);
        }
Beispiel #7
0
        private static void RegisterNodeMaps(IServiceProvider serviceProvider)
        {
            INodeCreationService nodeCreationService = ServiceHelper.GetNodeCreationService(serviceProvider);

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

            nodeCreationService.AddNodeCreationEntry(entry);

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

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

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

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

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

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

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