ServerProperties.cs :  » Chat-Servers » Thresher » Sharkbite » Irc » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Chat Servers » Thresher 
Thresher » Sharkbite » Irc » ServerProperties.cs
using System;
using System.Collections;

namespace Sharkbite.Irc{
  /// <summary>
  /// Encapsulates the collection of properties sent by the IRC server
  /// after registration.
  /// </summary>
  /// <remarks>See the server_properties.pdf file for a list of comon properties.</remarks>
  /// <example><code>
  /// //This will only be non null if the connection has already received
  /// //a '005' reply and that such a reply is actually sent by the server.
  /// //This will happen right after registration.
  /// //Instances are only retrieved from a Connection and not instantiated directly.
  /// ServerProperties properties = connection.ServerProperties;
  /// //It should always be tested for null
  /// if( properties != null ) {
  /// Console.Writeline("NICKLEN is" + properties["NICKLEN"] );
  /// }
  /// //Only a handful of properties will ever be available.
  /// </code></example>
  public sealed class ServerProperties
  {
    private Hashtable properties;

    /// <summary>
    /// Instances should only be created by the Connection class.
    /// </summary>
    internal ServerProperties()
    {
      properties = new Hashtable();
    }

    /// <summary>
    /// Read-only indexer for the various server
    /// property strings.
    /// </summary>
    /// <returns>The string sent by the server or <see cref="String.Empty"/> if not present..</returns>
    public string this [ string key ] 
    {
      get
      {
        if( properties[ key ] != null ) 
        {
          return (string) properties[key];
        }
        else 
        {
          return String.Empty;
        }
      }
    }

    /// <summary>
    /// Add a property retrieved from the IRC 
    /// server.
    /// </summary>
    internal void SetProperty( string key, string propertyValue )
    {
      properties.Add( key, propertyValue );
    }

    /// <summary>
    /// Get a read-only enumeration of all the elements
    /// in this object.
    /// </summary>
    /// <returns>An IDictionaryEnumerator type enumeration.</returns>
    /// <example><code>
    /// //To loop over all the values  
    /// foreach( DictionaryEntry entry in connection.ServerProperties ) 
    /// {
    /// Console.WriteLine("Key:" + entry.Key + " Value:" + entry.Value );
    /// }
    /// </code></example>
    public IDictionaryEnumerator GetEnumerator()
    {
      return properties.GetEnumerator();
    }
    /// <summary>
    /// Test if this instance contains a given key.
    /// </summary>
    /// <param name="key">The server properties key to test.</param>
    /// <returns>True if it is present.</returns>
    public bool ContainsKey( string key ) 
    {
      return properties[ key] != null;
    }

  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.