mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
* CodeIdentifiers.cs: * XmlSchemaExporter.cs: * XmlSchemaImporter.cs: * XmlSchemas.cs: * XmlSerializationWriteCallback.cs: * XmlSerializationWriter.cs: * XmlSerializer.cs: * XmlSerializerNamespaces.cs: some class status based fixed and implemented a couple of methods. svn path=/trunk/mcs/; revision=7442
111 lines
2.1 KiB
C#
111 lines
2.1 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;
|
|
Hashtable table = new Hashtable ();
|
|
Hashtable reserved = 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);
|
|
}
|
|
|
|
public void AddReserved (string identifier)
|
|
{
|
|
reserved.Add (identifier, identifier);
|
|
}
|
|
|
|
public string AddUnique (string identifier, object value)
|
|
{
|
|
string unique = MakeUnique (identifier);
|
|
Add (unique, value);
|
|
return unique;
|
|
}
|
|
|
|
public void Clear ()
|
|
{
|
|
table.Clear ();
|
|
}
|
|
|
|
public bool IsInUse (string identifier)
|
|
{
|
|
return (table.ContainsKey (identifier) || reserved.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);
|
|
}
|
|
|
|
public void RemoveReserved (string identifier)
|
|
{
|
|
reserved.Remove (identifier);
|
|
}
|
|
|
|
public object ToArray (Type type)
|
|
{
|
|
Array list = Array.CreateInstance (type, table.Count);
|
|
table.CopyTo (list, 0);
|
|
return list;
|
|
}
|
|
|
|
#endregion // Methods
|
|
}
|
|
}
|