This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IResult | |
{ | |
void Execute(); | |
} | |
public class ErrorResult : IResult | |
{ | |
public void Execute() | |
{ | |
// Does something |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(Types | |
.FromAssemblyContaining<HttpFileDownloader> | |
.BasedOn<IHtmlTitleRetriever>()); | |
); | |
// 3. "Resolve" the root service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) ) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void GetAfterPostReturnsCorrectStatusCodeWithPostedEntry() | |
{ | |
using (var client = MyHttpClientFactory.Create()) | |
{ | |
var json = new | |
{ | |
time = DateTimeOffset.Now | |
, | |
distance = 8500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Task<dynamic> ReadAsJsonAsync(this HttpContent content) | |
{ | |
if (content == null) | |
throw new ArgumentNullException("content"); | |
return content.ReadAsStringAsync().ContinueWith(t => | |
JsonConvert.DeserializeObject(t.Result)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void GetAfterPostReturnsCorrectStatusCodeWithPostedEntry() | |
{ | |
using (var client = MyHttpClientFactory.Create()) | |
{ | |
var json = new | |
{ | |
time = DateTimeOffset.Now | |
, | |
distance = 8500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main() | |
{ | |
Person person = new Person(); | |
string dateOfBirth = "10 May 1989"; | |
Console.WriteLine(person.GetAge(dateOfBirth)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void SomeMethod(ISomeInterface interface) | |
{ | |
interface.DoSomething(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void SomeMethod(SomeObject obj) | |
{ | |
obj.DoSomething(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |