Files
mono/mcs/class/System.XML/System.Xml/NameTable.cs
T
Duncan Mak c6fbc77fe6 2002-03-12 Duncan Mak <[email protected]>
* XmlCharacterData.cs: Reformatted the properties for better readability.

	* XmlLinkedNode.cs: Removed the awful boxy comments.

	* XmlNamedNodeMap.cs (Count):
	(Item): Implemented. Tests will be coming.

	* XmlEntityReference.cs:
	* XmlSignificantWhitespace.cs: Implemented these classes except for
	the Clone, WriteContentTo and WriteTo methods. Will have to
	investigate into these later.

svn path=/trunk/mcs/; revision=3081
2002-03-13 00:04:40 +00:00

75 lines
1.4 KiB
C#
Executable File

//
// System.Xml.NameTable.cs
//
// Author: Duncan Mak ([email protected])
//
// (C) Ximian, Inc.
//
using System;
using System.Collections;
namespace System.Xml
{
public class NameTable : XmlNameTable
{
// Fields
Hashtable table;
// Constructor
public NameTable ()
: base ()
{
table = new Hashtable ();
}
// Method
public override string Add (string key)
{
if (table.Contains (key))
return (string) table [key];
else {
table.Add (key, key);
return key;
}
}
public override string Add (char[] key, int start, int len)
{
if (((0 > start) && (start >= key.Length))
|| ((0 > len) && (len >= key.Length - len)))
throw new IndexOutOfRangeException ("The Index is out of range.");
if (len == 0)
return String.Empty;
string item = new string (key, start, len);
return Add (item);
}
public override string Get (string key)
{
if (! (table.Contains (key)))
return null;
else
return (string) table [key];
}
public override string Get (char[] array, int offset, int length)
{
if (((0 > offset) && (offset >= array.Length))
|| ((0 > length) && (length >= array.Length - offset)))
throw new IndexOutOfRangeException ("The Index is out of range.");
if (length == 0)
return String.Empty;
string key = new string (array, offset, length);
return Get (key);
}
}
}