{
public static class WebExtensions
{
+
public static string ReadToEnd(this HttpWebResponse response)
{
using (var stream = response.GetResponseStream())
return new StringReader(body);
}
}
+
+
+ public static TOut NullSafe<TIn, TOut>(this TIn obj, Func<TIn, TOut> memberAction)
+ {
+ //Note we should not use obj != null because it can not test value types and also
+ //compiler has to lift the type to a nullable type for doing the comparision with null.
+ return (!EqualityComparer<TIn>.Default.Equals(obj, default(TIn))) ? memberAction(obj) : default(TOut);
+
+ }
+
+
+
+
}
}