Skip to content

Instantly share code, notes, and snippets.

View rexcfnghk's full-sized avatar

Rex Ng rexcfnghk

View GitHub Profile
public class AppNinjectModule : NinjectModule
{
public override void Load()
{
Bind<UserProfile>()
.ToMethod(ctx => ctx.Get<UserProfileManager>().GetUserProfile())
.InRequestScope();
this.BindFilter<UserProfileActionFilterAttribute>(FilterScope.Action, 0);
}
}
@{
var user = (UserProfile)ViewBag.User;
}
<h2>Hello, @user.DisplayName</h2>
public class UserProfileActionFilterAttributeTests
{
[Fact]
public void OnActionExecuting_UserProfileExistsInViewBag()
{
// Arrange
var expected = new UserProfile { DisplayName = "Foo" };
var mockController = new Mock<ControllerBase>().Object;
var mockActionExecutingContext = new Mock<ActionExecutingContext>();
type Option<'a> =
| Some of 'a
| None
module Option =
// Catamorphism for 'a option
// val cata: someF: ('a -> 'b) -> noneF: 'b -> 'a option -> 'b
let cata someF noneF = function
| Some x -> valueF x
public class Foo
{
private readonly Bar _bar;
public Foo(Bar bar)
{
_bar = bar;
}
public Bar Bar
public class Foo
{
public Foo(Bar bar)
{
Bar = bar;
}
public Bar Bar { get; }
}
public class Foo
{
public Bar Bar
{
get { return new Bar(); }
}
}
public class Foo
{
public Bar Bar => new Bar();
}
public class Foo
{
public Bar Bar1 => new Bar();
public Bar Bar2 { get; } = new Bar();
}
public class Program
{
public static void Main(string[] args)
public class Foo
{
private readonly Bar _bar2;
public Foo()
{
_bar2 = new Bar();
}
public Bar Bar1