Click here to Skip to main content
12,356,784 members (62,914 online)
Click here to Skip to main content

Stats

70.4K views
1.9K downloads
62 bookmarked
Posted

WCF Service Behavior Example: IPFilter - Allow/Deny Access by IP Address

, 15 Jun 2009 CPOL
WCF Service Behavior Example: IPFilter - Allow/Deny Access by IP Address
IPFilterTests
bin
Debug
IPFilter.dll
IPFilterTests.dll
Configuration
Mock
Properties
TestWebsite
App_Data
bin
IPFilter.dll
IPFilter.pdb
TestWebsite.dll
TestWebsite.pdb
Filtered
Properties
TestWebsite.csproj.user
IPFilterExample.suo
IPFilterExample.vsmdi
IPFilterExample1.vsmdi
IPFilterExample2.vsmdi
LocalTestRun.testrunconfig
IPFilter
bin
Debug
IPFilter.dll
Configuration
Properties
IPFilterExample3.vsmdi
LocalTestRun.testrunconfig
IPFilter.dll
IPFilter.csproj.user
IPFilter.dll
IPFilterTests.dll
IPFilter.dll
IPFilter.pdb
TestWebsite.dll
TestWebsite.pdb
TestWebsite.csproj.user
IPFilterExample.vsmdi
IPFilterExample1.vsmdi
IPFilterExample2.vsmdi
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace IPFiltering.Configuration
{
    public class FilterConfigurationCollection : ConfigurationElementCollection
    {

        /// <summary>
        /// Gets the <see cref="IPFilter.Configuration.FilterConfiguration"/> at the specified index.
        /// </summary>
        /// <value></value>
        public FilterConfiguration this[int index]
        {
            get
            {
                return this.BaseGet(index) as FilterConfiguration;
            }
        }

        /// <summary>
        /// Gets the <see cref="IPFilter.Configuration.FilterConfiguration"/> with the specified name.
        /// </summary>
        /// <value></value>
        public FilterConfiguration this[string name]
        {
            get
            {
                return this.BaseGet(name) as FilterConfiguration;
            }
        }

        /// <summary>
        /// Gets the type of the <see cref="T:System.Configuration.ConfigurationElementCollection"/>.
        /// </summary>
        /// <value></value>
        /// <returns>The <see cref="T:System.Configuration.ConfigurationElementCollectionType"/> of this collection.</returns>
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.AddRemoveClearMap;
            }
        }


        

        /// <summary>
        /// When overridden in a derived class, creates a new <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </summary>
        /// <returns>
        /// A new <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new FilterConfiguration();
        }

        /// <summary>
        /// Gets the element key for a specified configuration element when overridden in a derived class.
        /// </summary>
        /// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement"/> to return the key for.</param>
        /// <returns>
        /// An <see cref="T:System.Object"/> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return (element as FilterConfiguration).Name;
        }
    }
}

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 Code Project Open License (CPOL)

Share

About the Author

Ziad Elmalki
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 16 Jun 2009
Article Copyright 2009 by Ziad Elmalki
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid