//*********************************************************************
// //
// SQL Power Injector 1.2 Copyright (c) 2006-2007 Francois Larouche //
// //
// Author : francois.larouche@sqlpowerinjector.com //
// Web Site: www.sqlpowerinjector.com //
// //
//*******************************************************************//
using System;
using System.Collections;
using System.Xml.Serialization;
namespace SQLPowerInjector{
/// <summary>
/// Summary description for CharacterSet.
/// </summary>
[Serializable]
public class CharacterSet
{
#region Members
#region Private
private string _characterSetID;
private string _characterSetName;
private bool _readOnly;
private ArrayList _charArray;
#endregion
#endregion
#region Constructor
public CharacterSet()
{
_characterSetID = System.Guid.NewGuid().ToString();
_characterSetName = _characterSetID;
_readOnly = true;
_charArray = new ArrayList();
}
public CharacterSet(string characterSetName)
{
_characterSetID = System.Guid.NewGuid().ToString();
_characterSetName = characterSetName;
_readOnly = true;
_charArray = new ArrayList();
}
public CharacterSet(string characterSetName, string characterSetGuid, bool readOnly)
{
_characterSetID = characterSetGuid;
_characterSetName = characterSetName;
_readOnly = readOnly;
_charArray = new ArrayList();
}
#endregion
#region Public Attributes
[XmlAttributeAttribute(DataType="Name")]
public string CharacterSetName
{
get { return _characterSetName; }
set { _characterSetName = value; }
}
[XmlAttributeAttribute(DataType="string")]
public string CharacterSetID
{
get { return _characterSetID; }
set { _characterSetID = value; }
}
[XmlAttributeAttribute(DataType="boolean")]
public bool ReadOnly
{
get { return _readOnly; }
set { _readOnly = value; }
}
[XmlElement("Character")]
public ArrayList CharArray
{
get
{
_charArray.Sort();
return _charArray;
}
set { _charArray = value; }
}
#endregion
public static int[] ToIntArray(CharacterSet characterSetToConvert)
{
int[] characterSetIntArray = new int[characterSetToConvert.CharArray.Count];
for(int currentCharIndex=0; currentCharIndex<characterSetIntArray.Length;currentCharIndex++)
characterSetIntArray[currentCharIndex] = (int)characterSetToConvert.CharArray[currentCharIndex];
return characterSetIntArray;
}
public void AddCharacter(int characterAsciiCode)
{
if(characterAsciiCode >= 0 && characterAsciiCode < 256)
{
if(!_charArray.Contains(characterAsciiCode))
{
_charArray.Add(characterAsciiCode);
_charArray.Sort();
}
}
}
public void RemoveCharacter(int characterAsciiCode)
{
if(characterAsciiCode >= 0 && characterAsciiCode < 256)
{
if(_charArray.Contains(characterAsciiCode))
{
_charArray.Remove(characterAsciiCode);
_charArray.Sort();
}
}
}
}
}
|