- machatproject.zip
- MaChatproject
- Chat.sln
- Chat.suo
- ChatLibrary
- MaChat
- MagicLibrary
- AssemblyInfo.cs
- bin
- Debug
- Release
- Collections
- Common
- Controls
- Docking
- MagicLibrary.csproj
- MagicLibrary.csproj.user
- Menus
- obj
- Debug
- MagicLibrary.projdata
- temp
- TempPE
- Release
- MagicLibrary.projdata
- temp
- TempPE
- Resources
- ImagesCaptionIDE.bmp
- ImagesCaptionPlain.bmp
- ImagesMenuControl.bmp
- ImagesPopupMenu.bmp
- ImagesTabControl.bmp
- LibraryIcon.ico
- Win32
- Resources
- bin
- MaChat.ChatProxy.pl.resX
- MaChat.ChatProxy.resX
- MaChat.MainForm.pl.resX
- MaChat.MainForm.resX
- MaChat.OptionsDlg.pl.resX
- MaChat.OptionsDlg.resX
- obj
- Resources.vcproj
- Setup
- Setup.vdproj
- Setup
- ssetup.zip
- sSetup.msi
- lsetup.zip
- lSetup.msi
|
// *****************************************************************************
//
// (c) Crownwood Consulting Limited 2002
// All rights reserved. The software and associated documentation
// supplied hereunder are the proprietary information of Crownwood Consulting
// Limited, Haxey, North Lincolnshire, England and are supplied subject to
// licence terms.
//
// Magic Version 1.6 www.dotnetmagic.com
// *****************************************************************************
using System;
using System.Xml;
using Crownwood.Magic.Collections;
namespace Crownwood.Magic.Collections
{
public class StringCollection : CollectionWithEvents
{
public String Add(String value)
{
// Use base class to process actual collection operation
base.List.Add(value as object);
return value;
}
public void AddRange(String[] values)
{
// Use existing method to add each array entry
foreach(String item in values)
Add(item);
}
public void Remove(String value)
{
// Use base class to process actual collection operation
base.List.Remove(value as object);
}
public void Insert(int index, String value)
{
// Use base class to process actual collection operation
base.List.Insert(index, value as object);
}
public bool Contains(String value)
{
// Value comparison
foreach(String s in base.List)
if (value.Equals(s))
return true;
return false;
}
public bool Contains(StringCollection values)
{
foreach(String c in values)
{
// Use base class to process actual collection operation
if (Contains(c))
return true;
}
return false;
}
public String this[int index]
{
// Use base class to process actual collection operation
get { return (base.List[index] as String); }
}
public int IndexOf(String value)
{
// Find the 0 based index of the requested entry
return base.List.IndexOf(value);
}
public void SaveToXml(string name, XmlTextWriter xmlOut)
{
xmlOut.WriteStartElement(name);
xmlOut.WriteAttributeString("Count", this.Count.ToString());
foreach(String s in base.List)
{
xmlOut.WriteStartElement("Item");
xmlOut.WriteAttributeString("Name", s);
xmlOut.WriteEndElement();
}
xmlOut.WriteEndElement();
}
public void LoadFromXml(string name, XmlTextReader xmlIn)
{
// Move to next xml node
if (!xmlIn.Read())
throw new ArgumentException("Could not read in next expected node");
// Check it has the expected name
if (xmlIn.Name != name)
throw new ArgumentException("Incorrect node name found");
this.Clear();
// Grab raw position information
string attrCount = xmlIn.GetAttribute(0);
// Convert from string to proper types
int count = int.Parse(attrCount);
for(int index=0; index<count; index++)
{
// Move to next xml node
if (!xmlIn.Read())
throw new ArgumentException("Could not read in next expected node");
// Check it has the expected name
if (xmlIn.Name != "Item")
throw new ArgumentException("Incorrect node name found");
this.Add(xmlIn.GetAttribute(0));
}
if (count > 0)
{
// Move over the end element of the collection
if (!xmlIn.Read())
throw new ArgumentException("Could not read in next expected node");
// Check it has the expected name
if (xmlIn.Name != name)
throw new ArgumentException("Incorrect node name found");
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Micheal is an independent consultant -
www.macmichal.pl.
He's main areas of interest are: DDD\CqRS, TDD, SaaS, Design Patterns, Architecture. He specializes in .Net/C# for the early beginning of it and T-SQL. He's a writer, blogger (
blog.macmichal.pl) and speaker.
In his spare time, he's climbing the mountains all over the Europe.