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
[assembly: WebActivator.PreApplicationStartMethod(typeof(Mvc4Sandbox.App_Start.StructuremapMvc), "Start")] |
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 class RedirectedConsole : IDisposable | |
{ | |
readonly TextWriter outBefore; | |
readonly TextWriter errBefore; | |
readonly StringWriter console; | |
public RedirectedConsole() | |
{ | |
console = new StringWriter(); | |
outBefore = Console.Out; |
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
static string linebreaks_wp(string body) | |
{ | |
if (body.Trim() == "") | |
return ""; | |
//Ensure all newlines are simply \n and that we end with a \n | |
body = body.Replace("\r\n", "\n") | |
.Replace("\r", "\n"); | |
body = body + "\n"; |
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
using System; | |
using System.Diagnostics.CodeAnalysis; | |
public static class Maybe | |
{ | |
public static bool Try<T>(Func<T> maybeGetValue, [NotNullWhen(true)] out T output) | |
{ | |
output = maybeGetValue(); | |
return output != null; |
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
namespace ContactList.Core.Domain | |
{ | |
using System; | |
public abstract class Entity | |
{ | |
public Guid Id { get; set; } | |
} | |
public class Contact : Entity |
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 abstract class Entity | |
{ | |
public Guid Id { get; set; } | |
} | |
public class Customer : Entity | |
{ | |
public Customer() | |
{ | |
Orders = new List<Order>(); |
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 class ContactsContext : DbContext | |
{ | |
private DbContextTransaction _currentTransaction; | |
... | |
public void BeginTransaction() | |
{ | |
if (_currentTransaction != null) | |
return; |
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 class ExampleDbContext : DbContext | |
{ | |
private DbContextTransaction _currentTransaction; | |
... | |
public void BeginTransaction() | |
{ | |
if (_currentTransaction != null) | |
return; |
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 class Assertions | |
{ | |
public static void ShouldMatch<T>(this T actual, T expected) | |
=> Json(actual).ShouldEqual(Json(expected), "Expected two objects to match on all properties."); | |
private static string Json<T>(T actual) | |
=> JsonConvert.SerializeObject(actual, Formatting.Indented); | |
... | |
} |
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 class UnitOfWork : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
var database = DependencyResolver.Current.GetService<ContactsContext>(); | |
database.BeginTransaction(); | |
} | |
public override void OnActionExecuted(ActionExecutedContext filterContext) |
NewerOlder