Skip to content

Instantly share code, notes, and snippets.

View kjeske's full-sized avatar

Krzysztof Jeske kjeske

View GitHub Profile
@kjeske
kjeske / clean.cmd
Created February 21, 2013 14:32 — forked from nikodemrafalski/clean.cmd
Clean bin and obj artifacts directories downstream current directory tree.
for /d /r . %%d in (bin, obj) do @if exist "%%d" rd /s/q "%%d"
@kjeske
kjeske / ObjectExtensions.cs
Last active March 14, 2016 16:54
Safely get the property value from a source object. If the source object is null, then get the default value.
public static class ObjectExtensions
{
public static TReturn safe<T, TReturn>(this T testedObject, Func<T, TReturn> member, TReturn defaultValue = default(TReturn))
where T : class
{
return testedObject != null ? member(testedObject) : defaultValue;
}
}
// Usage example: