Skip to content

Commit

Permalink
Added RecurseWhile extensions; renamed IEnumerable<Boolean> extension…
Browse files Browse the repository at this point in the history
…s; added ConcurrentDictionary<TKey, TValue> extension; updated version info...
  • Loading branch information
iSynaptic committed Feb 4, 2013
1 parent 1787d2d commit 76a64bf
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 77 deletions.
@@ -0,0 +1,41 @@
// The MIT License
//
// Copyright (c) 2013 Jordan E. Terrell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System.Collections.Concurrent;

namespace iSynaptic.Commons.Collections.Concurrent
{
public static class ConcurrentDictionaryExtensions
{
public static Maybe<TValue> TryGetValue<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> @this, TKey key)
{
Guard.NotNull(@this, "@this");

TValue retreivedValue = default(TValue);

return @this
.ToMaybe()
.Where(x => x.TryGetValue(key, out retreivedValue))
.Select(x => retreivedValue);
}
}
}

0 comments on commit 76a64bf

Please sign in to comment.