Skip to content

Instantly share code, notes, and snippets.

View DavidSSL's full-sized avatar
💭
Set the status

DavidSSL

💭
Set the status
View GitHub Profile
@DavidSSL
DavidSSL / AutoReg
Created April 10, 2013 15:10
Auto registration in Castle Windsor
public static void Main()
{
// 1. Instantiate the IWindsor container object
var container = new WindsorContainer();
// 2. Register the services and the respective components that implement them
container.Register(
Component.For( typeof( IHtmlTitleRetriever ) ).ImplementedBy( typeof(HtmlTitleRetriever) ) ,
Component.For( typeof( IHtmlTitleRetriever ) ).ImplementedBy( typeof(AnotherHttpFileDownloader ) )
);
@DavidSSL
DavidSSL / WorkingGetAfterPostReturnsCorrectStatusCodeWithPostedEntry
Last active December 15, 2015 04:50
GetAfterPostReturnsCorrectStatusCodeWithPostedEntry working
[Fact]
public void GetAfterPostReturnsCorrectStatusCodeWithPostedEntry()
{
using (var client = MyHttpClientFactory.Create())
{
var json = new
{
time = DateTimeOffset.Now
,
distance = 8500
@DavidSSL
DavidSSL / GetAfterPostReturnsCorrectStatusCodeWithPostedEntry
Created March 20, 2013 12:24
GetAfterPostReturnsCorrectStatusCodeWithPostedEntry
[Fact]
public void GetAfterPostReturnsCorrectStatusCodeWithPostedEntry()
{
using (var client = MyHttpClientFactory.Create())
{
var json = new
{
time = DateTimeOffset.Now
,
distance = 8500
@DavidSSL
DavidSSL / Tightly coupled code
Created March 17, 2013 15:16
Tightly coupled code example
class Program
{
static void Main()
{
Person person = new Person();
string dateOfBirth = "10 May 1989";
Console.WriteLine(person.GetAge(dateOfBirth));
}
}
@DavidSSL
DavidSSL / PassingInterface
Created March 16, 2013 18:49
Passing interface
public void SomeMethod(ISomeInterface interface)
{
interface.DoSomething();
}
@DavidSSL
DavidSSL / PassingConcreteObj
Created March 16, 2013 18:44
Passing concrete object
public void SomeMethod(SomeObject obj)
{
obj.DoSomething();
}
@DavidSSL
DavidSSL / TryCatchThrow
Created September 21, 2012 20:11
Try catch with throw
try
{
//Code to perform some operation
}
catch
{
//Code to handle any exception that occurred in the try block
throw; // the throw keyword will pass or throw the exception to the calling method
}
@DavidSSL
DavidSSL / AnotherTryCatch
Created September 21, 2012 20:10
Another try catch
try
{
//Code to perform some operation
}
catch
{
//Code to handle any exception that occurred in the try block
// No throw statement
}
@DavidSSL
DavidSSL / TryCatch
Created September 21, 2012 20:07
Basic try catch block
try
{
//Code to perform some operation which could raise an exception
}
catch
{
//Code to handle any exception that occurred in the try block
}
SELECT
dataInt -- this is the "Content" node id
FROM [someTable].[dbo].[cmsPropertyData] PD
INNER JOIN cmsMember mb on PD.contentNodeId = mb.nodeId
WHERE LoginName = 'someLoginName'
AND dataInt IS NOT NULL
AND PD.propertyTypeId = the document type id of the "Content" node (see cmsPropertyType table)