using System; namespace Wayne.Lib { public static class ObjectExtensions { public static TGeneral WhenOfType(this TGeneral o, Action action) where TSpecial : TGeneral { if (o is TSpecial) { action((TSpecial)o); } return o; } } }