Skip to content

Commit 7defe60

Browse files
authored
4015 change context to interfaces (#4025)
* #4015 Change to use interfaces for ClientContext and LocalContext * #4015 Changes to use single IContextDictionary interface and concrete ContextDictionary under the covers. * #4015 Remove unwanted changes * #4015 Remove last unwanted change. * #4015 Changes to implement ConcurrentDictionary instead of HybridDictionary. * #4015 update to documentation * #4015 Changes to documentation
1 parent 9a5c5e6 commit 7defe60

File tree

2 files changed

+17
-170
lines changed

2 files changed

+17
-170
lines changed

Source/Csla/Core/ContextDictionary.cs

+8-57
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ namespace Csla.Core
1919
[Serializable]
2020
public class ContextDictionary : ConcurrentDictionary<object, object>, IContextDictionary
2121
{
22-
/// <summary>
23-
/// Get a value from the dictionary, or return null
24-
/// if the key is not found in the dictionary.
25-
/// </summary>
26-
/// <param name="key">Key of value to get from dictionary.</param>
22+
/// <inheritdoc cref="Csla.Core.IContextDictionary.GetValueOrNull(string)"/>
2723
public object GetValueOrNull(string key)
2824
{
2925
if (ContainsKey(key))
@@ -77,47 +73,25 @@ void IMobileObject.SetChildren(SerializationInfo info, MobileFormatter formatter
7773

7874
#region IDictionary Members
7975

80-
/// <summary>
81-
/// Gets a value indicating whether the System.Collections.IDictionary object is
82-
/// read-only.
83-
/// </summary>
84-
///<returns>true if the System.Collections.IDictionary object is read-only; otherwise, false.</returns>
76+
/// <inheritdoc cref="System.Collections.IDictionary.IsReadOnly"/>
8577
public bool IsReadOnly
8678
{
8779
get => ((IDictionary)this).IsReadOnly;
8880
}
8981

90-
/// <summary>
91-
/// Gets a value indicating whether the System.Collections.IDictionary object has
92-
/// a fixed size.
93-
/// </summary>
94-
/// <returns>true if the System.Collections.IDictionary object has a fixed size; otherwise, false.</returns>
82+
/// <inheritdoc cref="System.Collections.IDictionary.IsFixedSize"/>
9583
public bool IsFixedSize
9684
{
9785
get => ((IDictionary)this).IsFixedSize;
9886
}
9987

100-
/// <summary>
101-
/// Adds an element with the provided key and value to the System.Collections.IDictionary
102-
/// object.
103-
/// </summary>
104-
/// <param name="key">The System.Object to use as the key of the element to add.</param>
105-
/// <param name="value">The System.Object to use as the value of the element to add.</param>
106-
/// <exception cref="System.ArgumentNullException">key is null.</exception>
107-
/// <exception cref="System.ArgumentException">An element with the same key already exists in the System.Collections.IDictionary object.</exception>
108-
/// <exception cref="System.NotSupportedException">The System.Collections.IDictionary is read-only. -or- The System.Collections.IDictionary has a fixed size.</exception>
88+
/// <inheritdoc cref="System.Collections.IDictionary.Add(object, object?)"/>
10989
public void Add(object key, object value)
11090
{
11191
((IDictionary)this).Add(key, value);
11292
}
11393

114-
/// <summary>
115-
/// Removes the element with the specified key from the System.Collections.IDictionary
116-
/// object.
117-
/// </summary>
118-
/// <param name="key">The key of the element to remove.</param>
119-
/// <exception cref="System.ArgumentNullException">key is null.</exception>
120-
/// <exception cref="System.NotSupportedException">The System.Collections.IDictionary object is read-only. -or- The System.Collections.IDictionary has a fixed size.</exception>
94+
/// <inheritdoc cref="System.Collections.IDictionary.Remove(object)"/>
12195
public void Remove(object key)
12296
{
12397
((IDictionary)this).Remove(key);
@@ -127,42 +101,19 @@ public void Remove(object key)
127101

128102
#region ICollection Members
129103

130-
/// <summary>
131-
/// Gets an object that can be used to synchronize access to the System.Collections.ICollection.
132-
/// </summary>
133-
/// <returns>An object that can be used to synchronize access to the System.Collections.ICollection.</returns>
104+
/// <inheritdoc cref="System.Collections.ICollection.SyncRoot"/>
134105
public object SyncRoot
135106
{
136107
get => ((IDictionary)this).SyncRoot;
137108
}
138109

139-
/// <summary>
140-
/// Gets a value indicating whether access to the System.Collections.ICollection
141-
/// is synchronized (thread safe).
142-
/// </summary>
143-
///<returns>true if access to the System.Collections.ICollection is synchronized (thread safe); otherwise, false.</returns>
110+
/// <inheritdoc cref="System.Collections.ICollection.IsSynchronized"/>
144111
public bool IsSynchronized
145112
{
146113
get => ((ICollection)this).IsSynchronized;
147114
}
148115

149-
/// <summary>
150-
/// Copies the elements of the System.Collections.ICollection to an System.Array,
151-
/// starting at a particular System.Array index.
152-
/// </summary>
153-
/// <param name="array">
154-
/// The one-dimensional System.Array that is the destination of the elements copied
155-
/// from System.Collections.ICollection. The System.Array must have zero-based indexing.
156-
/// </param>
157-
/// <param name="index">The zero-based index in array at which copying begins.</param>
158-
/// <exception cref="System.ArgumentNullException">array is null.</exception>
159-
/// <exception cref="System.ArgumentOutOfRangeException">index is less than zero.</exception>
160-
/// <exception cref="System.ArgumentException">
161-
/// array is multidimensional. -or- The number of elements in the source System.Collections.ICollection
162-
/// is greater than the available space from index to the end of the destination
163-
/// array. -or- The type of the source System.Collections.ICollection cannot be cast
164-
/// automatically to the type of the destination array.
165-
/// </exception>
116+
/// <inheritdoc cref="System.Collections.ICollection.CopyTo(Array, int)"/>
166117
public void CopyTo(Array array, int index)
167118
{
168119
((ICollection)this).CopyTo(array, index);

Source/Csla/Core/IContextDictionary.cs

+9-113
Original file line numberDiff line numberDiff line change
@@ -19,135 +19,31 @@ public interface IContextDictionary : IMobileObject, IDictionary, ICollection, I
1919
/// <returns>The value associated with the specified key, or null if the key does not exist.</returns>
2020
object GetValueOrNull(string key);
2121

22-
/// <summary>
23-
/// Attempts to add the specified key and value to the ContextDictionary.
24-
/// </summary>
25-
/// <param name="key">The key of the element to add.</param>
26-
/// <param name="value">The value of the element to add. The value can be null for reference types.</param>
27-
/// <returns>
28-
/// true if the key/value pair was added to the ContextDictionary
29-
/// successfully; false if the key already exists.
30-
/// </returns>
31-
/// <exception cref="System.ArgumentNullException">key is null.</exception>
32-
/// <exception cref="System.OverflowException">The dictionary already contains the maximum number of elements (System.Int32.MaxValue).</exception>
22+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.TryAdd(TKey, TValue)"/>
3323
bool TryAdd(object key, object value);
3424

35-
/// <summary>
36-
/// Determines whether the ContextDictionary contains
37-
/// the specified key.
38-
/// </summary>
39-
/// <param name="key">The key to locate in the ContextDictionary.</param>
40-
/// <returns>
41-
/// true if the ContextDictionary contains an
42-
/// element with the specified key; otherwise, false.
43-
/// </returns>
44-
/// <exception cref="System.ArgumentNullException">key is null.</exception>
25+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.ContainsKey(TKey)"/>
4526
public bool ContainsKey(object key);
4627

47-
/// <summary>
48-
/// Attempts to remove and return the value that has the specified key from the ContextDictionary.
49-
/// </summary>
50-
/// <param name="key">The key of the element to remove and return.</param>
51-
/// <param name="value">
52-
/// When this method returns, contains the object removed from the ContextDictionary,
53-
/// or the default value of the TValue type if key does not exist.
54-
/// </param>
55-
/// <returns>true if the object was removed successfully; otherwise, false.</returns>
56-
/// <exception cref="System.ArgumentNullException">key is null.</exception>
28+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.TryRemove(TKey, out TValue)"/>
5729
public bool TryRemove(object key, out object value);
5830

59-
/// <summary>
60-
/// Attempts to get the value associated with the specified key from the ContextDictionary.
61-
/// </summary>
62-
/// <param name="key">The key of the value to get.</param>
63-
/// <param name="value">
64-
/// When this method returns, contains the object from the ContextDictionary
65-
/// that has the specified key, or the default value of the type if the operation
66-
/// failed.
67-
/// </param>
68-
/// <returns>true if the key was found in the ContextDictionary; otherwise, false.</returns>
69-
/// <exception cref="System.ArgumentNullException">key is null.</exception>
31+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.TryGetValue(TKey, out TValue)"/>
7032
public bool TryGetValue(object key, out object value);
7133

72-
/// <summary>
73-
/// Updates the value associated with key to newValue if the existing value with
74-
/// key is equal to comparisonValue.
75-
/// </summary>
76-
/// <param name="key">The key of the value that is compared with comparisonValue and possibly replaced.</param>
77-
/// <param name="newValue">
78-
/// The value that replaces the value of the element that has the specified key if
79-
/// the comparison results in equality.
80-
/// </param>
81-
/// <param name="comparisonValue">
82-
/// The value that is compared with the value of the element that has the specified
83-
/// key.
84-
/// </param>
85-
/// <returns>true if the value with key was equal to comparisonValue and was replaced with newValue; otherwise, false.</returns>
86-
/// <exception cref="System.ArgumentNullException">key is null.</exception>
34+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.TryUpdate(TKey, TValue, TValue)"/>
8735
bool TryUpdate(object key, object newValue, object comparisonValue);
8836

89-
/// <summary>
90-
/// Adds a key/value pair to the ContextDictionary
91-
/// by using the specified function if the key does not already exist. Returns the
92-
/// new value, or the existing value if the key exists.
93-
/// </summary>
94-
/// <param name="key">The key of the element to add.</param>
95-
/// <param name="valueFactory">The function used to generate a value for the key.</param>
96-
/// <returns>
97-
/// The value for the key. This will be either the existing value for the key if
98-
/// the key is already in the dictionary, or the new value if the key was not in
99-
/// the dictionary.
100-
/// </returns>
101-
/// <exception cref="System.ArgumentNullException">key or valueFactory is null.</exception>
102-
/// <exception cref="System.OverflowException">The dictionary already contains the maximum number of elements (System.Int32.MaxValue).</exception>
37+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/>
10338
object GetOrAdd(object key, Func<object, object> valueFactory);
10439

105-
/// <summary>
106-
/// Adds a key/value pair to the ContextDictionary
107-
/// if the key does not already exist. Returns the new value, or the existing value
108-
/// if the key exists.
109-
/// </summary>
110-
/// <param name="key">The key of the element to add.</param>
111-
/// <param name="value">The value to be added, if the key does not already exist.</param>
112-
/// <returns>
113-
/// The value for the key. This will be either the existing value for the key if
114-
/// the key is already in the dictionary, or the new value if the key was not in
115-
/// the dictionary.
116-
/// </returns>
117-
/// <exception cref="System.ArgumentNullException">key or valueFactory is null.</exception>
118-
/// <exception cref="System.OverflowException">The dictionary already contains the maximum number of elements (System.Int32.MaxValue).</exception>
40+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, TValue)"/>
11941
public object GetOrAdd(object key, object value);
12042

121-
/// <summary>
122-
/// Uses the specified functions to add a key/value pair to the ContextDictionary
123-
/// if the key does not already exist, or to update a key/value pair in the ContextDictionary
124-
/// if the key already exists.
125-
/// </summary>
126-
/// <param name="key">The key to be added or whose value should be updated.</param>
127-
/// <param name="addValueFactory">The function used to generate a value for an absent key.</param>
128-
/// <param name="updateValueFactory">The function used to generate a new value for an existing key based on the key's existing value.</param>
129-
/// <returns>
130-
/// The new value for the key. This will be either be the result of addValueFactory
131-
/// (if the key was absent) or the result of updateValueFactory (if the key was present).
132-
/// </returns>
133-
/// <exception cref="System.ArgumentNullException">key, addValueFactory, or updateValueFactory is null.</exception>
134-
/// <exception cref="System.OverflowException">The dictionary already contains the maximum number of elements (System.Int32.MaxValue).</exception>
43+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.AddOrUpdate(TKey, Func{TKey, TValue}, Func{TKey, TValue, TValue})"/>
13544
public object AddOrUpdate(object key, Func<object, object> addValueFactory, Func<object, object, object> updateValueFactory);
13645

137-
/// <summary>
138-
/// Adds a key/value pair to the ContextDictionary
139-
/// if the key does not already exist, or updates a key/value pair in the ContextDictionary
140-
/// by using the specified function if the key already exists.
141-
/// </summary>
142-
/// <param name="key">The key to be added or whose value should be updated.</param>
143-
/// <param name="addValue">The value to be added for an absent key.</param>
144-
/// <param name="updateValueFactory">The function used to generate a new value for an existing key based on the key's existing value.</param>
145-
/// <returns>
146-
/// The new value for the key. This will be either be addValue (if the key was absent)
147-
/// or the result of updateValueFactory (if the key was present).
148-
/// </returns>
149-
/// <exception cref="System.ArgumentNullException">key or updateValueFactory is null.</exception>
150-
/// <exception cref="System.OverflowException">The dictionary already contains the maximum number of elements (System.Int32.MaxValue).</exception>
46+
/// <inheritdoc cref="System.Collections.Concurrent.ConcurrentDictionary{TKey, TValue}.AddOrUpdate(TKey, TValue, Func{TKey, TValue, TValue})"/>
15147
public object AddOrUpdate(object key, object addValue, Func<object, object, object> updateValueFactory);
15248
}
15349
}

0 commit comments

Comments
 (0)