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
/* How to use with a DataReader: */ | |
public void Test() | |
{ | |
var Res = | |
from Dr in MyDataReader.Enumerate() | |
select new { | |
ID = (Guid)Dr["ID"], | |
Description = Dr["Desc"] as string | |
}; |
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" /> |
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
// Credits: http://stackoverflow.com/questions/2683442/where-can-i-find-the-clamp-function-in-net | |
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T> | |
{ | |
if (val.CompareTo(min) < 0) return min; | |
else if(val.CompareTo(max) > 0) return max; | |
else return val; | |
} |
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
static class Program | |
{ | |
[DllImport("user32.dll")] | |
private static extern bool SetForegroundWindow(IntPtr hWnd); | |
/// <summary> | |
/// The main entry point for the application. | |
/// </summary> | |
[STAThread] | |
static void Main(string[] args) |
OlderNewer