Click here to Skip to main content
15,896,453 members
Articles / Programming Languages / C#

WS-Discovery for WCF

Rate me:
Please Sign up or sign in to vote.
4.95/5 (31 votes)
27 Nov 2008CPOL12 min read 139.9K   3.3K   86  
This article describes the design, implementation, and usage of WS-Discovery for Windows Communication Foundation (WCF).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//*****************************************************************************
//    Description.....WS-Discovey for WCF
//                                
//    Author..........Claudio Masieri, claudio@claudiomasieri.it
//    Copyright © 2008 ing.Masieri Claudio. (see included license.rtf file)    
//                        
//    Date Created:    06/06/06
//
//    Date        Modified By     Description
//-----------------------------------------------------------------------------
//    01/10/08    Claudio Masieri     First Release
//*****************************************************************************
namespace Masieri.ServiceModel.WSDiscovery.Service
{
  /// <summary>
  /// ScopeList class
  /// </summary>
  public class ScopeList : System.Collections.IEnumerable
  {
    List<string> _internalList;
    /// <summary>
    /// Occurs when [scope list modified].
    /// </summary>
    public event EventHandler ScopeListModified;
    /// <summary>
    /// Initializes a new instance of the <see cref="ScopeList"/> class.
    /// </summary>
    public ScopeList()
    {
      _internalList = new List<string>();
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="ScopeList"/> class.
    /// </summary>
    /// <param name="scopes">The scopes.</param>
    public ScopeList(string[] scopes)
    {
      _internalList = new List<string>(scopes);
    }
    /// <summary>
    /// Adds the specified scope.
    /// </summary>
    /// <param name="scope">The scope.</param>
    public void Add(string scope)
    {
      _internalList.Add(scope);
      OnScopeModified();
    }
    /// <summary>
    /// Adds the range.
    /// </summary>
    /// <param name="scopes">The scopes.</param>
    public void AddRange(string[] scopes)
    {
      _internalList.AddRange(scopes);
      OnScopeModified();
    }
    /// <summary>
    /// Removes the specified scope.
    /// </summary>
    /// <param name="scope">The scope.</param>
    public void Remove(string scope)
    {
      _internalList.Remove(scope);
      OnScopeModified();
    }
    /// <summary>
    /// Removes all.
    /// </summary>
    /// <param name="match">The match.</param>
    public void RemoveAll(Predicate<string> match)
    {
      _internalList.RemoveAll(match);
      OnScopeModified();
    }

    /// <summary>
    /// Called when [scope modified].
    /// </summary>
    private void OnScopeModified()
    {
      if (ScopeListModified != null)
        ScopeListModified(this, new EventArgs());
    }
    /// <summary>
    /// Gets the count.
    /// </summary>
    /// <value>The count.</value>
    public int Count { get { return _internalList.Count; } }
    /// <summary>
    /// Clears this instance.
    /// </summary>
    public void Clear()
    {
      _internalList.Clear();
    }
    /// <summary>
    /// Toes the array.
    /// </summary>
    /// <returns></returns>
    public string[] ToArray()
    {
      return _internalList.ToArray();
    }
    #region IEnumerable Members
    /// <summary>
    /// Returns an enumerator that iterates through a collection.
    /// </summary>
    /// <returns>
    /// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
    /// </returns>
    System.Collections.IEnumerator GetEnumerator()
    {
      return _internalList.GetEnumerator();
    }
    #endregion
    #region IEnumerable Members
    /// <summary>
    /// Returns an enumerator that iterates through a collection.
    /// </summary>
    /// <returns>
    /// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
    /// </returns>
    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
      return _internalList.GetEnumerator();
    }
    #endregion

    
  }
}

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)


Written By
Software Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions