fixing broken build
This commit is contained in:
@@ -1,249 +1,254 @@
|
||||
/* Copyright <20> 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spring.Collections.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// <p><c>DictionarySet</c> is an abstract class that supports the creation of new <c>Set</c>
|
||||
/// types where the underlying data store is an <c>IDictionary</c> instance.</p>
|
||||
///
|
||||
/// <p>You can use any object that implements the <c>IDictionary</c> interface to hold set data.
|
||||
/// You can define your own, or you can use one of the objects provided in the Framework.
|
||||
/// The type of <c>IDictionary</c> you choose will affect both the performance and the behavior
|
||||
/// of the <c>Set</c> using it. </p>
|
||||
///
|
||||
/// <p>To make a <c>Set</c> typed based on your own <c>IDictionary</c>, simply derive a
|
||||
/// new class with a constructor that takes no parameters. Some <c>Set</c> implmentations
|
||||
/// cannot be defined with a default constructor. If this is the case for your class,
|
||||
/// you will need to override <c>Clone()</c> as well.</p>
|
||||
///
|
||||
/// <p>It is also standard practice that at least one of your constructors takes an <c>ICollection</c> or
|
||||
/// an <c>ISet</c> as an argument.</p>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class DictionarySet<T> : Set<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the storage for elements in the <c>Set</c>, stored as the key-set
|
||||
/// of the <c>IDictionary</c> object. Set this object in the constructor
|
||||
/// if you create your own <c>Set</c> class.
|
||||
/// </summary>
|
||||
protected IDictionary<T, object> InternalDictionary = null;
|
||||
/// <summary>
|
||||
/// <p><c>DictionarySet</c> is an abstract class that supports the creation of new <c>Set</c>
|
||||
/// types where the underlying data store is an <c>IDictionary</c> instance.</p>
|
||||
///
|
||||
/// <p>You can use any object that implements the <c>IDictionary</c> interface to hold set data.
|
||||
/// You can define your own, or you can use one of the objects provided in the Framework.
|
||||
/// The type of <c>IDictionary</c> you choose will affect both the performance and the behavior
|
||||
/// of the <c>Set</c> using it. </p>
|
||||
///
|
||||
/// <p>To make a <c>Set</c> typed based on your own <c>IDictionary</c>, simply derive a
|
||||
/// new class with a constructor that takes no parameters. Some <c>Set</c> implmentations
|
||||
/// cannot be defined with a default constructor. If this is the case for your class,
|
||||
/// you will need to override <c>Clone()</c> as well.</p>
|
||||
///
|
||||
/// <p>It is also standard practice that at least one of your constructors takes an <c>ICollection</c> or
|
||||
/// an <c>ISet</c> as an argument.</p>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class DictionarySet<T> : Set<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the storage for elements in the <c>Set</c>, stored as the key-set
|
||||
/// of the <c>IDictionary</c> object. Set this object in the constructor
|
||||
/// if you create your own <c>Set</c> class.
|
||||
/// </summary>
|
||||
protected IDictionary<T, object> InternalDictionary = null;
|
||||
|
||||
private static readonly object PlaceholderObject = new object();
|
||||
private static readonly object PlaceholderObject = new object();
|
||||
|
||||
/// <summary>
|
||||
/// The placeholder object used as the value for the <c>IDictionary</c> instance.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// There is a single instance of this object globally, used for all <c>Sets</c>.
|
||||
/// </remarks>
|
||||
protected object Placeholder
|
||||
{
|
||||
get { return PlaceholderObject; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The placeholder object used as the value for the <c>IDictionary</c> instance.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// There is a single instance of this object globally, used for all <c>Sets</c>.
|
||||
/// </remarks>
|
||||
protected object Placeholder
|
||||
{
|
||||
get { return PlaceholderObject; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified element to this set if it is not already present.
|
||||
/// </summary>
|
||||
/// <param name="o">The <typeparamref name="T"/> to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
|
||||
public override bool Add(T o)
|
||||
{
|
||||
if (InternalDictionary.ContainsKey(o))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//The object we are adding is just a placeholder. The thing we are
|
||||
//really concerned with is 'o', the key.
|
||||
InternalDictionary.Add(o, PlaceholderObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds the specified element to this set if it is not already present.
|
||||
/// </summary>
|
||||
/// <param name="o">The <typeparamref name="T"/> to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
|
||||
public override bool Add(T o)
|
||||
{
|
||||
if (InternalDictionary.ContainsKey(o))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//The object we are adding is just a placeholder. The thing we are
|
||||
//really concerned with is 'o', the key.
|
||||
InternalDictionary.Add(o, PlaceholderObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds all the elements in the specified collection to the set if they are not already present.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
|
||||
public override bool AddAll(ICollection<T> c)
|
||||
{
|
||||
bool changed = false;
|
||||
foreach (T o in c)
|
||||
{
|
||||
changed |= this.Add(o);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds all the elements in the specified collection to the set if they are not already present.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
|
||||
public override bool AddAll(ICollection<T> c)
|
||||
{
|
||||
bool changed = false;
|
||||
foreach (T o in c)
|
||||
{
|
||||
changed |= this.Add(o);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all objects from the set.
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
InternalDictionary.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes all objects from the set.
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
InternalDictionary.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains the specified element.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to look for.</param>
|
||||
/// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override bool Contains(T o)
|
||||
{
|
||||
return InternalDictionary.ContainsKey(o);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains the specified element.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to look for.</param>
|
||||
/// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override bool Contains(T o)
|
||||
{
|
||||
return InternalDictionary.ContainsKey(o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects.</param>
|
||||
/// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
|
||||
public override bool ContainsAll(ICollection<T> c)
|
||||
{
|
||||
foreach (T o in c)
|
||||
{
|
||||
if (!this.Contains(o))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects.</param>
|
||||
/// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
|
||||
public override bool ContainsAll(ICollection<T> c)
|
||||
{
|
||||
foreach (T o in c)
|
||||
{
|
||||
if (!this.Contains(o))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains no elements.
|
||||
/// </summary>
|
||||
public override bool IsEmpty
|
||||
{
|
||||
get { return InternalDictionary.Count == 0; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains no elements.
|
||||
/// </summary>
|
||||
public override bool IsEmpty
|
||||
{
|
||||
get { return InternalDictionary.Count == 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified element from the set.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to be removed.</param>
|
||||
/// <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override bool Remove(T o)
|
||||
{
|
||||
bool contained = this.Contains(o);
|
||||
if (contained)
|
||||
{
|
||||
InternalDictionary.Remove(o);
|
||||
}
|
||||
return contained;
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes the specified element from the set.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to be removed.</param>
|
||||
/// <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override bool Remove(T o)
|
||||
{
|
||||
bool contained = this.Contains(o);
|
||||
if (contained)
|
||||
{
|
||||
InternalDictionary.Remove(o);
|
||||
}
|
||||
return contained;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all the specified elements from this set, if they exist in this set.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of elements to remove.</param>
|
||||
/// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
|
||||
public override bool RemoveAll(ICollection<T> c)
|
||||
{
|
||||
bool changed = false;
|
||||
foreach (T o in c)
|
||||
{
|
||||
changed |= this.Remove(o);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
/// <summary>
|
||||
/// Remove all the specified elements from this set, if they exist in this set.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of elements to remove.</param>
|
||||
/// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
|
||||
public override bool RemoveAll(ICollection<T> c)
|
||||
{
|
||||
bool changed = false;
|
||||
foreach (T o in c)
|
||||
{
|
||||
changed |= this.Remove(o);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retains only the elements in this set that are contained in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">Collection that defines the set of elements to be retained.</param>
|
||||
/// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
|
||||
public override bool RetainAll(ICollection<T> c)
|
||||
{
|
||||
//Put data from C into a set so we can use the Contains() method.
|
||||
Set<T> cSet = new HashedSet<T>(c);
|
||||
/// <summary>
|
||||
/// Retains only the elements in this set that are contained in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">Collection that defines the set of elements to be retained.</param>
|
||||
/// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
|
||||
public override bool RetainAll(ICollection<T> c)
|
||||
{
|
||||
//Put data from C into a set so we can use the Contains() method.
|
||||
Set<T> cSet = new HashedSet<T>(c);
|
||||
|
||||
//We are going to build a set of elements to remove.
|
||||
Set<T> removeSet = new HashedSet<T>();
|
||||
//We are going to build a set of elements to remove.
|
||||
Set<T> removeSet = new HashedSet<T>();
|
||||
|
||||
foreach (T o in this)
|
||||
{
|
||||
//If C does not contain O, then we need to remove O from our
|
||||
//set. We can't do this while iterating through our set, so
|
||||
//we put it into RemoveSet for later.
|
||||
if (!cSet.Contains(o))
|
||||
removeSet.Add(o);
|
||||
}
|
||||
foreach (T o in this)
|
||||
{
|
||||
//If C does not contain O, then we need to remove O from our
|
||||
//set. We can't do this while iterating through our set, so
|
||||
//we put it into RemoveSet for later.
|
||||
if (!cSet.Contains(o))
|
||||
removeSet.Add(o);
|
||||
}
|
||||
|
||||
return this.RemoveAll(removeSet);
|
||||
}
|
||||
return this.RemoveAll(removeSet);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Copies the elements in the <c>Set</c> to an array of T. The type of array needs
|
||||
/// to be compatible with the objects in the <c>Set</c>, obviously.
|
||||
/// </summary>
|
||||
/// <param name="array">An array that will be the target of the copy operation.</param>
|
||||
/// <param name="index">The zero-based index where copying will start.</param>
|
||||
public override void CopyTo(T[] array, int index)
|
||||
{
|
||||
InternalDictionary.Keys.CopyTo(array, index);
|
||||
}
|
||||
/// <summary>
|
||||
/// Copies the elements in the <c>Set</c> to an array of T. The type of array needs
|
||||
/// to be compatible with the objects in the <c>Set</c>, obviously.
|
||||
/// </summary>
|
||||
/// <param name="array">An array that will be the target of the copy operation.</param>
|
||||
/// <param name="index">The zero-based index where copying will start.</param>
|
||||
public override void CopyTo(T[] array, int index)
|
||||
{
|
||||
InternalDictionary.Keys.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of elements contained in this collection.
|
||||
/// </summary>
|
||||
public override int Count
|
||||
{
|
||||
get { return InternalDictionary.Count; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The number of elements contained in this collection.
|
||||
/// </summary>
|
||||
public override int Count
|
||||
{
|
||||
get { return InternalDictionary.Count; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// None of the objects based on <c>DictionarySet</c> are synchronized. Use the
|
||||
/// <c>SyncRoot</c> property instead.
|
||||
/// </summary>
|
||||
public override bool IsSynchronized
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
/// <summary>
|
||||
/// None of the objects based on <c>DictionarySet</c> are synchronized. Use the
|
||||
/// <c>SyncRoot</c> property instead.
|
||||
/// </summary>
|
||||
public override bool IsSynchronized
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object that can be used to synchronize the <c>Set</c> between threads.
|
||||
/// </summary>
|
||||
public override object SyncRoot
|
||||
{
|
||||
get { return ((ICollection) InternalDictionary).SyncRoot; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns an object that can be used to synchronize the <c>Set</c> between threads.
|
||||
/// </summary>
|
||||
public override object SyncRoot
|
||||
{
|
||||
get { return ((ICollection)InternalDictionary).SyncRoot; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for the elements in the <c>Set</c>.
|
||||
/// </summary>
|
||||
/// <returns>An <c>IEnumerator</c> over the elements in the <c>Set</c>.</returns>
|
||||
public override IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return InternalDictionary.Keys.GetEnumerator();
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets an enumerator for the elements in the <c>Set</c>.
|
||||
/// </summary>
|
||||
/// <returns>An <c>IEnumerator</c> over the elements in the <c>Set</c>.</returns>
|
||||
public override IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return InternalDictionary.Keys.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates wether the <c>Set</c> is read-only or not
|
||||
/// </summary>
|
||||
public override bool IsReadOnly
|
||||
{
|
||||
get { return InternalDictionary.IsReadOnly; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Indicates wether the <c>Set</c> is read-only or not
|
||||
/// </summary>
|
||||
public override bool IsReadOnly
|
||||
{
|
||||
get { return InternalDictionary.IsReadOnly; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the elements in the <c>Set</c> to an array. The type of array needs
|
||||
/// to be compatible with the objects in the <c>Set</c>, obviously. Needed for
|
||||
/// non-generic ISet methods implementation
|
||||
/// </summary>
|
||||
/// <param name="array">An array that will be the target of the copy operation.</param>
|
||||
/// <param name="index">The zero-based index where copying will start.</param>
|
||||
protected override void NonGenericCopyTo(Array array, int index)
|
||||
{
|
||||
((ICollection) InternalDictionary.Keys).CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Copies the elements in the <c>Set</c> to an array. The type of array needs
|
||||
/// to be compatible with the objects in the <c>Set</c>, obviously. Needed for
|
||||
/// non-generic ISet methods implementation
|
||||
/// </summary>
|
||||
/// <param name="array">An array that will be the target of the copy operation.</param>
|
||||
/// <param name="index">The zero-based index where copying will start.</param>
|
||||
protected override void NonGenericCopyTo(Array array, int index)
|
||||
{
|
||||
((ICollection)InternalDictionary.Keys).CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,33 +1,40 @@
|
||||
/* Copyright <20> 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spring.Collections.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements a <c>Set</c> based on a Dictionary (which is equivalent of
|
||||
/// non-genric <c>HashTable</c>) This will give the best lookup, add, and remove
|
||||
/// performance for very large data-sets, but iteration will occur in no particular order.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class HashedSet<T> : DictionarySet<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a Dictinary.
|
||||
/// </summary>
|
||||
public HashedSet()
|
||||
{
|
||||
InternalDictionary = new Dictionary<T, object>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Implements a <c>Set</c> based on a Dictionary (which is equivalent of
|
||||
/// non-genric <c>HashTable</c>) This will give the best lookup, add, and remove
|
||||
/// performance for very large data-sets, but iteration will occur in no particular order.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class HashedSet<T> : DictionarySet<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a Dictinary.
|
||||
/// </summary>
|
||||
public HashedSet()
|
||||
{
|
||||
InternalDictionary = new Dictionary<T, object>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a Dictinary and
|
||||
/// initializes it based on a collection of elements.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
public HashedSet(ICollection<T> initialValues) : this()
|
||||
{
|
||||
this.AddAll(initialValues);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a Dictinary and
|
||||
/// initializes it based on a collection of elements.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
public HashedSet(ICollection<T> initialValues)
|
||||
: this()
|
||||
{
|
||||
this.AddAll(initialValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,139 +1,145 @@
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spring.Collections.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// <p>A collection that contains no duplicate elements. This interface models the mathematical
|
||||
/// <c>Set</c> abstraction.
|
||||
/// The order of elements in a set is dependant on (a)the data-structure implementation, and
|
||||
/// (b)the implementation of the various <c>Set</c> methods, and thus is not guaranteed.</p>
|
||||
///
|
||||
/// <p>None of the <c>Set</c> implementations in this library are guranteed to be thread-safe
|
||||
/// in any way unless wrapped in a <c>SynchronizedSet</c>.</p>
|
||||
///
|
||||
/// <p>The following table summarizes the binary operators that are supported by the <c>Set</c> class.</p>
|
||||
/// <list type="table">
|
||||
/// <listheader>
|
||||
/// <term>Operation</term>
|
||||
/// <term>Description</term>
|
||||
/// <term>Method</term>
|
||||
/// </listheader>
|
||||
/// <item>
|
||||
/// <term>Union (OR)</term>
|
||||
/// <term>Element included in result if it exists in either <c>A</c> OR <c>B</c>.</term>
|
||||
/// <term><c>Union()</c></term>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>Intersection (AND)</term>
|
||||
/// <term>Element included in result if it exists in both <c>A</c> AND <c>B</c>.</term>
|
||||
/// <term><c>InterSect()</c></term>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>Exclusive Or (XOR)</term>
|
||||
/// <term>Element included in result if it exists in one, but not both, of <c>A</c> and <c>B</c>.</term>
|
||||
/// <term><c>ExclusiveOr()</c></term>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>Minus (n/a)</term>
|
||||
/// <term>Take all the elements in <c>A</c>. Now, if any of them exist in <c>B</c>, remove
|
||||
/// them. Note that unlike the other operators, <c>A - B</c> is not the same as <c>B - A</c>.</term>
|
||||
/// <term><c>Minus()</c></term>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public interface ISet<T> : ICollection<T>, IEnumerable<T>, IEnumerable, ICloneable
|
||||
{
|
||||
// Clear is declared in ICollection<T>, but not in ICollection
|
||||
// void Clear();
|
||||
/// <summary>
|
||||
/// <p>A collection that contains no duplicate elements. This interface models the mathematical
|
||||
/// <c>Set</c> abstraction.
|
||||
/// The order of elements in a set is dependant on (a)the data-structure implementation, and
|
||||
/// (b)the implementation of the various <c>Set</c> methods, and thus is not guaranteed.</p>
|
||||
///
|
||||
/// <p>None of the <c>Set</c> implementations in this library are guranteed to be thread-safe
|
||||
/// in any way unless wrapped in a <c>SynchronizedSet</c>.</p>
|
||||
///
|
||||
/// <p>The following table summarizes the binary operators that are supported by the <c>Set</c> class.</p>
|
||||
/// <list type="table">
|
||||
/// <listheader>
|
||||
/// <term>Operation</term>
|
||||
/// <term>Description</term>
|
||||
/// <term>Method</term>
|
||||
/// </listheader>
|
||||
/// <item>
|
||||
/// <term>Union (OR)</term>
|
||||
/// <term>Element included in result if it exists in either <c>A</c> OR <c>B</c>.</term>
|
||||
/// <term><c>Union()</c></term>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>Intersection (AND)</term>
|
||||
/// <term>Element included in result if it exists in both <c>A</c> AND <c>B</c>.</term>
|
||||
/// <term><c>InterSect()</c></term>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>Exclusive Or (XOR)</term>
|
||||
/// <term>Element included in result if it exists in one, but not both, of <c>A</c> and <c>B</c>.</term>
|
||||
/// <term><c>ExclusiveOr()</c></term>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>Minus (n/a)</term>
|
||||
/// <term>Take all the elements in <c>A</c>. Now, if any of them exist in <c>B</c>, remove
|
||||
/// them. Note that unlike the other operators, <c>A - B</c> is not the same as <c>B - A</c>.</term>
|
||||
/// <term><c>Minus()</c></term>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public interface ISet<T> : ICollection<T>, IEnumerable<T>, IEnumerable, ICloneable
|
||||
{
|
||||
// Clear is declared in ICollection<T>, but not in ICollection
|
||||
// void Clear();
|
||||
|
||||
// Remove is declared in ICollection<T>, but not in ICollection
|
||||
// bool Remove(T o);
|
||||
// Remove is declared in ICollection<T>, but not in ICollection
|
||||
// bool Remove(T o);
|
||||
|
||||
// Contains is declared in ICollection<T>, but not in ICollection
|
||||
// bool Contains(T o);
|
||||
// Contains is declared in ICollection<T>, but not in ICollection
|
||||
// bool Contains(T o);
|
||||
|
||||
/// <summary>
|
||||
/// Performs a "union" of the two sets, where all the elements
|
||||
/// in both sets are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>.
|
||||
/// Neither this set nor the input set are modified during the operation. The return value
|
||||
/// is a <c>Clone()</c> of this set with the extra elements added in.
|
||||
/// </summary>
|
||||
/// <param name="a">A collection of elements.</param>
|
||||
/// <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection.
|
||||
/// Neither of the input objects is modified by the union.</returns>
|
||||
ISet<T> Union(ISet<T> a);
|
||||
/// <summary>
|
||||
/// Performs a "union" of the two sets, where all the elements
|
||||
/// in both sets are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>.
|
||||
/// Neither this set nor the input set are modified during the operation. The return value
|
||||
/// is a <c>Clone()</c> of this set with the extra elements added in.
|
||||
/// </summary>
|
||||
/// <param name="a">A collection of elements.</param>
|
||||
/// <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection.
|
||||
/// Neither of the input objects is modified by the union.</returns>
|
||||
ISet<T> Union(ISet<T> a);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an "intersection" of the two sets, where only the elements
|
||||
/// that are present in both sets remain. That is, the element is included if it exists in
|
||||
/// both sets. The <c>Intersect()</c> operation does not modify the input sets. It returns
|
||||
/// a <c>Clone()</c> of this set with the appropriate elements removed.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>The intersection of this set with <c>a</c>.</returns>
|
||||
ISet<T> Intersect(ISet<T> a);
|
||||
/// <summary>
|
||||
/// Performs an "intersection" of the two sets, where only the elements
|
||||
/// that are present in both sets remain. That is, the element is included if it exists in
|
||||
/// both sets. The <c>Intersect()</c> operation does not modify the input sets. It returns
|
||||
/// a <c>Clone()</c> of this set with the appropriate elements removed.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>The intersection of this set with <c>a</c>.</returns>
|
||||
ISet<T> Intersect(ISet<T> a);
|
||||
|
||||
/// <summary>
|
||||
/// Performs a "minus" of set <c>b</c> from set <c>a</c>. This returns a set of all
|
||||
/// the elements in set <c>a</c>, removing the elements that are also in set <c>b</c>.
|
||||
/// The original sets are not modified during this operation. The result set is a <c>Clone()</c>
|
||||
/// of this <c>Set</c> containing the elements from the operation.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>A set containing the elements from this set with the elements in <c>a</c> removed.</returns>
|
||||
ISet<T> Minus(ISet<T> a);
|
||||
/// <summary>
|
||||
/// Performs a "minus" of set <c>b</c> from set <c>a</c>. This returns a set of all
|
||||
/// the elements in set <c>a</c>, removing the elements that are also in set <c>b</c>.
|
||||
/// The original sets are not modified during this operation. The result set is a <c>Clone()</c>
|
||||
/// of this <c>Set</c> containing the elements from the operation.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>A set containing the elements from this set with the elements in <c>a</c> removed.</returns>
|
||||
ISet<T> Minus(ISet<T> a);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an "exclusive-or" of the two sets, keeping only the elements that
|
||||
/// are in one of the sets, but not in both. The original sets are not modified
|
||||
/// during this operation. The result set is a <c>Clone()</c> of this set containing
|
||||
/// the elements from the exclusive-or operation.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>A set containing the result of <c>a ^ b</c>.</returns>
|
||||
ISet<T> ExclusiveOr(ISet<T> a);
|
||||
/// <summary>
|
||||
/// Performs an "exclusive-or" of the two sets, keeping only the elements that
|
||||
/// are in one of the sets, but not in both. The original sets are not modified
|
||||
/// during this operation. The result set is a <c>Clone()</c> of this set containing
|
||||
/// the elements from the exclusive-or operation.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>A set containing the result of <c>a ^ b</c>.</returns>
|
||||
ISet<T> ExclusiveOr(ISet<T> a);
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects.</param>
|
||||
/// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
|
||||
bool ContainsAll(ICollection<T> c);
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects.</param>
|
||||
/// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
|
||||
bool ContainsAll(ICollection<T> c);
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains no elements.
|
||||
/// </summary>
|
||||
bool IsEmpty { get; }
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains no elements.
|
||||
/// </summary>
|
||||
bool IsEmpty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified element to this set if it is not already present.
|
||||
/// </summary>
|
||||
/// <param name="o">The object to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
|
||||
new bool Add(T o);
|
||||
/// <summary>
|
||||
/// Adds the specified element to this set if it is not already present.
|
||||
/// </summary>
|
||||
/// <param name="o">The object to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
|
||||
new bool Add(T o);
|
||||
|
||||
/// <summary>
|
||||
/// Adds all the elements in the specified collection to the set if they are not already present.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
|
||||
bool AddAll(ICollection<T> c);
|
||||
/// <summary>
|
||||
/// Adds all the elements in the specified collection to the set if they are not already present.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
|
||||
bool AddAll(ICollection<T> c);
|
||||
|
||||
/// <summary>
|
||||
/// Remove all the specified elements from this set, if they exist in this set.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of elements to remove.</param>
|
||||
/// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
|
||||
bool RemoveAll(ICollection<T> c);
|
||||
/// <summary>
|
||||
/// Remove all the specified elements from this set, if they exist in this set.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of elements to remove.</param>
|
||||
/// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
|
||||
bool RemoveAll(ICollection<T> c);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retains only the elements in this set that are contained in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">Collection that defines the set of elements to be retained.</param>
|
||||
/// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
|
||||
bool RetainAll(ICollection<T> c);
|
||||
}
|
||||
/// <summary>
|
||||
/// Retains only the elements in this set that are contained in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">Collection that defines the set of elements to be retained.</param>
|
||||
/// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
|
||||
bool RetainAll(ICollection<T> c);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,308 +1,313 @@
|
||||
/* Copyright <20> 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spring.Collections.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// <p>Implements an immutable (read-only) <c>Set</c> wrapper.</p>
|
||||
/// <p>Although this is advertised as immutable, it really isn't. Anyone with access to the
|
||||
/// <c>basisSet</c> can still change the data-set. So <c>GetHashCode()</c> is not implemented
|
||||
/// for this <c>Set</c>, as is the case for all <c>Set</c> implementations in this library.
|
||||
/// This design decision was based on the efficiency of not having to <c>Clone()</c> the
|
||||
/// <c>basisSet</c> every time you wrap a mutable <c>Set</c>.</p>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class ImmutableSet<T> : Set<T>
|
||||
{
|
||||
private const string ERROR_MESSAGE = "Object is immutable.";
|
||||
private ISet<T> mBasisSet;
|
||||
/// <summary>
|
||||
/// <p>Implements an immutable (read-only) <c>Set</c> wrapper.</p>
|
||||
/// <p>Although this is advertised as immutable, it really isn't. Anyone with access to the
|
||||
/// <c>basisSet</c> can still change the data-set. So <c>GetHashCode()</c> is not implemented
|
||||
/// for this <c>Set</c>, as is the case for all <c>Set</c> implementations in this library.
|
||||
/// This design decision was based on the efficiency of not having to <c>Clone()</c> the
|
||||
/// <c>basisSet</c> every time you wrap a mutable <c>Set</c>.</p>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class ImmutableSet<T> : Set<T>
|
||||
{
|
||||
private const string ERROR_MESSAGE = "Object is immutable.";
|
||||
private ISet<T> mBasisSet;
|
||||
|
||||
internal ISet<T> BasisSet
|
||||
{
|
||||
get { return mBasisSet; }
|
||||
}
|
||||
internal ISet<T> BasisSet
|
||||
{
|
||||
get { return mBasisSet; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an immutable (read-only) <c>Set</c> wrapper.
|
||||
/// </summary>
|
||||
/// <param name="basisSet">The <c>Set</c> that is wrapped.</param>
|
||||
public ImmutableSet(ISet<T> basisSet)
|
||||
{
|
||||
mBasisSet = basisSet;
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs an immutable (read-only) <c>Set</c> wrapper.
|
||||
/// </summary>
|
||||
/// <param name="basisSet">The <c>Set</c> that is wrapped.</param>
|
||||
public ImmutableSet(ISet<T> basisSet)
|
||||
{
|
||||
mBasisSet = basisSet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified element to this set if it is not already present.
|
||||
/// </summary>
|
||||
/// <param name="o">The object to add to the set.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool Add(T o)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds the specified element to this set if it is not already present.
|
||||
/// </summary>
|
||||
/// <param name="o">The object to add to the set.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool Add(T o)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds all the elements in the specified collection to the set if they are not already present.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects to add to the set.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool AddAll(ICollection<T> c)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds all the elements in the specified collection to the set if they are not already present.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects to add to the set.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool AddAll(ICollection<T> c)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all objects from the set.
|
||||
/// </summary>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed void Clear()
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes all objects from the set.
|
||||
/// </summary>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed void Clear()
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains the specified element.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to look for.</param>
|
||||
/// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool Contains(T o)
|
||||
{
|
||||
return mBasisSet.Contains(o);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains the specified element.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to look for.</param>
|
||||
/// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool Contains(T o)
|
||||
{
|
||||
return mBasisSet.Contains(o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects.</param>
|
||||
/// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool ContainsAll(ICollection<T> c)
|
||||
{
|
||||
return mBasisSet.ContainsAll(c);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects.</param>
|
||||
/// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool ContainsAll(ICollection<T> c)
|
||||
{
|
||||
return mBasisSet.ContainsAll(c);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains no elements.
|
||||
/// </summary>
|
||||
public override sealed bool IsEmpty
|
||||
{
|
||||
get { return mBasisSet.IsEmpty; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains no elements.
|
||||
/// </summary>
|
||||
public override sealed bool IsEmpty
|
||||
{
|
||||
get { return mBasisSet.IsEmpty; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified element from the set.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to be removed.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool Remove(T o)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes the specified element from the set.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to be removed.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool Remove(T o)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all the specified elements from this set, if they exist in this set.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of elements to remove.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool RemoveAll(ICollection<T> c)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
/// <summary>
|
||||
/// Remove all the specified elements from this set, if they exist in this set.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of elements to remove.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool RemoveAll(ICollection<T> c)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retains only the elements in this set that are contained in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">Collection that defines the set of elements to be retained.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool RetainAll(ICollection<T> c)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
/// <summary>
|
||||
/// Retains only the elements in this set that are contained in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">Collection that defines the set of elements to be retained.</param>
|
||||
/// <returns>nothing</returns>
|
||||
/// <exception cref="NotSupportedException"> is always thrown</exception>
|
||||
public override sealed bool RetainAll(ICollection<T> c)
|
||||
{
|
||||
throw new NotSupportedException(ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the elements in the <c>Set</c> to an array of T. The type of array needs
|
||||
/// to be compatible with the objects in the <c>Set</c>, obviously.
|
||||
/// </summary>
|
||||
/// <param name="array">An array that will be the target of the copy operation.</param>
|
||||
/// <param name="index">The zero-based index where copying will start.</param>
|
||||
public override sealed void CopyTo(T[] array, int index)
|
||||
{
|
||||
mBasisSet.CopyTo(array, index);
|
||||
}
|
||||
/// <summary>
|
||||
/// Copies the elements in the <c>Set</c> to an array of T. The type of array needs
|
||||
/// to be compatible with the objects in the <c>Set</c>, obviously.
|
||||
/// </summary>
|
||||
/// <param name="array">An array that will be the target of the copy operation.</param>
|
||||
/// <param name="index">The zero-based index where copying will start.</param>
|
||||
public override sealed void CopyTo(T[] array, int index)
|
||||
{
|
||||
mBasisSet.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of elements contained in this collection.
|
||||
/// </summary>
|
||||
public override sealed int Count
|
||||
{
|
||||
get { return mBasisSet.Count; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The number of elements contained in this collection.
|
||||
/// </summary>
|
||||
public override sealed int Count
|
||||
{
|
||||
get { return mBasisSet.Count; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object that can be used to synchronize use of the <c>Set</c> across threads.
|
||||
/// </summary>
|
||||
public override sealed bool IsSynchronized
|
||||
{
|
||||
get { return ((ICollection) mBasisSet).IsSynchronized; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns an object that can be used to synchronize use of the <c>Set</c> across threads.
|
||||
/// </summary>
|
||||
public override sealed bool IsSynchronized
|
||||
{
|
||||
get { return ((ICollection)mBasisSet).IsSynchronized; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object that can be used to synchronize the <c>Set</c> between threads.
|
||||
/// </summary>
|
||||
public override sealed object SyncRoot
|
||||
{
|
||||
get { return ((ICollection) mBasisSet).SyncRoot; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns an object that can be used to synchronize the <c>Set</c> between threads.
|
||||
/// </summary>
|
||||
public override sealed object SyncRoot
|
||||
{
|
||||
get { return ((ICollection)mBasisSet).SyncRoot; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for the elements in the <c>Set</c>.
|
||||
/// </summary>
|
||||
/// <returns>An <c>IEnumerator</c> over the elements in the <c>Set</c>.</returns>
|
||||
public override sealed IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return mBasisSet.GetEnumerator();
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets an enumerator for the elements in the <c>Set</c>.
|
||||
/// </summary>
|
||||
/// <returns>An <c>IEnumerator</c> over the elements in the <c>Set</c>.</returns>
|
||||
public override sealed IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return mBasisSet.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a clone of the <c>Set</c> instance.
|
||||
/// </summary>
|
||||
/// <returns>A clone of this object.</returns>
|
||||
public override sealed object Clone()
|
||||
{
|
||||
return new ImmutableSet<T>(mBasisSet);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a clone of the <c>Set</c> instance.
|
||||
/// </summary>
|
||||
/// <returns>A clone of this object.</returns>
|
||||
public override sealed object Clone()
|
||||
{
|
||||
return new ImmutableSet<T>(mBasisSet);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a "union" of the two sets, where all the elements
|
||||
/// in both sets are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>.
|
||||
/// Neither this set nor the input set are modified during the operation. The return value
|
||||
/// is a <c>Clone()</c> of this set with the extra elements added in.
|
||||
/// </summary>
|
||||
/// <param name="a">A collection of elements.</param>
|
||||
/// <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection.
|
||||
/// Neither of the input objects is modified by the union.</returns>
|
||||
public override sealed ISet<T> Union(ISet<T> a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet<T>(m.Union(a));
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs a "union" of the two sets, where all the elements
|
||||
/// in both sets are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>.
|
||||
/// Neither this set nor the input set are modified during the operation. The return value
|
||||
/// is a <c>Clone()</c> of this set with the extra elements added in.
|
||||
/// </summary>
|
||||
/// <param name="a">A collection of elements.</param>
|
||||
/// <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection.
|
||||
/// Neither of the input objects is modified by the union.</returns>
|
||||
public override sealed ISet<T> Union(ISet<T> a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet<T>(m.Union(a));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs an "intersection" of the two sets, where only the elements
|
||||
/// that are present in both sets remain. That is, the element is included if it exists in
|
||||
/// both sets. The <c>Intersect()</c> operation does not modify the input sets. It returns
|
||||
/// a <c>Clone()</c> of this set with the appropriate elements removed.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>The intersection of this set with <c>a</c>.</returns>
|
||||
public override sealed ISet<T> Intersect(ISet<T> a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet<T>(m.Intersect(a));
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs an "intersection" of the two sets, where only the elements
|
||||
/// that are present in both sets remain. That is, the element is included if it exists in
|
||||
/// both sets. The <c>Intersect()</c> operation does not modify the input sets. It returns
|
||||
/// a <c>Clone()</c> of this set with the appropriate elements removed.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>The intersection of this set with <c>a</c>.</returns>
|
||||
public override sealed ISet<T> Intersect(ISet<T> a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet<T>(m.Intersect(a));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a "minus" of set <c>b</c> from set <c>a</c>. This returns a set of all
|
||||
/// the elements in set <c>a</c>, removing the elements that are also in set <c>b</c>.
|
||||
/// The original sets are not modified during this operation. The result set is a <c>Clone()</c>
|
||||
/// of this <c>Set</c> containing the elements from the operation.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>A set containing the elements from this set with the elements in <c>a</c> removed.</returns>
|
||||
public override sealed ISet<T> Minus(ISet<T> a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet<T>(m.Minus(a));
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs a "minus" of set <c>b</c> from set <c>a</c>. This returns a set of all
|
||||
/// the elements in set <c>a</c>, removing the elements that are also in set <c>b</c>.
|
||||
/// The original sets are not modified during this operation. The result set is a <c>Clone()</c>
|
||||
/// of this <c>Set</c> containing the elements from the operation.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>A set containing the elements from this set with the elements in <c>a</c> removed.</returns>
|
||||
public override sealed ISet<T> Minus(ISet<T> a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet<T>(m.Minus(a));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs an "exclusive-or" of the two sets, keeping only the elements that
|
||||
/// are in one of the sets, but not in both. The original sets are not modified
|
||||
/// during this operation. The result set is a <c>Clone()</c> of this set containing
|
||||
/// the elements from the exclusive-or operation.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>A set containing the result of <c>a ^ b</c>.</returns>
|
||||
public override sealed ISet<T> ExclusiveOr(ISet<T> a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet<T>(m.ExclusiveOr(a));
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs an "exclusive-or" of the two sets, keeping only the elements that
|
||||
/// are in one of the sets, but not in both. The original sets are not modified
|
||||
/// during this operation. The result set is a <c>Clone()</c> of this set containing
|
||||
/// the elements from the exclusive-or operation.
|
||||
/// </summary>
|
||||
/// <param name="a">A set of elements.</param>
|
||||
/// <returns>A set containing the result of <c>a ^ b</c>.</returns>
|
||||
public override sealed ISet<T> ExclusiveOr(ISet<T> a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet<T>(m.ExclusiveOr(a));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the given instance is read-only
|
||||
/// </summary>
|
||||
public override sealed bool IsReadOnly
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Indicates that the given instance is read-only
|
||||
/// </summary>
|
||||
public override sealed bool IsReadOnly
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs CopyTo when called trhough non-generic ISet (ICollection) interface
|
||||
/// </summary>
|
||||
/// <param name="array"></param>
|
||||
/// <param name="index"></param>
|
||||
protected override void NonGenericCopyTo(Array array, int index)
|
||||
{
|
||||
((ICollection) this.BasisSet).CopyTo(array, index);
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs CopyTo when called trhough non-generic ISet (ICollection) interface
|
||||
/// </summary>
|
||||
/// <param name="array"></param>
|
||||
/// <param name="index"></param>
|
||||
protected override void NonGenericCopyTo(Array array, int index)
|
||||
{
|
||||
((ICollection)this.BasisSet).CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs Union when called trhough non-generic ISet interface
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
protected override sealed ISet NonGenericUnion(ISet a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet(((ISet) m).Union(a));
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs Union when called trhough non-generic ISet interface
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
protected override sealed ISet NonGenericUnion(ISet a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet(((ISet)m).Union(a));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs Minus when called trhough non-generic ISet interface
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
protected override sealed ISet NonGenericMinus(ISet a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet(((ISet) m).Minus(a));
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs Minus when called trhough non-generic ISet interface
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
protected override sealed ISet NonGenericMinus(ISet a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet(((ISet)m).Minus(a));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs Intersect when called trhough non-generic ISet interface
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
protected override sealed ISet NonGenericIntersect(ISet a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet(((ISet) m).Intersect(a));
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs Intersect when called trhough non-generic ISet interface
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
protected override sealed ISet NonGenericIntersect(ISet a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet(((ISet)m).Intersect(a));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs ExclusiveOr when called trhough non-generic ISet interface
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
protected override sealed ISet NonGenericExclusiveOr(ISet a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet(((ISet) m).ExclusiveOr(a));
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs ExclusiveOr when called trhough non-generic ISet interface
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
protected override sealed ISet NonGenericExclusiveOr(ISet a)
|
||||
{
|
||||
ISet<T> m = GetUltimateBasisSet();
|
||||
return new ImmutableSet(((ISet)m).ExclusiveOr(a));
|
||||
}
|
||||
|
||||
private ISet<T> GetUltimateBasisSet()
|
||||
{
|
||||
ISet<T> m = this.mBasisSet;
|
||||
while (m is ImmutableSet<T>)
|
||||
m = ((ImmutableSet<T>) m).mBasisSet;
|
||||
return m;
|
||||
}
|
||||
}
|
||||
private ISet<T> GetUltimateBasisSet()
|
||||
{
|
||||
ISet<T> m = this.mBasisSet;
|
||||
while (m is ImmutableSet<T>)
|
||||
m = ((ImmutableSet<T>)m).mBasisSet;
|
||||
return m;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,30 +1,35 @@
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spring.Collections.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements an ordered <c>Set</c> based on a dictionary.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OrderedSet<T> : DictionarySet<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OrderedSet{T}" /> class.
|
||||
/// </summary>
|
||||
public OrderedSet()
|
||||
{
|
||||
InternalDictionary = new Dictionary<T, object>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Implements an ordered <c>Set</c> based on a dictionary.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OrderedSet<T> : DictionarySet<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OrderedSet{T}" /> class.
|
||||
/// </summary>
|
||||
public OrderedSet()
|
||||
{
|
||||
InternalDictionary = new Dictionary<T, object>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OrderedSet{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
public OrderedSet(ICollection<T> initialValues)
|
||||
: this()
|
||||
{
|
||||
AddAll(initialValues);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OrderedSet{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
public OrderedSet(ICollection<T> initialValues)
|
||||
: this()
|
||||
{
|
||||
AddAll(initialValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,69 +1,76 @@
|
||||
/* Copyright <20> 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spring.Collections.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements a <c>Set</c> based on a sorted tree. This gives good performance for operations on very
|
||||
/// large data-sets, though not as good - asymptotically - as a <c>HashedSet</c>. However, iteration
|
||||
/// occurs in order. Elements that you put into this type of collection must implement <c>IComparable</c>,
|
||||
/// and they must actually be comparable. You can't mix <c>string</c> and <c>int</c> values, for example.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SortedSet<T> : DictionarySet<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree.
|
||||
/// </summary>
|
||||
public SortedSet()
|
||||
{
|
||||
InternalDictionary = new SortedDictionary<T, object>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Implements a <c>Set</c> based on a sorted tree. This gives good performance for operations on very
|
||||
/// large data-sets, though not as good - asymptotically - as a <c>HashedSet</c>. However, iteration
|
||||
/// occurs in order. Elements that you put into this type of collection must implement <c>IComparable</c>,
|
||||
/// and they must actually be comparable. You can't mix <c>string</c> and <c>int</c> values, for example.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SortedSet<T> : DictionarySet<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree.
|
||||
/// </summary>
|
||||
public SortedSet()
|
||||
{
|
||||
InternalDictionary = new SortedDictionary<T, object>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree.
|
||||
/// </summary>
|
||||
/// <param name="comparer">The <see cref="IComparer<T>"/> to use for sorting.</param>
|
||||
public SortedSet(IComparer<T> comparer)
|
||||
{
|
||||
InternalDictionary = new SortedList<T, object>(comparer);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree.
|
||||
/// </summary>
|
||||
/// <param name="comparer">The <see cref="IComparer<T>"/> to use for sorting.</param>
|
||||
public SortedSet(IComparer<T> comparer)
|
||||
{
|
||||
InternalDictionary = new SortedList<T, object>(comparer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree and
|
||||
/// initializes it based on a collection of elements.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
public SortedSet(ICollection<T> initialValues)
|
||||
: this()
|
||||
{
|
||||
this.AddAll(initialValues);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree and
|
||||
/// initializes it based on a collection of elements.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
public SortedSet(ICollection<T> initialValues)
|
||||
: this()
|
||||
{
|
||||
this.AddAll(initialValues);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree and
|
||||
/// initializes it based on a collection of elements.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
public SortedSet(ICollection initialValues)
|
||||
: this()
|
||||
{
|
||||
((ISet) this).AddAll(initialValues);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree and
|
||||
/// initializes it based on a collection of elements.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
public SortedSet(ICollection initialValues)
|
||||
: this()
|
||||
{
|
||||
((ISet)this).AddAll(initialValues);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree and
|
||||
/// initializes it based on a collection of elements.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
/// <param name="comparer">The <see cref="IComparer<T>"/> to use for sorting.</param>
|
||||
public SortedSet(ICollection<T> initialValues, IComparer<T> comparer)
|
||||
: this(comparer)
|
||||
{
|
||||
this.AddAll(initialValues);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new set instance based on a sorted tree and
|
||||
/// initializes it based on a collection of elements.
|
||||
/// </summary>
|
||||
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
|
||||
/// <param name="comparer">The <see cref="IComparer<T>"/> to use for sorting.</param>
|
||||
public SortedSet(ICollection<T> initialValues, IComparer<T> comparer)
|
||||
: this(comparer)
|
||||
{
|
||||
this.AddAll(initialValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,262 +1,269 @@
|
||||
/* Copyright <20> 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spring.Collections.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// <p>Implements a thread-safe <c>Set</c> wrapper. The implementation is extremely conservative,
|
||||
/// serializing critical sections to prevent possible deadlocks, and locking on everything.
|
||||
/// The one exception is for enumeration, which is inherently not thread-safe. For this, you
|
||||
/// have to <c>lock</c> the <c>SyncRoot</c> object for the duration of the enumeration.</p>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class SynchronizedSet<T> : Set<T>
|
||||
{
|
||||
private ISet<T> mBasisSet;
|
||||
private object mSyncRoot;
|
||||
/// <summary>
|
||||
/// <p>Implements a thread-safe <c>Set</c> wrapper. The implementation is extremely conservative,
|
||||
/// serializing critical sections to prevent possible deadlocks, and locking on everything.
|
||||
/// The one exception is for enumeration, which is inherently not thread-safe. For this, you
|
||||
/// have to <c>lock</c> the <c>SyncRoot</c> object for the duration of the enumeration.</p>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class SynchronizedSet<T> : Set<T>
|
||||
{
|
||||
private ISet<T> mBasisSet;
|
||||
private object mSyncRoot;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a thread-safe <c>Set</c> wrapper.
|
||||
/// </summary>
|
||||
/// <param name="basisSet">The <c>Set</c> object that this object will wrap.</param>
|
||||
public SynchronizedSet(ISet<T> basisSet)
|
||||
{
|
||||
mBasisSet = basisSet;
|
||||
mSyncRoot = ((ICollection) basisSet).SyncRoot;
|
||||
if (mSyncRoot == null)
|
||||
throw new NullReferenceException("The Set you specified returned a null SyncRoot.");
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs a thread-safe <c>Set</c> wrapper.
|
||||
/// </summary>
|
||||
/// <param name="basisSet">The <c>Set</c> object that this object will wrap.</param>
|
||||
public SynchronizedSet(ISet<T> basisSet)
|
||||
{
|
||||
mBasisSet = basisSet;
|
||||
mSyncRoot = ((ICollection)basisSet).SyncRoot;
|
||||
if (mSyncRoot == null)
|
||||
throw new NullReferenceException("The Set you specified returned a null SyncRoot.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified element to this set if it is not already present.
|
||||
/// </summary>
|
||||
/// <param name="o">The object to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
|
||||
public override sealed bool Add(T o)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.Add(o);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds the specified element to this set if it is not already present.
|
||||
/// </summary>
|
||||
/// <param name="o">The object to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
|
||||
public override sealed bool Add(T o)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.Add(o);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds all the elements in the specified collection to the set if they are not already present.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
|
||||
public override sealed bool AddAll(ICollection<T> c)
|
||||
{
|
||||
Set<T> temp;
|
||||
lock (((ICollection) c).SyncRoot)
|
||||
{
|
||||
temp = new HashedSet<T>(c);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds all the elements in the specified collection to the set if they are not already present.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects to add to the set.</param>
|
||||
/// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
|
||||
public override sealed bool AddAll(ICollection<T> c)
|
||||
{
|
||||
Set<T> temp;
|
||||
lock (((ICollection)c).SyncRoot)
|
||||
{
|
||||
temp = new HashedSet<T>(c);
|
||||
}
|
||||
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.AddAll(temp);
|
||||
}
|
||||
}
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.AddAll(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all objects from the set.
|
||||
/// </summary>
|
||||
public override sealed void Clear()
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
mBasisSet.Clear();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes all objects from the set.
|
||||
/// </summary>
|
||||
public override sealed void Clear()
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
mBasisSet.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains the specified element.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to look for.</param>
|
||||
/// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool Contains(T o)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.Contains(o);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains the specified element.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to look for.</param>
|
||||
/// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool Contains(T o)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.Contains(o);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects.</param>
|
||||
/// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool ContainsAll(ICollection<T> c)
|
||||
{
|
||||
Set<T> temp;
|
||||
lock (((ICollection) c).SyncRoot)
|
||||
{
|
||||
temp = new HashedSet<T>(c);
|
||||
}
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.ContainsAll(temp);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of objects.</param>
|
||||
/// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool ContainsAll(ICollection<T> c)
|
||||
{
|
||||
Set<T> temp;
|
||||
lock (((ICollection)c).SyncRoot)
|
||||
{
|
||||
temp = new HashedSet<T>(c);
|
||||
}
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.ContainsAll(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains no elements.
|
||||
/// </summary>
|
||||
public override sealed bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.IsEmpty;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" /> if this set contains no elements.
|
||||
/// </summary>
|
||||
public override sealed bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.IsEmpty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified element from the set.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to be removed.</param>
|
||||
/// <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool Remove(T o)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.Remove(o);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes the specified element from the set.
|
||||
/// </summary>
|
||||
/// <param name="o">The element to be removed.</param>
|
||||
/// <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns>
|
||||
public override sealed bool Remove(T o)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.Remove(o);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all the specified elements from this set, if they exist in this set.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of elements to remove.</param>
|
||||
/// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
|
||||
public override sealed bool RemoveAll(ICollection<T> c)
|
||||
{
|
||||
Set<T> temp;
|
||||
lock (((ICollection) c).SyncRoot)
|
||||
{
|
||||
temp = new HashedSet<T>(c);
|
||||
}
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.RemoveAll(temp);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Remove all the specified elements from this set, if they exist in this set.
|
||||
/// </summary>
|
||||
/// <param name="c">A collection of elements to remove.</param>
|
||||
/// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
|
||||
public override sealed bool RemoveAll(ICollection<T> c)
|
||||
{
|
||||
Set<T> temp;
|
||||
lock (((ICollection)c).SyncRoot)
|
||||
{
|
||||
temp = new HashedSet<T>(c);
|
||||
}
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.RemoveAll(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retains only the elements in this set that are contained in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">Collection that defines the set of elements to be retained.</param>
|
||||
/// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
|
||||
public override sealed bool RetainAll(ICollection<T> c)
|
||||
{
|
||||
Set<T> temp;
|
||||
lock (((ICollection) c).SyncRoot)
|
||||
{
|
||||
temp = new HashedSet<T>(c);
|
||||
}
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.RetainAll(temp);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Retains only the elements in this set that are contained in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="c">Collection that defines the set of elements to be retained.</param>
|
||||
/// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
|
||||
public override sealed bool RetainAll(ICollection<T> c)
|
||||
{
|
||||
Set<T> temp;
|
||||
lock (((ICollection)c).SyncRoot)
|
||||
{
|
||||
temp = new HashedSet<T>(c);
|
||||
}
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.RetainAll(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the elements in the <c>Set</c> to an array. The type of array needs
|
||||
/// to be compatible with the objects in the <c>Set</c>, obviously.
|
||||
/// </summary>
|
||||
/// <param name="array">An array that will be the target of the copy operation.</param>
|
||||
/// <param name="index">The zero-based index where copying will start.</param>
|
||||
public override sealed void CopyTo(T[] array, int index)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
mBasisSet.CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Copies the elements in the <c>Set</c> to an array. The type of array needs
|
||||
/// to be compatible with the objects in the <c>Set</c>, obviously.
|
||||
/// </summary>
|
||||
/// <param name="array">An array that will be the target of the copy operation.</param>
|
||||
/// <param name="index">The zero-based index where copying will start.</param>
|
||||
public override sealed void CopyTo(T[] array, int index)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
mBasisSet.CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of elements contained in this collection.
|
||||
/// </summary>
|
||||
public override sealed int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The number of elements contained in this collection.
|
||||
/// </summary>
|
||||
public override sealed int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" />, indicating that this object is thread-safe. The exception to this
|
||||
/// is enumeration, which is inherently not thread-safe. Use the <c>SyncRoot</c> object to
|
||||
/// lock this object for the entire duration of the enumeration.
|
||||
/// </summary>
|
||||
public override sealed bool IsSynchronized
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns <see langword="true" />, indicating that this object is thread-safe. The exception to this
|
||||
/// is enumeration, which is inherently not thread-safe. Use the <c>SyncRoot</c> object to
|
||||
/// lock this object for the entire duration of the enumeration.
|
||||
/// </summary>
|
||||
public override sealed bool IsSynchronized
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object that can be used to synchronize the <c>Set</c> between threads.
|
||||
/// </summary>
|
||||
public override sealed object SyncRoot
|
||||
{
|
||||
get { return mSyncRoot; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns an object that can be used to synchronize the <c>Set</c> between threads.
|
||||
/// </summary>
|
||||
public override sealed object SyncRoot
|
||||
{
|
||||
get { return mSyncRoot; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration is, by definition, not thread-safe. Use a <c>lock</c> on the <c>SyncRoot</c>
|
||||
/// to synchronize the entire enumeration process.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override sealed IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return mBasisSet.GetEnumerator();
|
||||
}
|
||||
/// <summary>
|
||||
/// Enumeration is, by definition, not thread-safe. Use a <c>lock</c> on the <c>SyncRoot</c>
|
||||
/// to synchronize the entire enumeration process.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override sealed IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return mBasisSet.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a clone of the <c>Set</c> instance.
|
||||
/// </summary>
|
||||
/// <returns>A clone of this object.</returns>
|
||||
public override object Clone()
|
||||
{
|
||||
return new SynchronizedSet((ISet) mBasisSet.Clone());
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a clone of the <c>Set</c> instance.
|
||||
/// </summary>
|
||||
/// <returns>A clone of this object.</returns>
|
||||
public override object Clone()
|
||||
{
|
||||
return new SynchronizedSet((ISet)mBasisSet.Clone());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether given instace is read-only or not
|
||||
/// </summary>
|
||||
public override bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.IsReadOnly;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Indicates whether given instace is read-only or not
|
||||
/// </summary>
|
||||
public override bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
return mBasisSet.IsReadOnly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs CopyTo when called trhough non-generic ISet (ICollection) interface
|
||||
/// </summary>
|
||||
/// <param name="array"></param>
|
||||
/// <param name="index"></param>
|
||||
protected override void NonGenericCopyTo(Array array, int index)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
((ICollection) this.mBasisSet).CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs CopyTo when called trhough non-generic ISet (ICollection) interface
|
||||
/// </summary>
|
||||
/// <param name="array"></param>
|
||||
/// <param name="index"></param>
|
||||
protected override void NonGenericCopyTo(Array array, int index)
|
||||
{
|
||||
lock (mSyncRoot)
|
||||
{
|
||||
((ICollection)this.mBasisSet).CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Common.Logging;
|
||||
@@ -29,8 +32,11 @@ namespace Spring.Objects.Factory.Parsing
|
||||
public void Warning(Problem problem)
|
||||
{
|
||||
_logger.Warn(problem.Message);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Spring.Objects.Factory.Parsing
|
||||
@@ -11,3 +12,5 @@ namespace Spring.Objects.Factory.Parsing
|
||||
void Error(Problem problem);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Spring.Core.IO;
|
||||
@@ -31,7 +34,7 @@ namespace Spring.Objects.Factory.Parsing
|
||||
public Location(IResource resource)
|
||||
: this(resource, null)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public IResource Resource
|
||||
{
|
||||
@@ -51,3 +54,5 @@ namespace Spring.Objects.Factory.Parsing
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.Serialization;
|
||||
using Spring.Core.IO;
|
||||
|
||||
namespace Spring.Objects.Factory.Parsing
|
||||
{
|
||||
@@ -17,7 +21,132 @@ namespace Spring.Objects.Factory.Parsing
|
||||
public ObjectDefinitionParsingException(Problem problem)
|
||||
: base(problem.Location.Resource, problem.ResourceDescription, problem.Message)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ObjectDefinitionParsingException class.
|
||||
/// </summary>
|
||||
public ObjectDefinitionParsingException()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ObjectDefinitionParsingException class.
|
||||
/// </summary>
|
||||
/// <param name="message">
|
||||
/// A message about the exception.
|
||||
/// </param>
|
||||
public ObjectDefinitionParsingException(string message)
|
||||
: base(message)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ObjectDefinitionParsingException class.
|
||||
/// </summary>
|
||||
/// <param name="resourceDescription">
|
||||
/// The description of the resource that the object definition came from
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// The name of the object that triggered the exception.
|
||||
/// </param>
|
||||
/// <param name="message">
|
||||
/// A message about the exception.
|
||||
/// </param>
|
||||
public ObjectDefinitionParsingException(string resourceDescription, string name, string message)
|
||||
: base(resourceDescription, name, message)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ObjectDefinitionParsingException"></see> class.
|
||||
/// </summary>
|
||||
/// <param name="resourceDescription">
|
||||
/// The description of the resource that the object definition came from
|
||||
/// </param>
|
||||
/// <param name="msg">The detail message (used as exception message as-is)</param>
|
||||
/// <param name="cause">The root cause. (may be <code>null</code></param>
|
||||
public ObjectDefinitionParsingException(string resourceDescription, string msg, Exception cause)
|
||||
: base(resourceDescription, msg, cause)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ObjectDefinitionParsingException class.
|
||||
/// </summary>
|
||||
/// <param name="resourceLocation">
|
||||
/// The resource location (e.g. an XML object definition file) associated
|
||||
/// with the offending object definition.
|
||||
/// </param>
|
||||
/// <param name="message">
|
||||
/// A message about the exception.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// The name of the object that triggered the exception.
|
||||
/// </param>
|
||||
public ObjectDefinitionParsingException(IResource resourceLocation, string name, string message)
|
||||
: base(resourceLocation, name, message)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ObjectDefinitionParsingException class.
|
||||
/// </summary>
|
||||
/// <param name="resourceLocation">
|
||||
/// The resource location (e.g. an XML object definition file) associated
|
||||
/// with the offending object definition.
|
||||
/// </param>
|
||||
/// <param name="message">
|
||||
/// A message about the exception.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// The name of the object that triggered the exception.
|
||||
/// </param>
|
||||
/// <param name="rootCause">
|
||||
/// The root exception that is being wrapped.
|
||||
/// </param>
|
||||
public ObjectDefinitionParsingException(IResource resourceLocation, string name, string message, Exception rootCause)
|
||||
: base(resourceLocation, name, message, rootCause)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ObjectDefinitionParsingException class.
|
||||
/// </summary>
|
||||
/// <param name="resourceDescription">
|
||||
/// The description of the resource that the object definition came from
|
||||
/// </param>
|
||||
/// <param name="message">
|
||||
/// A message about the exception.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// The name of the object that triggered the exception.
|
||||
/// </param>
|
||||
/// <param name="rootCause">
|
||||
/// The root exception that is being wrapped.
|
||||
/// </param>
|
||||
public ObjectDefinitionParsingException(string resourceDescription, string name, string message, Exception rootCause)
|
||||
: base(resourceDescription, name, message, rootCause)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ObjectDefinitionParsingException class.
|
||||
/// </summary>
|
||||
/// <param name="message">
|
||||
/// A message about the exception.
|
||||
/// </param>
|
||||
/// <param name="rootCause">
|
||||
/// The root exception that is being wrapped.
|
||||
/// </param>
|
||||
public ObjectDefinitionParsingException(string message, Exception rootCause)
|
||||
: base(message, rootCause)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
#if NET_2_0
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Spring.Core.IO;
|
||||
@@ -14,11 +17,12 @@ namespace Spring.Objects.Factory.Parsing
|
||||
|
||||
private Exception _rootCause;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Problem class.
|
||||
/// Initializes a new instance of the <see cref="Problem"/> class.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="location">The location.</param>
|
||||
public Problem(string message, Location location)
|
||||
: this(message, location, null)
|
||||
{
|
||||
@@ -59,7 +63,7 @@ namespace Spring.Objects.Factory.Parsing
|
||||
|
||||
public string ResourceDescription
|
||||
{
|
||||
get { return _location.Resource!=null ? _location.Resource.Description : string.Empty; }
|
||||
get { return _location.Resource != null ? _location.Resource.Description : string.Empty; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -76,3 +80,5 @@ namespace Spring.Objects.Factory.Parsing
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Spring.Objects.Factory.Config;
|
||||
|
||||
namespace Spring.Objects.Factory.Support
|
||||
@@ -9,4 +7,4 @@ namespace Spring.Objects.Factory.Support
|
||||
{
|
||||
void PostProcessObjectDefinitionRegistry(IObjectDefinitionRegistry registry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace Spring.Util
|
||||
/// Avoid BeforeFieldInit problem
|
||||
/// </summary>
|
||||
static ReflectionUtils()
|
||||
{}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Checks, if the specified type is a nullable
|
||||
@@ -1074,7 +1074,7 @@ namespace Spring.Util
|
||||
|
||||
private static object ConvertConstructorArgsToObjectArrayIfNecessary(object value)
|
||||
{
|
||||
if (value == null)
|
||||
if (value == null)
|
||||
return value;
|
||||
|
||||
IList<CustomAttributeTypedArgument> constructorArguments = value as IList<CustomAttributeTypedArgument>;
|
||||
@@ -1083,7 +1083,7 @@ namespace Spring.Util
|
||||
return value;
|
||||
|
||||
object[] arguments = new object[constructorArguments.Count];
|
||||
|
||||
|
||||
for (int i = 0; i < constructorArguments.Count; i++)
|
||||
{
|
||||
arguments[i] = constructorArguments[i].Value;
|
||||
@@ -1091,7 +1091,7 @@ namespace Spring.Util
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
@@ -1429,7 +1429,7 @@ namespace Spring.Util
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException("obj", "obj is null.");
|
||||
if (String.IsNullOrEmpty(fieldName))
|
||||
if (StringUtils.IsNullOrEmpty(fieldName))
|
||||
throw new ArgumentException("fieldName is null or empty.", "fieldName");
|
||||
|
||||
FieldInfo f = obj.GetType().GetField(fieldName, BindingFlags.SetField | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
@@ -1453,7 +1453,7 @@ namespace Spring.Util
|
||||
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException("obj", "obj is null.");
|
||||
if (String.IsNullOrEmpty(fieldName))
|
||||
if (StringUtils.IsNullOrEmpty(fieldName))
|
||||
throw new ArgumentException("fieldName is null or empty.", "fieldName");
|
||||
if (fieldValue == null)
|
||||
throw new ArgumentNullException("fieldValue", "fieldValue is null.");
|
||||
|
||||
Reference in New Issue
Block a user