Skip to content

Instantly share code, notes, and snippets.

//Get the action names for a particular controller type.
public static IEnumerable<String> ActionsFromController(this Type controllerType)
{
return controllerType.GetMethods(BindingFlags.Public | BindingFlags.Instance).OfType<MethodInfo>()
.Where(y=>typeof(IActionResult).IsAssignableFrom(y)).Select(y=>y.Name);
}
//example expando...
public class ExtensibleClass : IFlyweight
{
private Dictionary<string, object> _props = new Dictionary<String, object>();
public object this[String key]{
get{
return this._props[key];
}
using System;
using System.Collections.Generic;
public class MyClass
{
public static void RunSnippet()
{
DateTime start = DateTime.Now;
for(int i = 0; i< 1000000; i++)
{
public static IEnumerable<T> Distinct(this IEnumerable<T> set, Func<T,U> propertySelector)
{
HashSet<U> distinct = new HashSet<U>();
foreach(var a in set)
{
var key = propertySelector.Invoke(a);
if(!distinct.Contains(key))
{
distinct.Add(key);
yield return a;
public static class ArrayUtils
{
public static void Push<T>(this T[] arr, T newItem)
{
arr = (new T[] { newItem }).Concat(arr).ToArray();
}
public static T Pop<T>(this T[] arr, T newItem)
{
T retval = default(T);