This file contains hidden or 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 AppNinjectModule : NinjectModule | |
| { | |
| public override void Load() | |
| { | |
| Bind<UserProfile>() | |
| .ToMethod(ctx => ctx.Get<UserProfileManager>().GetUserProfile()) | |
| .InRequestScope(); | |
| this.BindFilter<UserProfileActionFilterAttribute>(FilterScope.Action, 0); | |
| } | |
| } |
This file contains hidden or 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
| @{ | |
| var user = (UserProfile)ViewBag.User; | |
| } | |
| <h2>Hello, @user.DisplayName</h2> |
This file contains hidden or 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 UserProfileActionFilterAttributeTests | |
| { | |
| [Fact] | |
| public void OnActionExecuting_UserProfileExistsInViewBag() | |
| { | |
| // Arrange | |
| var expected = new UserProfile { DisplayName = "Foo" }; | |
| var mockController = new Mock<ControllerBase>().Object; | |
| var mockActionExecutingContext = new Mock<ActionExecutingContext>(); |
This file contains hidden or 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
| 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 |
This file contains hidden or 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 Foo | |
| { | |
| private readonly Bar _bar; | |
| public Foo(Bar bar) | |
| { | |
| _bar = bar; | |
| } | |
| public Bar Bar |
This file contains hidden or 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 Foo | |
| { | |
| public Foo(Bar bar) | |
| { | |
| Bar = bar; | |
| } | |
| public Bar Bar { get; } | |
| } |
This file contains hidden or 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 Foo | |
| { | |
| public Bar Bar | |
| { | |
| get { return new Bar(); } | |
| } | |
| } |
This file contains hidden or 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 Foo | |
| { | |
| public Bar Bar => new Bar(); | |
| } |
This file contains hidden or 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 Foo | |
| { | |
| public Bar Bar1 => new Bar(); | |
| public Bar Bar2 { get; } = new Bar(); | |
| } | |
| public class Program | |
| { | |
| public static void Main(string[] args) |
This file contains hidden or 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 Foo | |
| { | |
| private readonly Bar _bar2; | |
| public Foo() | |
| { | |
| _bar2 = new Bar(); | |
| } | |
| public Bar Bar1 |