-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
152 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Weakly | ||
{ | ||
/// <summary> | ||
/// Common extensions to <see cref="IDictionary<TKey,TValue>"/> | ||
/// </summary> | ||
public static class DictionaryHelper | ||
{ | ||
/// <summary> | ||
/// Gets the value for a key. If the key does not exist, return default(TValue); | ||
/// </summary> | ||
/// <typeparam name="TKey">The type of the keys in the dictionary.</typeparam> | ||
/// <typeparam name="TValue">The type of the values in the dictionary.</typeparam> | ||
/// <param name="dictionary">The dictionary to call this method on.</param> | ||
/// <param name="key">The key to look up.</param> | ||
/// <returns>The key value. default(TValue) if this key is not in the dictionary.</returns> | ||
public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) | ||
{ | ||
TValue result; | ||
return dictionary.TryGetValue(key, out result) ? result : default(TValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Weakly | ||
{ | ||
/// <summary> | ||
/// Provides data for the event that is raised when a faulted <see cref="Task"/> is observed. | ||
/// </summary> | ||
public sealed class FaultedTaskEventArgs : EventArgs | ||
{ | ||
private readonly Task _task; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FaultedTaskEventArgs"/> class with the faulted task. | ||
/// </summary> | ||
/// <param name="task">The Task that has faulted.</param> | ||
public FaultedTaskEventArgs(Task task) | ||
{ | ||
if (task == null) | ||
throw new ArgumentNullException("task"); | ||
|
||
_task = task; | ||
} | ||
|
||
/// <summary> | ||
/// The faulted task. | ||
/// </summary> | ||
public Task Task | ||
{ | ||
get { return _task; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters