Update of /cvsroot/csmail/csmail/src/CSMail
In directory usw-pr-cvs1:/tmp/cvs-serv642
Modified Files:
ChangeLog
Added Files:
StateBag.cs StateItem.cs
Log Message:
2002-09-13
* StateBag.cs : Added new class.
* StateItem.cs : Added new class.
--- NEW FILE ---
/**
* Namespace: CSMail
* Class: StateBag
*
* Author: Gaurav Vaish
* Maintainer: mastergaurav AT users DOT sf DOT net
*
* (C) Gaurav Vaish (2002)
*/
using System;
using System.Collections;
using System.Collections.Specialized;
namespace CSMail
{
public sealed class StateBag : IDictionary, ICollection, IEnumerable
{
private bool ignoreCase;
private bool marked;
private HybridDictionary bag;
public StateBag(bool ignoreCase)
{
Initialize(ignoreCase);
}
public StateBag()
{
Initialize(false);
}
private void Initialize(bool ignoreCase)
{
this.ignoreCase = ignoreCase;
marked = false;
bag = new HybridDictionary(ignoreCase);
}
public int Count
{
get
{
return bag.Count;
}
}
public object this[string key]
{
get
{
if(key == null || key.Length == 0)
{
throw new ArgumentException ("[this] Key_Cannot_Be_Null");
}
object val = bag [key];
if(val is StateItem)
{
return ((StateItem) val).Value;
}
return null;
}
set
{
Add(key, value);
}
}
object IDictionary.this[object key]
{
get
{
return this[(string) key];
}
set
{
Add((string)key, value);
}
}
public ICollection Keys
{
get
{
return bag.Keys;
}
}
public ICollection Values
{
get
{
return bag.Values;
}
}
public StateItem Add(string key, object value)
{
if (key == null || key.Length == 0)
throw new ArgumentException ("[Add] Key_Cannot_Be_Null");
StateItem val = (StateItem)bag[key];
if(val == null)
{
if(value != null || marked)
{
val = new StateItem(value);
bag.Add (key, val);
}
} else if(value == null && !marked)
{
bag.Remove (key);
}
else
{
val.Value = value;
}
if(val != null && marked)
{
val.IsDirty = true;
}
return val;
}
public void Clear()
{
bag.Clear();
}
public IDictionaryEnumerator GetEnumerator()
{
return bag.GetEnumerator();
}
public bool IsItemDirty(string key)
{
object o = bag[key];
if (o is StateItem)
return ((StateItem) o).IsDirty;
return false;
}
public void Remove(string key)
{
bag.Remove(key);
}
/// <summary>
/// Undocumented
/// </summary>
public void SetItemDirty(string key, bool dirty)
{
if (bag[key] is StateItem)
{
((StateItem) bag [key]).IsDirty = dirty;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
void ICollection.CopyTo(Array array, int index)
{
Values.CopyTo(array, index);
}
bool ICollection.IsSynchronized
{
get
{
return false;
}
}
object ICollection.SyncRoot
{
get
{
return this;
}
}
void IDictionary.Add(object key, object value)
{
Add((string) key, value);
}
void IDictionary.Remove(object key)
{
Remove((string) key);
}
bool IDictionary.Contains(object key)
{
return bag.Contains((string) key);
}
bool IDictionary.IsFixedSize
{
get
{
return false;
}
}
bool IDictionary.IsReadOnly
{
get
{
return false;
}
}
}
}
--- NEW FILE ---
/**
* Namespace: CSMail
* Class: StateItem
*
* Author: Gaurav Vaish
* Maintainer: mastergaurav AT users DOT sf DOT net
*
* (C) Gaurav Vaish (2002)
*/
namespace CSMail
{
public sealed class StateItem
{
private object val;
private bool isDirty;
private StateItem()
{
}
internal StateItem(object value)
{
this.val = value;
}
public bool IsDirty
{
get
{
return isDirty;
}
set
{
isDirty = value;
}
}
public object Value
{
get
{
return val;
}
set
{
this.val = value;
}
}
}
}
Index: ChangeLog
===================================================================
RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- ChangeLog 13 Sep 2002 04:55:02 -0000 1.38
+++ ChangeLog 13 Sep 2002 05:50:55 -0000 1.39
@@ -1,6 +1,11 @@
2002-09-13 Gaurav Vaish <mastergaurav AT users DOT sf DOT net>
+ * StateBag.cs : Added new class.
+ * StateItem.cs : Added new class.
+
+2002-09-13 Gaurav Vaish <mastergaurav AT users DOT sf DOT net>
+
* BodyPart.cs : Wait, why should a BodyPart have a
separate item as boundary. Just thought,
it's a parameter to ContentType.
|