Files
mono/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs
T
Tim Coleman 52a614cc31 2002-07-24 Tim Coleman <[email protected]>
* CodeIdentifier.cs:
        * IXmlSerializable.cs:
        * XmlSerializationCollectionFixupCallback.cs:
        * XmlSerializationFixupCallback.cs:
        * XmlSerializationReadCallback.cs:
        * XmlSerializationReader.cs:
        * XmlSerializationWriteCallback.cs:
                Add new classes.
        * XmlSchemas.cs
        * CodeIdentifiers.cs:
                Implement some of these classes
        * XmlCodeExporter.cs:
                Fix return type of a function

svn path=/trunk/mcs/; revision=6157
2002-07-24 19:52:33 +00:00

109 lines
2.0 KiB
C#

//
// System.Xml.Serialization.CodeIdentifiers
//
// Author:
// Tim Coleman ([email protected])
//
// Copyright (C) Tim Coleman, 2002
//
using System;
using System.Collections;
namespace System.Xml.Serialization {
public class CodeIdentifiers {
#region Fields
bool useCamelCasing;
static Hashtable table = new Hashtable ();
#endregion
#region Constructors
public CodeIdentifiers ()
{
}
#endregion // Constructors
#region Properties
public bool UseCamelCasing {
get { return useCamelCasing; }
set { useCamelCasing = value; }
}
#endregion // Properties
#region Methods
public void Add (string identifier, object value)
{
table.Add (identifier, value);
}
[MonoTODO ("What does this do?")]
public void AddReserved (string identifier)
{
throw new NotImplementedException ();
}
public void AddUnique (string identifier, object value)
{
Add (MakeUnique (identifier), value);
}
public void Clear ()
{
table.Clear ();
}
public bool IsInUse (string identifier)
{
return (table.ContainsKey (identifier));
}
public string MakeRightCase (string identifier)
{
if (UseCamelCasing)
return CodeIdentifier.MakeCamel (identifier);
else
return CodeIdentifier.MakePascal (identifier);
}
public string MakeUnique (string identifier)
{
string uniqueIdentifier = identifier;
int i = 1;
while (IsInUse (uniqueIdentifier)) {
uniqueIdentifier = String.Format ("{0}{1}", identifier, i.ToString ());
i += 1;
}
return uniqueIdentifier;
}
public void Remove (string identifier)
{
table.Remove (identifier);
}
[MonoTODO ("What does this do?")]
public void RemoveReserved (string identifier)
{
throw new NotImplementedException ();
}
[MonoTODO ("Need to determine how to do the conversion.")]
public object ToArray (Type type)
{
throw new NotImplementedException ();
}
#endregion // Methods
}
}