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 SpecsForExtensions | |
{ | |
using System; | |
using System.Security.Principal; | |
using System.Web; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
public class ControllerSpecsFor<T> : DbSpecsFor<T> | |
where T : Controller |
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 Attributes | |
{ | |
using System.Web.Mvc; | |
public class DisplayModelErrorsAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuted(ActionExecutedContext filterContext) | |
{ | |
var model = filterContext.Controller.ViewData.Model; | |
var metadatas = ModelMetadataProviders.Current.GetMetadataForProperties(model, model.GetType()); |
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 MyCompany.Product | |
{ | |
// I tend to utilize immutable value objects in my domain and am | |
// attempting to, basically, inject them into my handlers via | |
// a behavior--tying into the Simple.Web pipeline. | |
public class Foo | |
{ | |
private readonly string _value; | |
public string Value { get { return _value; } } | |
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 Helpers | |
{ | |
// Used like: | |
// public override int GetHashCode() { | |
// return 17.CombineHashWith(foo).CombineHashWith(bar).CombineHashWith(GetType()); | |
// } | |
public static int CombineHashWith<T>(this int initialHash, T other) | |
{ | |
var otherHash = other == null ? 0 : other.GetHashCode(); | |
return initialHash + initialHash * 23 + otherHash; |
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
module CommandBus = | |
let createCommandRouter handlers = | |
let event = Event<Command>() | |
handlers |> List.iter(fun handler -> event.Publish |> Event.add handler) | |
let agent = MailboxProcessor.Start(fun inbox -> | |
let loop() = async { | |
let! cmd = inbox.Receive() | |
cmd |> event.Trigger | |
return! loop() } |
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
open System.Web.Hosting | |
open Simple.Web.Helpers | |
type PathUtility() = | |
interface IPathUtility with | |
member __.MapPath virtualPath = | |
virtualPath |> HostingEnvironment.MapPath |
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
[<RequireQualifiedAccess>] | |
module Authentication | |
open System | |
open System.Collections.Generic | |
open Simple.Web | |
open Simple.Web.Http | |
open Simple.Web.Authentication | |
type Payload = { UserId: Guid; Name: string; Expires: int64 } |
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
[<RequireQualifiedAccess>] | |
module Authentication | |
open System | |
open System.Collections.Generic | |
open Simple.Web | |
open Simple.Web.Http | |
open Simple.Web.Authentication | |
type Payload = { UserId: Guid; Name: string; Expires: int64 } |
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
module Counter = | |
type State = { Value: int } | |
static member Zero = { Value: 0 } | |
type Command = | |
| Incremement | |
| Decrement | |
type Event = | |
| Incremented |
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
// --Snip-- | |
let getEntity id = | |
use conn = EntityContext.GetDataContext() | |
query { for t1 in conn.Table_1 do | |
join t2 in conn.Table_2 on (t1.id = t2.table_1_id) | |
where (t1.id = id) | |
select t2 | |
headOrDefault } |> function | |
| null -> Unchecked.defaultof<_> | |
| t2 -> { Id = t2.id; Value = t2.value } |
OlderNewer