Format:
Recent snippets matching language of C#
[TestFixture] public class ObjectTests { #region Setup/Teardown [SetUp] public void SetUp() { _id1 = Guid.NewGuid(); _id2 = Guid.NewGuid();
6 Views
no comments
[TestFixture] public class EntityTests { #region Setup/Teardown [SetUp] public void SetUp() { _id1 = Guid.NewGuid(); _id2 = Guid.NewGuid();
9 Views
no comments
[Serializable] public abstract class Entity : ValueObject, IEntity { public virtual Guid Id { get; protected set; } private int? _cachedHashCode; public virtual bool IsTransient() { return Id.Equals(null) || Id.Equals(Guid.Empty); }
11 Views
no comments
[Serializable] public abstract class Entity : ValueObject, IEntity { #region Fields & Properties public virtual Guid Id { get; protected set; } private int? _cachedHashCode; #endregion
4 Views
no comments
[Serializable] public abstract class ValueObject : IEquatable<ValueObject> { public bool Equals(ValueObject other) { // is other null? if (ReferenceEquals(other, null)) return false; // are they the same object?
11 Views
no comments
[Test]
public void comparing_to_a_null_object_is_false_and_cannot_be_equal()
{
var phone = new Telephone(11111, 111111);
Assert.That(phone.Equals(null), Is.False);
}
[Test]
public void comparing_to_self_is_true_and_always_equal()
9 Views
no comments
[Test]
public void comparing_to_a_null_object_is_false_and_cannot_be_equal()
{
var phone = new Telephone(11111, 111111);
Assert.That(phone.Equals(null), Is.False);
}
[Test]
public void comparing_to_self_is_true_and_always_equal()
5 Views
no comments
[Test]
public void comparing_to_a_null_object_is_false_and_cannot_be_equal()
{
var phone = new Telephone(11111, 111111);
Assert.That(phone.Equals(null), Is.False);
}
[Test]
public void comparing_to_self_is_true_and_always_equal()
5 Views
no comments
The following extensions methods can help you in the situation below: public static TResult IfNotNull<TSource, TResult>(this TSource obj, Func<TSource, TResult> func) { return IfNotNull(obj, func, default(TResult)); } public static TResult IfNotNull<TSource, TResult>(this TSource obj, Func<TSource, TResult> func, TResult defaultIfNull) { return obj == null ? defaultIfNull : func(obj); }
11 Views
no comments
public static TResult IfNotNull<TSource, TResult>(this TSource obj, Func<TSource, TResult> func)
{
return IfNotNull(obj, func, default(TResult));
}
public static TResult IfNotNull<TSource, TResult>(this TSource obj, Func<TSource, TResult> func, TResult defaultIfNull)
{
return obj == null ? defaultIfNull : func(obj);
}
9 Views
no comments
/* * This is the "IRQ descriptor", which contains various information * about the irq, including what kind of hardware handling it has, * whether it is disabled etc etc. * * Pad this out to 32 bytes for cache and indexing reasons. */ typedef struct { unsigned int status; /* IRQ status */ hw_irq_controller *handler;
5 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FinbonacciApp { class Program { static void Main(string[] args)
7 Views
no comments
using System; namespace Foo { /// <summary> /// A dummy callback-like mechanism for our application logic. /// </summary> public interface IStatusProvider { /// <summary>
5 Views
no comments
public class ServerRegistry : MassTransitRegistryBase { public ServerRegistry() { MsmqEndpointConfigurator.Defaults(x => { x.CreateMissingQueues = true; x.CreateTransactionalQueues = true; //x.PurgeOnStartup = true;
6 Views
no comments
public Bitmap ConvertToGrayscale(Bitmap source) { Bitmap bm = new Bitmap(source.Width,source.Height); for(int y=0;y<bm.Height;y++) { for(int x=0;x<bm.Width;x++) { Color c=source.GetPixel(x,y); int luma = (int)(c.R*0.3 + c.G*0.59+ c.B*0.11); bm.SetPixel(x,y,Color.FromArgb(luma,luma,luma));
9 Views
no comments
Get["/"] = x => { return "This is the root"; }; Get["/Greet"] = x => { return "Hello World"; }; Get["/Greet/{name}"] = x => { return "Hello " + x.name;
9 Views
no comments
public class UriBinder : HttpProcessor { private static List<UriBinding> _bindings; static UriBinder() { _bindings = new List<UriBinding>(); } public static void AddUriBinding<TModel>(string name, string matchRegex, Func<int, object> modelFactory)
43 Views
no comments
//in startup UriBinder.AddUriBinding<Contact>("contact", "contact/(.+)", cid => ContactsHandler._contacts.Single(c => c.ContactID == cid)); //request is http://contactmanager/contact/1 //the resource takes contact as a param public class ContactHandler { public Contact Get(Contact contact) {
30 Views
no comments
public class Crypt { public static string OpenSslSign(string privateKeyFile, string content) { var pkey = new PrivateKey(); pkey.LoadPemFile(privateKeyFile); string pkeyXml = pkey.GetXml(); var rsa = new Rsa(); bool success = rsa.UnlockComponent("30-day trial"); if (success != true) {
7 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media;
8 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input;
8 Views
no comments
protected void Button2_Click(object sender, EventArgs e) { string uri = "http://quality.osm.no"; Uri weburi = new Uri(uri, false); StringBuilder sbuild = new StringBuilder(); string temp = ""; try { HttpWebRequest webrequest = (HttpWebRequest) WebRequest.Create(weburi); CredentialCache myCache = new CredentialCache();
9 Views
no comments
#region License /* ************************************************************** * Author: Rick Strahl * © West Wind Technologies, 2008 - 2009 * http://www.west-wind.com/ * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without
13 Views
no comments
[Test] public void Idle_ServerDisconnects_NoUnhandeledException() { bool unhandeledException = false; UnhandledExceptionEventHandler fail = (sender, args) => unhandeledException = true; try { AppDomain.CurrentDomain.UnhandledException += fail; WithLogin(client =>
43 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
