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
/// Source: http://stackoverflow.com/questions/268321/bidirectional-1-to-1-dictionary-in-c-sharp | |
/// <summary> | |
/// This is a dictionary guaranteed to have only one of each value and key. | |
/// It may be searched either by TFirst or by TSecond, giving a unique answer because it is 1 to 1. | |
/// </summary> | |
/// <typeparam name="TFirst">The type of the "key"</typeparam> | |
/// <typeparam name="TSecond">The type of the "value"</typeparam> | |
using System.Collections.Generic; | |
using System; |
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
namespace System.Collections.Generic | |
{ | |
public static class ListExtensions | |
{ | |
/// <summary> | |
/// Do a binary search in a generic list | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <typeparam name="U"></typeparam> | |
/// <param name="tf">list</param> |
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
namespace System.Collections.Generic | |
{ | |
public static class DictionaryExtension | |
{ | |
public static void ProcessValue<TKey, TValue>(this IDictionary<TKey, TValue> x, TKey key, Action<TValue> action) | |
{ | |
TValue o; | |
if (x.TryGetValue(key, out o)) | |
action(o); | |
} |
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
using System; | |
namespace iTracker.UI.Forms.Tools | |
{ | |
public class EventArgs<T> : EventArgs | |
{ | |
public T Content | |
{ | |
get; | |
set; |
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
using System; | |
using System.Collections.Generic; | |
public static class Extensions | |
{ | |
static public IEnumerable<T> Descendants<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> descendBy) | |
{ | |
foreach (T value in source) | |
{ | |
yield return value; |
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
namespace DbHelper | |
{ | |
public class OleDbHelper : DbHelper<OleDbConnection> | |
{ | |
public static DbParameter CreateParameter(string name, object value) | |
{ | |
return new OleDbParameter(name, value); | |
} | |
} |
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
public static string Truncate(this string myString, int limit, string symbol) | |
{ | |
if (myString == null) | |
return null; | |
if (limit < 0) | |
throw new ArgumentOutOfRangeException("limit", limit, "must be 0 or greater"); | |
if (symbol == null) | |
throw new ArgumentNullException("symbol must not be null"); |
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
public class DuckTryParse | |
{ | |
public static bool TryParse<duck>(string stringToParse, out duck value) | |
{ | |
var method = MethodCache<duck>.TryParse; | |
if (method == null || !method(stringToParse, out value)) | |
{ | |
value = default(duck); | |
return false; |
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
new bool DesignMode | |
{ | |
get | |
{ | |
return (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv"); | |
} | |
} |
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
<WindowsFormsHost Margin="0" x:Name="winFormHost" FontSize="11.33" FontFamily="Microsoft Sans Serif" /> |
OlderNewer