Click here to Skip to main content
15,895,084 members
Articles / Programming Languages / XML

Adaptive Console Framework - Build Your Console Application on the Fly

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
18 Sep 2008CDDL9 min read 31K   286   15  
Introduces the goal and use of the Adaptive Console Framework.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace AdaptiveConsole.Config
{
    /// <summary>
    /// Represents a collection of repository configuration element.
    /// </summary>
    [ConfigurationCollection(typeof(RepositoryConfigElement),
        CollectionType = ConfigurationElementCollectionType.BasicMap,
        AddItemName = "repository")]
    public class RepositoryConfigElementCollection : ConfigurationElementCollection
    {
        /// <summary>
        /// Gets or sets a repository configuration element by its index in the collection.
        /// </summary>
        /// <param name="index">Index of the element in the collection.</param>
        /// <returns>The repository configuration element.</returns>
        public RepositoryConfigElement this[int index]
        {
            get { return (RepositoryConfigElement)base.BaseGet(index); }
            set
            {
                if (base.BaseGet(index) != null)
                    base.BaseRemoveAt(index);
                base.BaseAdd(index, value);
            }
        }
        /// <summary>
        /// Gets a repository configuration element by its name.
        /// </summary>
        /// <param name="name">Name of the element.</param>
        /// <returns>The repository configuration element.</returns>
        public new RepositoryConfigElement this[string name]
        {
            get { return (RepositoryConfigElement)base.BaseGet(name); }
        }

        /// <summary>
        /// Gets the collection type.
        /// </summary>
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }

        /// <summary>
        /// Provides the method that creates the new instance of the element.
        /// </summary>
        /// <returns>The created new instance.</returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new RepositoryConfigElement();
        }

        /// <summary>
        /// Gets the key of the element.
        /// </summary>
        /// <param name="element">The element from which the key is obtained.</param>
        /// <returns>The key.</returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return (element as RepositoryConfigElement).Name;
        }

        /// <summary>
        /// Gets the name of the element.
        /// </summary>
        protected override string ElementName
        {
            get
            {
                return "repository";
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Architect Prosource Development
China China
I have more than 13 years' experience in software development and more than 5 years' working experience in software industry. I'm the National Certified System Analyst and now I'm the consultant of China System Analyst Institution. I also got the MCP/MCAD certificate on .NET technology in the year 2004.
I'm very interested in system architect and analysis, and also interested in .NET technologies. For my blog please refer to http://www.sunnychen.org.

Comments and Discussions