Skip to content

Instantly share code, notes, and snippets.

var request = WebRequest.Create("http://foo.com/users/123");
request.Method = "GET";
var response = (HttpWebResponse)webRequest.GetResponse();
var data = string.Empty;
using (var stream = response.GetResponseStream())
data = new StreamReader(stream).ReadToEnd();
//However you want to deserialize
var user = Deserialize<User>(data);
node.BaseType.IsGeneric && node.BaseType.Template == FrameworkAssemblies.Mscorlib.Types.SingleOrDefault(t => t.FullName == "System.Collections.Generic.List`1")
class User
{
User Doppelganger { get; set; }
string Name { get; set; }
}
var user = new User { Name = "Ben" };
user.Doppelganger = user;
using System;
using System.Linq;
using System.Collections.Generic;
namespace managers
{
class MainClass
{
class Employee
days.collect {|d| Hpricot(d) }.each do |d|
rows = (d/"//table[contains(@id,'Timeslots')]/tbody/tr[not(@class)]").collect { |r| Slot.new r }
@days[Date.parse((d/".riTextBox").inner_text)] = rows
end
#Needed to pass each module to the cucumber World() method
#/helpers/foo_helper.rb
module FooHelpers
def foo()
puts "foo"
end
end
public class ReflectionBasedPresenterDiscoveryStrategy : IPresenterDiscoveryStrategy
{
private readonly ViewPresenterTable _presenterTable;
public ReflectionBasedPresenterDiscoveryStrategy(params Assembly[] presenterAssemblies)
{
_presenterTable = new ViewPresenterTable(presenterAssemblies);
}
public IEnumerable<PresenterDiscoveryResult> GetBindings(IEnumerable<object> hosts, IEnumerable<IView> viewInstances)
public class When_there_are_100_bottles_of_beer_on_the_wall
{
static Wall Wall;
Establish there_are = () => Wall = new Wall { NumberBottlesOfBeer = 100 };
Because we_take_one_down_and_pass_it_around = () => Wall.TakeOneDownAndPassItAround();
It should_only_have_99_bottles_of_beer_on_the_wall = () => Wall.NumberBottlesOfBeer.ShouldEqual(99);
}
public abstract class Query<T> : IQuery<T>
{
private readonly ISession _session;
protected Query(ISession session)
{
_session = session;
}
public abstract T Execute();
protected void Application_Start()
{
XmlConfigurator.Configure();
_log.Debug("Starting the application");
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new AreaViewEngine());