├── .gitignore ├── .gitmodules ├── VERSION.txt ├── rakefile.rb ├── readme.markdown ├── ripple.cmd ├── ripple.config └── src ├── Ajax └── AjaxContinuation │ ├── AjaxContinuationRecipe.Tests.Unit │ ├── AjaxContinuationRecipe.Tests.Unit.csproj │ ├── Handlers │ │ └── LogOn │ │ │ ├── GetHandlerTests.cs │ │ │ └── PostHandlerTests.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config │ ├── AjaxContinuationRecipe.sln │ ├── AjaxContinuationRecipe │ ├── AjaxContinuationRecipe.csproj │ ├── App_Start │ │ └── FubuMVC.cs │ ├── ConfigureFubuMVC.cs │ ├── Handlers │ │ ├── HandlersMarker.cs │ │ └── LogOn │ │ │ ├── GetHandler.cs │ │ │ ├── LogOn.spark │ │ │ ├── LogOnInputModel.cs │ │ │ ├── LogOnRequestModel.cs │ │ │ └── PostHandler.cs │ ├── Scripts │ │ ├── jquery-1.4.4-vsdoc.js │ │ ├── jquery-1.4.4.js │ │ ├── jquery-1.4.4.min.js │ │ ├── jquery.validate-vsdoc.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ ├── Settings.StyleCop │ ├── Shared │ │ └── Application.spark │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── fubu-content │ │ ├── FubuMVC.GettingStarted.dll │ │ └── fubumvc-diagnostics.zip │ └── packages.config │ └── nuget.config ├── Continuations ├── FubuContinuation │ ├── FubuContinuationRecipe.Tests.Unit │ │ ├── FubuContinuationRecipe.Tests.Unit.csproj │ │ ├── Handlers │ │ │ ├── DeadEnd │ │ │ │ └── GetHandlerTests.cs │ │ │ └── Home │ │ │ │ ├── GetHandlerTests.cs │ │ │ │ └── PostHandlerTests.cs │ │ └── packages.config │ ├── FubuContinuationRecipe.Web │ │ ├── App_Start │ │ │ └── FubuMVC.cs │ │ ├── ConfigureFubuMVC.cs │ │ ├── Content │ │ │ └── css │ │ │ │ └── style.css │ │ ├── FubuContinuationRecipe.Web.csproj │ │ ├── Handlers │ │ │ ├── DeadEnd │ │ │ │ ├── DeadEnd.spark │ │ │ │ ├── DeadEndViewModel.cs │ │ │ │ └── GetHandler.cs │ │ │ ├── HandlersMarker.cs │ │ │ └── Home │ │ │ │ ├── GetHandler.cs │ │ │ │ ├── Home.spark │ │ │ │ ├── HomeRequestModel.cs │ │ │ │ ├── HomeViewModel.cs │ │ │ │ └── PostHandler.cs │ │ ├── Shared │ │ │ ├── Application.spark │ │ │ ├── _global.spark │ │ │ └── bindings.xml │ │ ├── Web.Debug.config │ │ ├── Web.Release.config │ │ ├── Web.config │ │ ├── fubu-content │ │ │ ├── FubuMVC.GettingStarted.dll │ │ │ └── fubumvc-diagnostics.zip │ │ └── packages.config │ ├── FubuContinuationRecipe.sln │ ├── nuget.config │ └── readme.markdown └── IRedirectable │ ├── IRedirectableRecipe.Tests.Unit │ ├── Handlers │ │ ├── DeadEnd │ │ │ └── GetHandlerTests.cs │ │ └── Home │ │ │ ├── GetHandlerTests.cs │ │ │ └── PostHandlerTests.cs │ ├── IRedirectableRecipe.Tests.Unit.csproj │ └── packages.config │ ├── IRedirectableRecipe.Web │ ├── App_Start │ │ └── FubuMVC.cs │ ├── ConfigureFubuMVC.cs │ ├── Content │ │ └── css │ │ │ └── style.css │ ├── Handlers │ │ ├── DeadEnd │ │ │ ├── DeadEnd.spark │ │ │ ├── DeadEndViewModel.cs │ │ │ └── GetHandler.cs │ │ ├── HandlersMarker.cs │ │ └── Home │ │ │ ├── GetHandler.cs │ │ │ ├── Home.spark │ │ │ ├── HomeRequestModel.cs │ │ │ ├── HomeViewModel.cs │ │ │ └── PostHandler.cs │ ├── IRedirectableRecipe.Web.csproj │ ├── Shared │ │ ├── Application.spark │ │ ├── _global.spark │ │ └── bindings.xml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── fubu-content │ │ ├── FubuMVC.GettingStarted.dll │ │ └── fubumvc-diagnostics.zip │ └── packages.config │ ├── IRedirectableRecipe.sln │ ├── nuget.config │ └── readme.markdown ├── Http └── ICurrentChain │ ├── ICurrentChainRecipe.Tests.Unit │ ├── Handlers │ │ ├── DeadEnd │ │ │ └── GetHandlerTests.cs │ │ └── Home │ │ │ ├── GetHandlerTests.cs │ │ │ └── PostHandlerTests.cs │ ├── ICurrentChainRecipe.Tests.Unit.csproj │ └── packages.config │ ├── ICurrentChainRecipe.Web │ ├── App_Start │ │ └── FubuMVC.cs │ ├── ConfigureFubuMVC.cs │ ├── Content │ │ └── css │ │ │ └── style.css │ ├── Handlers │ │ ├── CommonViewModel.cs │ │ ├── DeadEnd │ │ │ ├── DeadEnd.spark │ │ │ ├── DeadEndViewModel.cs │ │ │ └── GetHandler.cs │ │ ├── HandlersMarker.cs │ │ └── Home │ │ │ ├── GetHandler.cs │ │ │ ├── Home.spark │ │ │ ├── HomeRequestModel.cs │ │ │ ├── HomeViewModel.cs │ │ │ └── PostHandler.cs │ ├── Helpers │ │ └── ViewModelHelper.cs │ ├── ICurrentChainRecipe.Web.csproj │ ├── Shared │ │ ├── Application.spark │ │ ├── ChainInfo.spark │ │ ├── _global.spark │ │ └── bindings.xml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── fubu-content │ │ ├── FubuMVC.GettingStarted.dll │ │ └── fubumvc-diagnostics.zip │ └── packages.config │ ├── ICurrentChainRecipe.sln │ ├── nuget.config │ └── readme.markdown ├── Other └── DownloadStream │ ├── DownloadStreamRecipe.sln │ ├── DownloadStreamRecipe │ ├── App_Start │ │ └── FubuMVC.cs │ ├── Assets │ │ ├── desert.jpg │ │ └── hola.pdf │ ├── ConfigureFubuMVC.cs │ ├── Controllers │ │ ├── HomeController.cs │ │ ├── JpegController.cs │ │ └── PdfController.cs │ ├── DownloadStreamRecipe.csproj │ ├── Settings.StyleCop │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── fubu-content │ │ ├── FubuMVC.GettingStarted.dll │ │ └── fubumvc-diagnostics.zip │ └── packages.config │ └── nuget.config ├── Security ├── BasicIAuthorizationPolicy │ ├── IAuthorizationPolicyRecipe.Tests.Unit │ │ ├── Handlers │ │ │ ├── Account │ │ │ │ ├── LogOn │ │ │ │ │ ├── GetHandlerTests.cs │ │ │ │ │ └── PostHandlerTests.cs │ │ │ │ └── LogOut │ │ │ │ │ └── GetHandlerTests.cs │ │ │ ├── AdvSectionMaps │ │ │ │ └── GetHandlerTests.cs │ │ │ ├── AdvSectionOne │ │ │ │ └── GetHandlerTests.cs │ │ │ └── Home │ │ │ │ └── GetHandlerTests.cs │ │ ├── IAuthorizationPolicyRecipe.Tests.Unit.csproj │ │ └── packages.config │ ├── IAuthorizationPolicyRecipe.Web │ │ ├── App_Start │ │ │ └── FubuMVC.cs │ │ ├── ConfigureFubuMVC.cs │ │ ├── Content │ │ │ └── css │ │ │ │ └── style.css │ │ ├── Handlers │ │ │ ├── Account │ │ │ │ ├── LogOn │ │ │ │ │ ├── GetHandler.cs │ │ │ │ │ ├── LogOn.spark │ │ │ │ │ ├── LogOnRequestModel.cs │ │ │ │ │ ├── LogOnViewModel.cs │ │ │ │ │ └── PostHandler.cs │ │ │ │ └── LogOut │ │ │ │ │ ├── GetHandler.cs │ │ │ │ │ └── LogOutRequestModel.cs │ │ │ ├── AdvSectionMaps │ │ │ │ ├── AdvSectionMaps.spark │ │ │ │ ├── AdvSectionMapsViewModel.cs │ │ │ │ └── GetHandler.cs │ │ │ ├── AdvSectionOne │ │ │ │ ├── AdvSectionOne.spark │ │ │ │ ├── AdvSectionOneViewModel.cs │ │ │ │ └── GetHandler.cs │ │ │ ├── HandlersMarker.cs │ │ │ └── Home │ │ │ │ ├── GetHandler.cs │ │ │ │ ├── Home.spark │ │ │ │ └── HomeViewModel.cs │ │ ├── IAuthorizationPolicyRecipe.Web.csproj │ │ ├── Security │ │ │ ├── FubuRoleProvider.cs │ │ │ ├── IRoleStore.cs │ │ │ ├── IUserData.cs │ │ │ ├── RoleReference.cs │ │ │ ├── RoleStore.cs │ │ │ ├── SecurityRegistry.cs │ │ │ └── UserData.cs │ │ ├── Shared │ │ │ ├── Application.spark │ │ │ └── _global.spark │ │ ├── Web.Debug.config │ │ ├── Web.Release.config │ │ ├── Web.config │ │ ├── fubu-content │ │ │ ├── FubuMVC.GettingStarted.dll │ │ │ └── fubumvc-diagnostics.zip │ │ └── packages.config │ ├── IAuthorizationPolicyRecipe.sln │ ├── nuget.config │ └── readme.markdown └── CustomIAuthorizationPolicy │ ├── IAuthorizationPolicyRecipe.Tests.Unit │ ├── Handlers │ │ ├── Account │ │ │ ├── LogOn │ │ │ │ ├── GetHandlerTests.cs │ │ │ │ └── PostHandlerTests.cs │ │ │ └── LogOut │ │ │ │ └── GetHandlerTests.cs │ │ ├── AdvSectionMaps │ │ │ └── GetHandlerTests.cs │ │ ├── AdvSectionOne │ │ │ └── GetHandlerTests.cs │ │ └── Home │ │ │ └── GetHandlerTests.cs │ ├── IAuthorizationPolicyRecipe.Tests.Unit.csproj │ ├── Security │ │ ├── AccessGroupAttributeTests.cs │ │ └── AccessGroupAuthorizationPolicyTests.cs │ └── packages.config │ ├── IAuthorizationPolicyRecipe.Web │ ├── App_Start │ │ └── FubuMVC.cs │ ├── ConfigureFubuMVC.cs │ ├── Content │ │ └── css │ │ │ └── style.css │ ├── Handlers │ │ ├── Account │ │ │ ├── LogOn │ │ │ │ ├── GetHandler.cs │ │ │ │ ├── LogOn.spark │ │ │ │ ├── LogOnRequestModel.cs │ │ │ │ ├── LogOnViewModel.cs │ │ │ │ └── PostHandler.cs │ │ │ └── LogOut │ │ │ │ └── GetHandler.cs │ │ ├── AdvSectionMaps │ │ │ ├── AdvSectionMaps.spark │ │ │ ├── AdvSectionMapsViewModel.cs │ │ │ └── GetHandler.cs │ │ ├── AdvSectionOne │ │ │ ├── AdvSectionOne.spark │ │ │ ├── AdvSectionOneViewModel.cs │ │ │ └── GetHandler.cs │ │ ├── HandlersMarker.cs │ │ └── Home │ │ │ ├── GetHandler.cs │ │ │ ├── Home.spark │ │ │ └── HomeViewModel.cs │ ├── IAuthorizationPolicyRecipe.Web.csproj │ ├── Security │ │ ├── AccessGroup.cs │ │ ├── AccessGroupAttribute.cs │ │ ├── AccessGroupAuthorizationPolicy.cs │ │ ├── AccessGroupConvention.cs │ │ ├── AccessGroupReference.cs │ │ ├── FormsAuthenticationWrapper.cs │ │ ├── IFormsAuthenticationWrapper.cs │ │ ├── IUserData.cs │ │ ├── SecurityRegistry.cs │ │ └── UserData.cs │ ├── Shared │ │ ├── Application.spark │ │ └── _global.spark │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── fubu-content │ │ ├── FubuMVC.GettingStarted.dll │ │ └── fubumvc-diagnostics.zip │ └── packages.config │ ├── IAuthorizationPolicyRecipe.sln │ ├── nuget.config │ └── readme.markdown ├── UI └── HtmlConventionsWithPageExtensions │ ├── FubuPageExtensionsRecipe.Tests.Unit │ ├── FubuPageExtensionsRecipe.Tests.Unit.csproj │ ├── Handlers │ │ ├── Books │ │ │ └── Create │ │ │ │ ├── GetHandlerTests.cs │ │ │ │ └── PostHandlerTests.cs │ │ ├── Genre │ │ │ └── Create │ │ │ │ └── PostHandlerTests.cs │ │ └── Home │ │ │ └── GetHandlerTests.cs │ └── packages.config │ ├── FubuPageExtensionsRecipe.Web │ ├── App_Start │ │ └── FubuMVC.cs │ ├── ConfigureFubuMVC.cs │ ├── Content │ │ ├── Css │ │ │ ├── jquery-ui-1.8.16.custom.css │ │ │ └── style.css │ │ ├── Scripts │ │ │ ├── RecipeHtmlConventions.js │ │ │ ├── jquery-1.6.2.min.js │ │ │ └── jquery-ui-1.8.16.custom.min.js │ │ └── images │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ ├── ui-icons_454545_256x240.png │ │ │ ├── ui-icons_888888_256x240.png │ │ │ └── ui-icons_cd0a0a_256x240.png │ ├── Conventions │ │ └── RecipeHtmlConventionsRegistry.cs │ ├── FubuPageExtensionsRecipe.Web.csproj │ ├── Handlers │ │ ├── Books │ │ │ └── Create │ │ │ │ ├── Create.spark │ │ │ │ ├── CreateRequestModel.cs │ │ │ │ ├── CreateViewModel.cs │ │ │ │ ├── GetHandler.cs │ │ │ │ └── PostHandler.cs │ │ ├── Genre │ │ │ └── Create │ │ │ │ ├── CreateRequestModel.cs │ │ │ │ └── PostHandler.cs │ │ ├── HandlersMarker.cs │ │ └── Home │ │ │ ├── GetHandler.cs │ │ │ ├── Home.spark │ │ │ └── HomeViewModel.cs │ ├── Models │ │ ├── BookStatus.cs │ │ ├── Genre.cs │ │ └── ImageDisplayModel.cs │ ├── Shared │ │ ├── Application.spark │ │ ├── _global.spark │ │ └── bindings.xml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── fubu-content │ │ ├── FubuMVC.GettingStarted.dll │ │ └── fubumvc-diagnostics.zip │ └── packages.config │ ├── FubuPageExtensionsRecipe.sln │ ├── nuget.config │ └── readme.markdown └── Urls └── IUrlRegistry ├── IUrlRegistryRecipe.Tests.Unit ├── IUrlRegistryRecipe.Tests.Unit.csproj ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── IUrlRegistryRecipe.Web ├── App_Start │ └── FubuMVC.cs ├── ConfigureFubuMVC.cs ├── Content │ └── Css │ │ └── style.css ├── Controllers │ ├── BookController.cs │ └── HomeController.cs ├── IUrlRegistryRecipe.Web.csproj ├── Models │ ├── Books │ │ ├── BookAddRequest.cs │ │ ├── BookFindRequestModel.cs │ │ ├── BookViewModel.cs │ │ └── BookViewRequestModel.cs │ ├── CallList.cs │ ├── DynamicFuncList.cs │ ├── HomeViewModel.cs │ ├── ValuePair.cs │ └── ValuePairList.cs ├── Properties │ └── AssemblyInfo.cs ├── Shared │ ├── Application.spark │ └── _global.spark ├── Views │ └── HomeViewModel.spark ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── fubu-content │ ├── FubuMVC.GettingStarted.dll │ └── fubumvc-diagnostics.zip └── packages.config ├── IUrlRegistryRecipe.sln ├── nuget.config └── readme.markdown /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio 2 | obj 3 | bin 4 | src/CommonAssemblyInfo.cs 5 | *.csproj.user 6 | *.suo 7 | *.cache 8 | 9 | # Fubu 10 | /src/*/*/*/fubu-content/*/ 11 | 12 | results 13 | build 14 | artifacts 15 | 16 | # NuGet 17 | packages 18 | repositories.config 19 | 20 | # mvim 21 | *.swp 22 | 23 | # Resharper 24 | *.resharper.user 25 | *.ReSharper.user 26 | */_Resharper.*/ 27 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "buildsupport"] 2 | path = buildsupport 3 | url = git://github.com/DarthFubuMVC/buildsupport.git 4 | -------------------------------------------------------------------------------- /VERSION.txt: -------------------------------------------------------------------------------- 1 | BUILD_VERSION = "0.0.1" -------------------------------------------------------------------------------- /ripple.cmd: -------------------------------------------------------------------------------- 1 | buildsupport\ripple.exe %* -------------------------------------------------------------------------------- /ripple.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | fubumvc.recipes 4 | packaging/nuget 5 | src 6 | rake 7 | rake compile 8 | 9 | FubuMVC 10 | FubuMVC.References 11 | FubuMVC.Spark 12 | FubuMVC.Validation 13 | HtmlTags 14 | NUnit 15 | Moq 16 | 17 | -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe.Tests.Unit/Handlers/LogOn/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace AjaxContinuationRecipe.Tests.Unit.Handlers.LogOn 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using AjaxContinuationRecipe.Handlers.LogOn; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | private GetHandler getHandler; 11 | 12 | [SetUp] 13 | public void TestSetup() 14 | { 15 | this.getHandler = new GetHandler(); 16 | } 17 | 18 | [Test] 19 | public void CallingExecuteReturnsNotNullLogOnRequestModel() 20 | { 21 | var result = this.getHandler.Execute(); 22 | Assert.IsNotNull(result); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe.Tests.Unit/Handlers/LogOn/PostHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace AjaxContinuationRecipe.Tests.Unit.Handlers.LogOn 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using AjaxContinuationRecipe.Handlers.LogOn; 6 | 7 | [TestFixture] 8 | public class PostHandlerTests 9 | { 10 | private PostHandler postHandler; 11 | 12 | [SetUp] 13 | public void TestSetup() 14 | { 15 | this.postHandler = new PostHandler(); 16 | } 17 | 18 | [Test] 19 | public void WhenCallingExecuteReturnsNotNullAjaxContinuation() 20 | { 21 | var result = this.postHandler.Execute(new LogOnInputModel() { UserName = "TestUser", Password = "TestPassword" }); 22 | Assert.IsNotNull(result); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe.Tests.Unit/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AjaxContinuation.Tests.Unit")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AjaxContinuation.Tests.Unit")] 13 | [assembly: AssemblyCopyright("Copyright © 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a093fc24-0728-4b2b-b8cc-c622aa4bc944")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AjaxContinuationRecipe", "AjaxContinuationRecipe\AjaxContinuationRecipe.csproj", "{7D61DB33-167E-463E-ACD0-29E26AF1D2F5}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AjaxContinuationRecipe.Tests.Unit", "AjaxContinuationRecipe.Tests.Unit\AjaxContinuationRecipe.Tests.Unit.csproj", "{30187F6F-3DB2-49FE-8B12-247ED964EDB2}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {7D61DB33-167E-463E-ACD0-29E26AF1D2F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7D61DB33-167E-463E-ACD0-29E26AF1D2F5}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7D61DB33-167E-463E-ACD0-29E26AF1D2F5}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7D61DB33-167E-463E-ACD0-29E26AF1D2F5}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {30187F6F-3DB2-49FE-8B12-247ED964EDB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {30187F6F-3DB2-49FE-8B12-247ED964EDB2}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {30187F6F-3DB2-49FE-8B12-247ED964EDB2}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {30187F6F-3DB2-49FE-8B12-247ED964EDB2}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | using FubuMVC.Core; 2 | using FubuMVC.Spark; 3 | using FubuMVC.Validation; 4 | 5 | namespace AjaxContinuationRecipe 6 | { 7 | public class ConfigureFubuMVC : FubuRegistry 8 | { 9 | public ConfigureFubuMVC() 10 | { 11 | // This line turns on the basic diagnostics and request tracing 12 | IncludeDiagnostics(true); 13 | 14 | ApplyHandlerConventions(); 15 | 16 | Routes.HomeIs(home => home.Execute()); 17 | 18 | // All public methods from concrete classes ending in "Controller" 19 | // in this assembly are assumed to be action methods 20 | Actions.IncludeClassesSuffixedWithController(); 21 | 22 | this.UseSpark(); 23 | 24 | this.Validation(); 25 | 26 | // Policies 27 | Routes 28 | .IgnoreControllerNamesEntirely() 29 | .IgnoreMethodSuffix("Html") 30 | .RootAtAssemblyNamespace(); 31 | 32 | // Match views to action methods by matching 33 | // on model type, view name, and namespace 34 | Views.TryToAttachWithDefaultConventions(); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Handlers/HandlersMarker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace AjaxContinuationRecipe.Handlers 7 | { 8 | public class HandlersMarker 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Handlers/LogOn/GetHandler.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace AjaxContinuationRecipe.Handlers.LogOn 3 | { 4 | public class GetHandler 5 | { 6 | public LogOnRequestModel Execute() 7 | { 8 | return new LogOnRequestModel(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Handlers/LogOn/LogOn.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | Authenticate 4 | 5 | 6 | 11 | 41 | 42 | 43 | 44 |
45 | 46 | 47 |
48 | 49 | 50 |
51 | 52 |
53 |
-------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Handlers/LogOn/LogOnInputModel.cs: -------------------------------------------------------------------------------- 1 | namespace AjaxContinuationRecipe.Handlers.LogOn 2 | { 3 | using FubuValidation; 4 | 5 | public class LogOnInputModel 6 | { 7 | [Required] 8 | public string UserName { get; set; } 9 | 10 | [Required] 11 | public string Password { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Handlers/LogOn/LogOnRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace AjaxContinuationRecipe.Handlers.LogOn 2 | { 3 | public class LogOnRequestModel : LogOnInputModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Handlers/LogOn/PostHandler.cs: -------------------------------------------------------------------------------- 1 | namespace AjaxContinuationRecipe.Handlers.LogOn 2 | { 3 | using FubuMVC.Core.Ajax; 4 | 5 | public class PostHandler 6 | { 7 | public AjaxContinuation Execute(LogOnInputModel input) 8 | { 9 | return new AjaxContinuation 10 | { 11 | Success = true 12 | }; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Shared/Application.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <use content="title"/> | AjaxContinuation 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Ajax/AjaxContinuation/AjaxContinuationRecipe/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Ajax/AjaxContinuation/AjaxContinuationRecipe/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/AjaxContinuationRecipe/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Ajax/AjaxContinuation/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Tests.Unit/Handlers/DeadEnd/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Tests.Unit.Handlers.DeadEnd 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using DeadEnd = FubuContinuationRecipe.Web.Handlers.DeadEnd; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new DeadEnd.GetHandler(); 14 | Assert.IsNotNull(handler.Execute(new DeadEnd.DeadEndViewModel())); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Tests.Unit/Handlers/Home/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Tests.Unit.Handlers.Home 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using Home = FubuContinuationRecipe.Web.Handlers.Home; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new Home.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/App_Start/FubuMVC.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Routing; 2 | using Bottles; 3 | using FubuMVC.Core; 4 | using FubuMVC.StructureMap; 5 | using StructureMap; 6 | 7 | // You can remove the reference to WebActivator by calling the Start() method from your Global.asax Application_Start 8 | [assembly: WebActivator.PreApplicationStartMethod(typeof(FubuContinuationRecipe.Web.App_Start.AppStartFubuMVC), "Start", callAfterGlobalAppStart: true)] 9 | 10 | namespace FubuContinuationRecipe.Web.App_Start 11 | { 12 | public static class AppStartFubuMVC 13 | { 14 | public static void Start() 15 | { 16 | // FubuApplication "guides" the bootstrapping of the FubuMVC 17 | // application 18 | FubuApplication.For() // ConfigureFubuMVC is the main FubuRegistry 19 | // for this application. FubuRegistry classes 20 | // are used to register conventions, policies, 21 | // and various other parts of a FubuMVC application 22 | 23 | 24 | // FubuMVC requires an IoC container for its own internals. 25 | // In this case, we're using a brand new StructureMap container, 26 | // but FubuMVC just adds configuration to an IoC container so 27 | // that you can use the native registration API's for your 28 | // IoC container for the rest of your application 29 | .StructureMap(new Container()) 30 | .Bootstrap(); 31 | 32 | // Ensure that no errors occurred during bootstrapping 33 | PackageRegistry.AssertNoFailures(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Web 2 | { 3 | using FubuMVC.Core; 4 | using FubuMVC.Spark; 5 | using FubuContinuationRecipe.Web.Handlers; 6 | using Home = Handlers.Home; 7 | 8 | public class ConfigureFubuMVC : FubuRegistry 9 | { 10 | public ConfigureFubuMVC() 11 | { 12 | // This line turns on the basic diagnostics and request tracing 13 | IncludeDiagnostics(true); 14 | 15 | // We're going to use the handlers convention for this recipe 16 | ApplyHandlerConventions(); 17 | 18 | // We all need a home 19 | Routes.HomeIs(x => x.Execute()); 20 | 21 | // We're using Spark, 'cause it's ace! 22 | this.UseSpark(); 23 | 24 | // Match views to action methods by matching 25 | // on model type, view name, and namespace 26 | Views.TryToAttachWithDefaultConventions(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Content/css/style.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: Consolas, Courier New, Verdana; 4 | font-size: 12px; 5 | } 6 | 7 | a, a:link, a:visited 8 | { 9 | color: Blue; 10 | } 11 | 12 | ul li 13 | { 14 | margin-bottom: 3px; 15 | } 16 | 17 | .formInput 18 | { 19 | margin: 10px; 20 | } 21 | 22 | .formInput label 23 | { 24 | float: left; 25 | width: 170px; 26 | padding-top: 5px; 27 | } 28 | 29 | .formInput p 30 | { 31 | clear: both; 32 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/DeadEnd/DeadEnd.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Dead End 5 | 6 | 7 | You reached a dead-end, but that means it worked! Yippee :-) 8 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/DeadEnd/DeadEndViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Web.Handlers.DeadEnd 2 | { 3 | using System; 4 | 5 | public class DeadEndViewModel 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/DeadEnd/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Web.Handlers.DeadEnd 2 | { 3 | using System; 4 | 5 | public class GetHandler 6 | { 7 | public DeadEndViewModel Execute(DeadEndViewModel model) 8 | { 9 | return new DeadEndViewModel(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/HandlersMarker.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Web.Handlers 2 | { 3 | public class HandlersMarker 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/Home/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | 5 | public class GetHandler 6 | { 7 | public HomeViewModel Execute() 8 | { 9 | return new HomeViewModel(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/Home/Home.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Home 5 | 6 |
7 |
8 |

9 | 10 | 11 | << Enter "REDIRECT" here to proceed elsewhere! 12 |

13 |

14 |

… or …
15 |

16 |

17 | 18 | 19 | << e.g. 404 - Not Found 20 |

21 |
22 | 25 |
26 |
27 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/Home/HomeRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | 5 | public class HomeRequestModel 6 | { 7 | public string RedirectConfirmation { get; set; } 8 | public int StatusCode { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/Home/HomeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | 5 | public class HomeViewModel 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Handlers/Home/PostHandler.cs: -------------------------------------------------------------------------------- 1 | namespace FubuContinuationRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | using DeadEnd = FubuContinuationRecipe.Web.Handlers.DeadEnd; 5 | using FubuMVC.Core.Continuations; 6 | 7 | public class PostHandler 8 | { 9 | public const string RedirectConfirm = @"REDIRECT"; 10 | 11 | public FubuContinuation Execute(HomeRequestModel model) 12 | { 13 | if (model.RedirectConfirmation.Equals(RedirectConfirm, StringComparison.CurrentCultureIgnoreCase)) 14 | { 15 | return FubuContinuation.RedirectTo(x => x.Execute(new DeadEnd.DeadEndViewModel())); 16 | } 17 | 18 | if (model.StatusCode > 0) 19 | { 20 | System.Net.HttpStatusCode httpStatusCode; 21 | 22 | if (!Enum.TryParse(model.StatusCode.ToString(), out httpStatusCode)) 23 | { 24 | throw new ArgumentException("StatusCode not valid"); 25 | } 26 | 27 | if (!Enum.IsDefined(typeof(System.Net.HttpStatusCode), httpStatusCode)) 28 | { 29 | throw new ArgumentException("StatusCode not listed"); 30 | } 31 | 32 | return FubuContinuation.EndWithStatusCode(httpStatusCode); 33 | } 34 | 35 | return FubuContinuation.RedirectTo(x => x.Execute()); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Shared/Application.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | FubuContinuation Recipe 5 | 6 | 7 | 8 |

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Shared/_global.spark: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Shared/bindings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | this.FormFor<@model>().Attr("class", "validate") 4 | this.EndForm() 5 | 6 | this.LabelFor<@model>(m => m.@property) 7 | this.InputFor<@model>(m => m.@property) 8 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.Web/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/FubuContinuationRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FubuContinuationRecipe.Web", "FubuContinuationRecipe.Web\FubuContinuationRecipe.Web.csproj", "{D187E66F-359C-49CB-94C3-3F109CF98A12}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FubuContinuationRecipe.Tests.Unit", "FubuContinuationRecipe.Tests.Unit\FubuContinuationRecipe.Tests.Unit.csproj", "{981C1C1D-DC2B-4271-B05C-559052D84FAA}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Recipe", "Recipe", "{EC0883C4-F5F0-4F22-8094-342E4C8186D8}" 9 | ProjectSection(SolutionItems) = preProject 10 | nuget.config = nuget.config 11 | readme.markdown = readme.markdown 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {D187E66F-359C-49CB-94C3-3F109CF98A12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {D187E66F-359C-49CB-94C3-3F109CF98A12}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {D187E66F-359C-49CB-94C3-3F109CF98A12}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {D187E66F-359C-49CB-94C3-3F109CF98A12}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {981C1C1D-DC2B-4271-B05C-559052D84FAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {981C1C1D-DC2B-4271-B05C-559052D84FAA}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {981C1C1D-DC2B-4271-B05C-559052D84FAA}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {981C1C1D-DC2B-4271-B05C-559052D84FAA}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/Continuations/FubuContinuation/readme.markdown: -------------------------------------------------------------------------------- 1 | 2 | FubuContinuation Recipe 3 | == 4 | This recipe shows how FubuContuation can be used for 302 redirects, or redirection to an Http status code. 5 | 6 | **NOTE!** There is now a new convention named IRedirectable which is worth checking out as it allows guard-style redirects using return (out) model. -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Tests.Unit/Handlers/DeadEnd/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Tests.Unit.Handlers.DeadEnd 2 | { 3 | using NUnit.Framework; 4 | using DeadEnd = IRedirectableRecipe.Web.Handlers.DeadEnd; 5 | 6 | [TestFixture] 7 | public class GetHandlerTests 8 | { 9 | [Test] 10 | public void when_calling_execute_return_is_not_null() 11 | { 12 | var handler = new DeadEnd.GetHandler(); 13 | Assert.IsNotNull(handler.Execute(new DeadEnd.DeadEndViewModel())); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Tests.Unit/Handlers/Home/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Tests.Unit.Handlers.Home 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using Home = IRedirectableRecipe.Web.Handlers.Home; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new Home.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/App_Start/FubuMVC.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Routing; 2 | using Bottles; 3 | using FubuMVC.Core; 4 | using FubuMVC.StructureMap; 5 | using StructureMap; 6 | 7 | // You can remove the reference to WebActivator by calling the Start() method from your Global.asax Application_Start 8 | [assembly: WebActivator.PreApplicationStartMethod(typeof(IRedirectableRecipe.Web.App_Start.AppStartFubuMVC), "Start", callAfterGlobalAppStart: true)] 9 | 10 | namespace IRedirectableRecipe.Web.App_Start 11 | { 12 | public static class AppStartFubuMVC 13 | { 14 | public static void Start() 15 | { 16 | // FubuApplication "guides" the bootstrapping of the FubuMVC 17 | // application 18 | FubuApplication.For() // ConfigureFubuMVC is the main FubuRegistry 19 | // for this application. FubuRegistry classes 20 | // are used to register conventions, policies, 21 | // and various other parts of a FubuMVC application 22 | 23 | 24 | // FubuMVC requires an IoC container for its own internals. 25 | // In this case, we're using a brand new StructureMap container, 26 | // but FubuMVC just adds configuration to an IoC container so 27 | // that you can use the native registration API's for your 28 | // IoC container for the rest of your application 29 | .StructureMap(new Container()) 30 | .Bootstrap(); 31 | 32 | // Ensure that no errors occurred during bootstrapping 33 | PackageRegistry.AssertNoFailures(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Web 2 | { 3 | using FubuMVC.Core; 4 | using FubuMVC.Spark; 5 | using IRedirectableRecipe.Web.Handlers; 6 | using Home = IRedirectableRecipe.Web.Handlers.Home; 7 | 8 | public class ConfigureFubuMVC : FubuRegistry 9 | { 10 | public ConfigureFubuMVC() 11 | { 12 | // This line turns on the basic diagnostics and request tracing 13 | IncludeDiagnostics(true); 14 | 15 | // Let's use the handlers convention, it rocks 16 | ApplyHandlerConventions(); 17 | 18 | // Where is home 19 | Routes.HomeIs(x => x.Execute()); 20 | 21 | // Engage Spark 22 | this.UseSpark(); 23 | 24 | // Match views to action methods by matching 25 | // on model type, view name, and namespace 26 | Views.TryToAttachWithDefaultConventions(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Content/css/style.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: Consolas, Courier New, Verdana; 4 | font-size: 12px; 5 | } 6 | 7 | a, a:link, a:visited 8 | { 9 | color: Blue; 10 | } 11 | 12 | ul li 13 | { 14 | margin-bottom: 3px; 15 | } 16 | 17 | .formInput 18 | { 19 | margin: 10px; 20 | } 21 | 22 | .formInput label 23 | { 24 | float: left; 25 | width: 170px; 26 | padding-top: 5px; 27 | } 28 | 29 | .formInput p 30 | { 31 | clear: both; 32 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/DeadEnd/DeadEnd.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Dead End 5 | 6 | 7 | You reached a dead-end, but that means it worked! Yippee :-) 8 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/DeadEnd/DeadEndViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Web.Handlers.DeadEnd 2 | { 3 | using System; 4 | 5 | public class DeadEndViewModel 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/DeadEnd/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Web.Handlers.DeadEnd 2 | { 3 | using System; 4 | 5 | public class GetHandler 6 | { 7 | public DeadEndViewModel Execute(DeadEndViewModel model) 8 | { 9 | return new DeadEndViewModel(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/HandlersMarker.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Web.Handlers 2 | { 3 | public class HandlersMarker 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/Home/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | 5 | public class GetHandler 6 | { 7 | public HomeViewModel Execute() 8 | { 9 | return new HomeViewModel(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/Home/Home.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Home 5 | 6 |
7 |
8 |

9 | 10 | 11 | << Enter "REDIRECT" here to proceed elsewhere! 12 |

13 |
14 | 17 |
18 |
-------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/Home/HomeRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | 5 | public class HomeRequestModel 6 | { 7 | public string RedirectConfirmation { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/Home/HomeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Web.Handlers.Home 2 | { 3 | using FubuMVC.Core.Continuations; 4 | 5 | public class HomeViewModel : IRedirectable 6 | { 7 | public FubuContinuation RedirectTo { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Handlers/Home/PostHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IRedirectableRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | using IRedirectableRecipe.Web.Handlers.DeadEnd; 5 | using FubuMVC.Core.Continuations; 6 | 7 | public class PostHandler 8 | { 9 | public const string RedirectConfirm = @"REDIRECT"; 10 | 11 | public HomeViewModel Execute(HomeRequestModel model) 12 | { 13 | if (model.RedirectConfirmation.Equals(RedirectConfirm, StringComparison.CurrentCultureIgnoreCase)) 14 | { 15 | return new HomeViewModel() 16 | { 17 | RedirectTo = FubuContinuation.RedirectTo(x => x.Execute(new DeadEndViewModel())) 18 | }; 19 | } 20 | 21 | return new HomeViewModel(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Shared/Application.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | IRedirectable recipe 5 | 6 | 7 | 8 |

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Shared/_global.spark: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Shared/bindings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | this.FormFor<@model>().Attr("class", "validate") 4 | this.EndForm() 5 | 6 | this.LabelFor<@model>(m => m.@property) 7 | this.InputFor<@model>(m => m.@property) 8 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Continuations/IRedirectable/IRedirectableRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Continuations/IRedirectable/IRedirectableRecipe.Web/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.Web/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/IRedirectableRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRedirectableRecipe.Web", "IRedirectableRecipe.Web\IRedirectableRecipe.Web.csproj", "{6B6B504F-2C91-4E17-8F15-2D6FDC124295}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRedirectableRecipe.Tests.Unit", "IRedirectableRecipe.Tests.Unit\IRedirectableRecipe.Tests.Unit.csproj", "{EAC15B3B-89AD-4FF6-8000-74761B7B181F}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Recipe", "Recipe", "{3AE2FB45-DF83-4C69-AFB6-0BD594899AEE}" 9 | ProjectSection(SolutionItems) = preProject 10 | nuget.config = nuget.config 11 | readme.markdown = readme.markdown 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {6B6B504F-2C91-4E17-8F15-2D6FDC124295}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {6B6B504F-2C91-4E17-8F15-2D6FDC124295}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {6B6B504F-2C91-4E17-8F15-2D6FDC124295}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {6B6B504F-2C91-4E17-8F15-2D6FDC124295}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {EAC15B3B-89AD-4FF6-8000-74761B7B181F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {EAC15B3B-89AD-4FF6-8000-74761B7B181F}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {EAC15B3B-89AD-4FF6-8000-74761B7B181F}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {EAC15B3B-89AD-4FF6-8000-74761B7B181F}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/Continuations/IRedirectable/readme.markdown: -------------------------------------------------------------------------------- 1 | 2 | IRedirectable Recipe 3 | == 4 | Using IRedirectable on a ViewModel implements a FubuContinuation as a *property* on the model. Setting this property during your handler/controller causes the behavior chain to automatically jump to the desired new chain. The advantage here is that it allows you to keep your return type as your model opposed to a [standard FubuContinuation](https://github.com/ianbattersby/FubuMVC.Recipes/tree/master/src/Continuations/FubuMVCContinuation). -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Tests.Unit/Handlers/DeadEnd/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Tests.Unit.Handlers.DeadEnd 2 | { 3 | using System; 4 | using FubuMVC.Core.Http; 5 | using Moq; 6 | using NUnit.Framework; 7 | using Home = ICurrentChainRecipe.Web.Handlers.Home; 8 | 9 | [TestFixture] 10 | public class GetHandlerTests 11 | { 12 | private Mock currentChainMock; 13 | private Home.GetHandler handler; 14 | 15 | [SetUp] 16 | public void test_setup() 17 | { 18 | currentChainMock = new Mock(); 19 | currentChainMock.SetupAllProperties(); 20 | 21 | handler = new Home.GetHandler(currentChainMock.Object); 22 | } 23 | 24 | [Test] 25 | public void when_calling_execute_return_is_not_null() 26 | { 27 | var result = handler.Execute(); 28 | Assert.IsNotNull(result); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Tests.Unit/Handlers/Home/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Tests.Unit.Handlers.Home 2 | { 3 | using System; 4 | using FubuMVC.Core.Http; 5 | using Moq; 6 | using NUnit.Framework; 7 | using DeadEnd = ICurrentChainRecipe.Web.Handlers.DeadEnd; 8 | 9 | [TestFixture] 10 | public class GetHandlerTests 11 | { 12 | private Mock currentChainMock; 13 | private DeadEnd.GetHandler handler; 14 | 15 | [SetUp] 16 | public void test_setup() 17 | { 18 | currentChainMock = new Mock(); 19 | currentChainMock.SetupAllProperties(); 20 | 21 | handler = new DeadEnd.GetHandler(currentChainMock.Object); 22 | } 23 | 24 | [Test] 25 | public void when_calling_execute_return_is_not_null() 26 | { 27 | var result = handler.Execute(); 28 | Assert.IsNotNull(result); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Tests.Unit/Handlers/Home/PostHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Tests.Unit.Handlers.Home 2 | { 3 | using System; 4 | using Home = ICurrentChainRecipe.Web.Handlers.Home; 5 | using DeadEnd = ICurrentChainRecipe.Web.Handlers.DeadEnd; 6 | using NUnit.Framework; 7 | 8 | [TestFixture] 9 | public class PostHandlerTests 10 | { 11 | private Home.PostHandler handler; 12 | 13 | [SetUp] 14 | public void test_setup() 15 | { 16 | this.handler = new Home.PostHandler(); 17 | } 18 | 19 | [Test] 20 | public void when_calling_execute_redirects_to_deadend_handler() 21 | { 22 | var result = this.handler.Execute(new Home.HomeRequestModel()); 23 | result.AssertWasRedirectedTo(x => x.Execute()); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/App_Start/FubuMVC.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Routing; 2 | using Bottles; 3 | using FubuMVC.Core; 4 | using FubuMVC.StructureMap; 5 | using StructureMap; 6 | 7 | // You can remove the reference to WebActivator by calling the Start() method from your Global.asax Application_Start 8 | [assembly: WebActivator.PreApplicationStartMethod(typeof(ICurrentChainRecipe.Web.App_Start.AppStartFubuMVC), "Start", callAfterGlobalAppStart: true)] 9 | 10 | namespace ICurrentChainRecipe.Web.App_Start 11 | { 12 | public static class AppStartFubuMVC 13 | { 14 | public static void Start() 15 | { 16 | // FubuApplication "guides" the bootstrapping of the FubuMVC 17 | // application 18 | FubuApplication.For() // ConfigureFubuMVC is the main FubuRegistry 19 | // for this application. FubuRegistry classes 20 | // are used to register conventions, policies, 21 | // and various other parts of a FubuMVC application 22 | 23 | 24 | // FubuMVC requires an IoC container for its own internals. 25 | // In this case, we're using a brand new StructureMap container, 26 | // but FubuMVC just adds configuration to an IoC container so 27 | // that you can use the native registration API's for your 28 | // IoC container for the rest of your application 29 | .StructureMap(new Container()) 30 | .Bootstrap(); 31 | 32 | // Ensure that no errors occurred during bootstrapping 33 | PackageRegistry.AssertNoFailures(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web 2 | { 3 | using FubuMVC.Core; 4 | using FubuMVC.Spark; 5 | using ICurrentChainRecipe.Web.Handlers; 6 | using Home = Handlers.Home; 7 | 8 | public class ConfigureFubuMVC : FubuRegistry 9 | { 10 | public ConfigureFubuMVC() 11 | { 12 | // This line turns on the basic diagnostics and request tracing 13 | IncludeDiagnostics(true); 14 | 15 | // Let's use the handlers convention 16 | ApplyHandlerConventions(); 17 | 18 | // Set the home/default page 19 | Routes.HomeIs(x => x.Execute()); 20 | 21 | // Let's use Spark view engine 22 | this.UseSpark(); 23 | 24 | // Match views to action methods by matching 25 | // on model type, view name, and namespace 26 | Views.TryToAttachWithDefaultConventions(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Content/css/style.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: Consolas, Courier New, Verdana; 4 | font-size: 12px; 5 | } 6 | 7 | a, a:link, a:visited 8 | { 9 | color: Blue; 10 | } 11 | 12 | ul li 13 | { 14 | margin-bottom: 3px; 15 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/CommonViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Handlers 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class CommonViewModel 6 | { 7 | public string Id { get; set; } 8 | public string RouteDefinition { get; set; } 9 | public IList Calls { get; set; } 10 | public IList Outputs { get; set; } 11 | public IList Filters { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/DeadEnd/DeadEnd.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Dead End 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/DeadEnd/DeadEndViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Handlers.DeadEnd 2 | { 3 | public class DeadEndViewModel : CommonViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/DeadEnd/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Handlers.DeadEnd 2 | { 3 | using System.Collections.Generic; 4 | using FubuMVC.Core.Http; 5 | using ICurrentChainRecipe.Web.Helpers; 6 | 7 | public class GetHandler 8 | { 9 | ICurrentChain currentChain; 10 | 11 | public GetHandler(ICurrentChain currentChain) 12 | { 13 | this.currentChain = currentChain; 14 | } 15 | 16 | public DeadEndViewModel Execute() 17 | { 18 | var model = new DeadEndViewModel() 19 | { 20 | Calls = new List(), 21 | Outputs = new List(), 22 | Filters = new List() 23 | }; 24 | 25 | if (currentChain.Current != null) 26 | { 27 | ViewModelHelper.PopulateModelWithChain(currentChain.Current, model); 28 | } 29 | 30 | return model; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/HandlersMarker.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Handlers 2 | { 3 | public class HandlersMarker 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/Home/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using FubuMVC.Core.Http; 6 | using ICurrentChainRecipe.Web.Helpers; 7 | 8 | public class GetHandler 9 | { 10 | ICurrentChain currentChain; 11 | 12 | public GetHandler(ICurrentChain currentChain) 13 | { 14 | this.currentChain = currentChain; 15 | } 16 | 17 | public HomeViewModel Execute() 18 | { 19 | var homeModel = new HomeViewModel() 20 | { 21 | Calls = new List(), 22 | Outputs = new List(), 23 | Filters = new List() 24 | }; 25 | 26 | if (currentChain.Current != null) 27 | { 28 | ViewModelHelper.PopulateModelWithChain(currentChain.Current, homeModel); 29 | } 30 | 31 | return homeModel; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/Home/Home.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Home 5 | 6 | 7 | 8 |
9 | 12 |
13 |
14 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/Home/HomeRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Handlers.Home 2 | { 3 | public class HomeRequestModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/Home/HomeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Handlers.Home 2 | { 3 | public class HomeViewModel : CommonViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Handlers/Home/PostHandler.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | using FubuMVC.Core.Continuations; 5 | using DeadEnd = Handlers.DeadEnd; 6 | 7 | public class PostHandler 8 | { 9 | public FubuContinuation Execute(HomeRequestModel model) 10 | { 11 | return FubuContinuation.RedirectTo(x => x.Execute()); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Helpers/ViewModelHelper.cs: -------------------------------------------------------------------------------- 1 | namespace ICurrentChainRecipe.Web.Helpers 2 | { 3 | using System; 4 | using FubuMVC.Core.Registration.Nodes; 5 | using ICurrentChainRecipe.Web.Handlers; 6 | 7 | public static class ViewModelHelper 8 | { 9 | public static void PopulateModelWithChain(BehaviorChain chain, CommonViewModel model) 10 | { 11 | model.Id = chain.UniqueId.ToString(); 12 | model.RouteDefinition = chain.Route.ToString(); 13 | 14 | foreach (var call in chain.Calls) 15 | { 16 | model.Calls.Add(call.ToString()); 17 | } 18 | 19 | foreach (var output in chain.Outputs) 20 | { 21 | model.Outputs.Add(output.ToString()); 22 | } 23 | 24 | foreach (var filter in chain.Filters) 25 | { 26 | model.Filters.Add(filter.ToString()); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Shared/Application.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ICurrentChain Recipe 5 | 6 | 7 | 8 |

9 | 10 |

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Shared/ChainInfo.spark: -------------------------------------------------------------------------------- 1 | 

Unique Identifier

2 | ${Model.Id} 3 | 4 |

Route Definition

5 | ${Model.RouteDefinition} 6 | 7 |

Calls

8 |

None

9 | 10 |

${c}

11 |
12 | 13 |

Outputs

14 |

None

15 | 16 |

${a}

17 |
18 | 19 |

Filters

20 |

None

21 | 22 |

${f}

23 |
-------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Shared/_global.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Shared/bindings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | this.FormFor<@model>().Attr("class", "validate") 4 | this.EndForm() 5 | 6 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Http/ICurrentChain/ICurrentChainRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Http/ICurrentChain/ICurrentChainRecipe.Web/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.Web/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/ICurrentChainRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICurrentChainRecipe.Web", "ICurrentChainRecipe.Web\ICurrentChainRecipe.Web.csproj", "{7EE941C1-E117-43E9-871D-C46C33A296B2}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICurrentChainRecipe.Tests.Unit", "ICurrentChainRecipe.Tests.Unit\ICurrentChainRecipe.Tests.Unit.csproj", "{69EDB439-3963-4C79-ADBA-7A1E9A1EC50F}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Recipe", "Recipe", "{670587D0-2125-44D3-B4B1-58A4B84FBD3B}" 9 | ProjectSection(SolutionItems) = preProject 10 | nuget.config = nuget.config 11 | readme.markdown = readme.markdown 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {7EE941C1-E117-43E9-871D-C46C33A296B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {7EE941C1-E117-43E9-871D-C46C33A296B2}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {7EE941C1-E117-43E9-871D-C46C33A296B2}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {7EE941C1-E117-43E9-871D-C46C33A296B2}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {69EDB439-3963-4C79-ADBA-7A1E9A1EC50F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {69EDB439-3963-4C79-ADBA-7A1E9A1EC50F}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {69EDB439-3963-4C79-ADBA-7A1E9A1EC50F}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {69EDB439-3963-4C79-ADBA-7A1E9A1EC50F}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/Http/ICurrentChain/readme.markdown: -------------------------------------------------------------------------------- 1 | 2 | ICurrentChain Recipe 3 | == 4 | This recipe demonstrates possible usage of ICurrentChain, which when injected through contruction will give you access to the properties of the current behavior chain. -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DownloadStreamRecipe", "DownloadStreamRecipe\DownloadStreamRecipe.csproj", "{89CF8BEF-20B9-4A07-B186-F965A15143E1}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {89CF8BEF-20B9-4A07-B186-F965A15143E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {89CF8BEF-20B9-4A07-B186-F965A15143E1}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {89CF8BEF-20B9-4A07-B186-F965A15143E1}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {89CF8BEF-20B9-4A07-B186-F965A15143E1}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/App_Start/FubuMVC.cs: -------------------------------------------------------------------------------- 1 | 2 | // You can remove the reference to WebActivator by calling the Start() method from your Global.asax Application_Start 3 | [assembly: WebActivator.PreApplicationStartMethod(typeof(DownloadStreamRecipe.App_Start.AppStartFubuMVC), "Start", callAfterGlobalAppStart: true)] 4 | 5 | namespace DownloadStreamRecipe.App_Start 6 | { 7 | using System.Web.Routing; 8 | using Bottles; 9 | using FubuMVC.Core; 10 | using FubuMVC.StructureMap; 11 | using StructureMap; 12 | 13 | public static class AppStartFubuMVC 14 | { 15 | public static void Start() 16 | { 17 | // FubuApplication "guides" the bootstrapping of the FubuMVC 18 | // application 19 | FubuApplication.For() // ConfigureFubuMVC is the main FubuRegistry 20 | // for this application. FubuRegistry classes 21 | // are used to register conventions, policies, 22 | // and various other parts of a FubuMVC application 23 | 24 | 25 | // FubuMVC requires an IoC container for its own internals. 26 | // In this case, we're using a brand new StructureMap container, 27 | // but FubuMVC just adds configuration to an IoC container so 28 | // that you can use the native registration API's for your 29 | // IoC container for the rest of your application 30 | .StructureMap(new Container()) 31 | .Bootstrap(); 32 | 33 | // Ensure that no errors occurred during bootstrapping 34 | PackageRegistry.AssertNoFailures(); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/Assets/desert.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Other/DownloadStream/DownloadStreamRecipe/Assets/desert.jpg -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/Assets/hola.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Other/DownloadStream/DownloadStreamRecipe/Assets/hola.pdf -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | namespace DownloadStreamRecipe 2 | { 3 | using DownloadStreamRecipe.Controllers; 4 | using FubuMVC.Core; 5 | using FubuMVC.Core.Registration.Conventions; 6 | 7 | public class ConfigureFubuMVC : FubuRegistry 8 | { 9 | public ConfigureFubuMVC() 10 | { 11 | // This line turns on the basic diagnostics and request tracing 12 | IncludeDiagnostics(true); 13 | 14 | ApplyConvention(); 15 | 16 | // All public methods from concrete classes ending in "Controller" 17 | // in this assembly are assumed to be action methods 18 | Actions.IncludeClassesSuffixedWithController(); 19 | 20 | // Policies 21 | Routes 22 | .HomeIs(home => home.Index()) 23 | .IgnoreControllerNamespaceEntirely() 24 | .IgnoreMethodSuffix("Html") 25 | .RootAtAssemblyNamespace(); 26 | 27 | // Match views to action methods by matching 28 | // on model type, view name, and namespace 29 | Views.TryToAttachWithDefaultConventions(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | namespace DownloadStreamRecipe.Controllers 2 | { 3 | using HtmlTags; 4 | 5 | public class HomeController 6 | { 7 | public HtmlDocument Index() 8 | { 9 | var document = new HtmlDocument 10 | { Title = "How to use DownloadFileModel class to stream and download assets" }; 11 | 12 | document.Body.Add("h1").Text("Using DownloadFileModel class to stream and download assets"); 13 | 14 | LinkTag streamPdf = new LinkTag("Stream PDF to browser", "pdf/stream"); 15 | LinkTag downloadPdf = new LinkTag("Force browser to open dialog for download PDF", "pdf/download"); 16 | LinkTag streamJpeg = new LinkTag("Stream JPEG to browser", "jpeg/stream"); 17 | 18 | document.Body.Append(streamPdf).Add("br"); 19 | document.Body.Append(downloadPdf).Add("br"); 20 | document.Body.Append(streamJpeg).Add("br"); 21 | 22 | return document; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/Controllers/JpegController.cs: -------------------------------------------------------------------------------- 1 | namespace DownloadStreamRecipe.Controllers 2 | { 3 | using System.Web; 4 | using FubuMVC.Core.Behaviors; 5 | 6 | public class JpegController 7 | { 8 | public DownloadFileModel Stream() 9 | { 10 | return new DownloadFileModel 11 | { 12 | ContentType = "image/jpeg", 13 | LocalFileName = HttpContext.Current.Server.MapPath("~/Assets/desert.jpg") 14 | }; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/Controllers/PdfController.cs: -------------------------------------------------------------------------------- 1 | namespace DownloadStreamRecipe.Controllers 2 | { 3 | using System.Web; 4 | 5 | using FubuMVC.Core.Behaviors; 6 | 7 | public class PdfController 8 | { 9 | public DownloadFileModel Stream() 10 | { 11 | return new DownloadFileModel 12 | { 13 | ContentType = "application/pdf", 14 | LocalFileName = HttpContext.Current.Server.MapPath("~/Assets/hola.pdf") 15 | }; 16 | } 17 | 18 | public DownloadFileModel Download() 19 | { 20 | return new DownloadFileModel 21 | { 22 | ContentType = "application/pdf", 23 | FileNameToDisplay = "hola.pdf", 24 | LocalFileName = HttpContext.Current.Server.MapPath("~/Assets/hola.pdf") 25 | }; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Other/DownloadStream/DownloadStreamRecipe/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Other/DownloadStream/DownloadStreamRecipe/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/Other/DownloadStream/DownloadStreamRecipe/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Other/DownloadStream/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/Account/LogOn/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.Account.LogOn 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using LogOn = IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new LogOn.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/Account/LogOut/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.Account.LogOut 2 | { 3 | using System; 4 | using FubuMVC.Core.Security; 5 | using Moq; 6 | using NUnit.Framework; 7 | using LogOn = IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn; 8 | using LogOut = IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOut; 9 | 10 | [TestFixture] 11 | public class GetHandlerTests 12 | { 13 | private LogOut.GetHandler handler; 14 | private Mock authContextMock; 15 | 16 | [SetUp] 17 | public void test_setup() 18 | { 19 | this.authContextMock = new Mock(); 20 | this.authContextMock.Setup(x => x.SignOut()); 21 | 22 | this.handler = new LogOut.GetHandler(authContextMock.Object); 23 | } 24 | 25 | [Test] 26 | public void when_calling_execute_calls_authcontext() 27 | { 28 | var result = handler.Execute(new LogOut.LogOutRequestModel()); 29 | authContextMock.Verify(x => x.SignOut(), Times.Once()); 30 | } 31 | 32 | [Test] 33 | public void when_calling_execute_returns_fubucontinuation() 34 | { 35 | var result = handler.Execute(new LogOut.LogOutRequestModel()); 36 | result.AssertWasRedirectedTo(x=>x.Execute()); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/AdvSectionMaps/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.AdvSectionMaps 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using AdvSectionMaps = IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionMaps; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new AdvSectionMaps.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/AdvSectionOne/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.AdvSectionOne 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using AdvSectionOne = IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionOne; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new AdvSectionOne.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/Home/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.Home 2 | { 3 | using System; 4 | using Home = IAuthorizationPolicyRecipe.Web.Handlers.Home; 5 | using NUnit.Framework; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new Home.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/App_Start/FubuMVC.cs: -------------------------------------------------------------------------------- 1 | using IAuthorizationPolicyRecipe.Web.Security; 2 | using Bottles; 3 | using FubuMVC.Core; 4 | using FubuMVC.StructureMap; 5 | 6 | // You can remove the reference to WebActivator by calling the Start() method from your Global.asax Application_Start 7 | [assembly: WebActivator.PreApplicationStartMethod(typeof(IAuthorizationPolicyRecipe.Web.App_Start.AppStartFubuMVC), "Start", callAfterGlobalAppStart: true)] 8 | 9 | namespace IAuthorizationPolicyRecipe.Web.App_Start 10 | { 11 | public static class AppStartFubuMVC 12 | { 13 | public static void Start() 14 | { 15 | // FubuApplication "guides" the bootstrapping of the FubuMVC 16 | // application 17 | FubuApplication.For() // ConfigureFubuMVC is the main FubuRegistry 18 | // for this application. FubuRegistry classes 19 | // are used to register conventions, policies, 20 | // and various other parts of a FubuMVC application 21 | 22 | 23 | // FubuMVC requires an IoC container for its own internals. 24 | // In this case, we're using a brand new StructureMap container, 25 | // but FubuMVC just adds configuration to an IoC container so 26 | // that you can use the native registration API's for your 27 | // IoC container for the rest of your application 28 | .StructureMapObjectFactory(sof => 29 | { 30 | sof.AddRegistry(); 31 | }) 32 | .Bootstrap(); 33 | 34 | // Ensure that no errors occurred during bootstrapping 35 | PackageRegistry.AssertNoFailures(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web 2 | { 3 | using FubuMVC.Core; 4 | using FubuMVC.Spark; 5 | using IAuthorizationPolicyRecipe.Web.Handlers; 6 | using Home = Handlers.Home; 7 | 8 | public class ConfigureFubuMVC : FubuRegistry 9 | { 10 | public ConfigureFubuMVC() 11 | { 12 | // This line turns on the basic diagnostics and request tracing 13 | IncludeDiagnostics(true); 14 | 15 | // Apply handler convention for EndPoints in HandlersMarker namespace root 16 | ApplyHandlerConventions(); 17 | 18 | // All public methods from concrete classes ending in "Controller" 19 | // in this assembly are assumed to be action methods 20 | Actions.IncludeClassesSuffixedWithController(); 21 | 22 | // Set the home page 23 | Routes.HomeIs(x => x.Execute()); 24 | 25 | // Let's use the wonderful Spark 26 | this.UseSpark(); 27 | 28 | // Match views to action methods by matching 29 | // on model type, view name, and namespace 30 | Views.TryToAttachWithDefaultConventions(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Content/css/style.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: Consolas, Courier New, Verdana; 4 | font-size: 12px; 5 | } 6 | 7 | a, a:link, a:visited 8 | { 9 | color: Blue; 10 | } 11 | 12 | ul li 13 | { 14 | margin-bottom: 3px; 15 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn 2 | { 3 | using System; 4 | 5 | public class GetHandler 6 | { 7 | public LogOnViewModel Execute() 8 | { 9 | return new LogOnViewModel(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/LogOn.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Log On 5 | 6 | 7 |

You can log into this recipe with any user/password combination below, access is based on:

8 |
    9 |
  • BasicUser + <any password> Can access the system with basic privileges
  • 10 |
  • AdvUser + <any password> Has advanced privileges and access to advanced sections
  • 11 |
  • MapsUser + <any password> Is an advanced user who also access to the maps section
  • 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
-------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/LogOnRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn 2 | { 3 | public class LogOnRequestModel 4 | { 5 | public string Name { get; set; } 6 | public string Password { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/LogOnViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn 2 | { 3 | public class LogOnViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/PostHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn 2 | { 3 | using System; 4 | using System.Linq; 5 | using System.Web.Security; 6 | using FubuMVC.Core.Continuations; 7 | using FubuMVC.Core.Security; 8 | using Security; 9 | using Home = Handlers.Home; 10 | 11 | public class PostHandler 12 | { 13 | private readonly IUserData userData; 14 | private readonly IAuthenticationContext authContext; 15 | 16 | public PostHandler( 17 | IAuthenticationContext authContext, 18 | IUserData userdata) 19 | { 20 | this.authContext = authContext; 21 | this.userData = userdata; 22 | } 23 | 24 | public FubuContinuation Execute(LogOnRequestModel model) 25 | { 26 | if (!String.IsNullOrWhiteSpace(model.Name) && !String.IsNullOrWhiteSpace(model.Password)) 27 | { 28 | var username= model.Name.Trim(); 29 | 30 | authContext.ThisUserHasBeenAuthenticated(username, false); 31 | 32 | if (userData.AllowedGroups.ContainsKey(username)) 33 | { 34 | Roles.AddUserToRoles(username, userData.AllowedGroups[username].ToArray()); 35 | } 36 | 37 | // TODO: We should be able to redirect based on ViewModel-In, but 38 | // FubuContinuation assetions don't like. Must investigate! 39 | return FubuContinuation.RedirectTo(x => x.Execute()); 40 | } 41 | 42 | return FubuContinuation.RedirectTo(x => x.Execute()); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOut/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOut 2 | { 3 | using System; 4 | using FubuMVC.Core.Continuations; 5 | using FubuMVC.Core.Security; 6 | 7 | public class GetHandler 8 | { 9 | private readonly IAuthenticationContext authContext; 10 | 11 | public GetHandler(IAuthenticationContext authContext) 12 | { 13 | this.authContext = authContext; ; 14 | } 15 | 16 | public FubuContinuation Execute(LogOutRequestModel model) 17 | { 18 | authContext.SignOut(); 19 | 20 | return FubuContinuation.RedirectTo(x => x.Execute()); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOut/LogOutRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOut 2 | { 3 | using FubuMVC.Core.Security; 4 | using Security; 5 | 6 | [AllowRole(RoleReference.Basic)] 7 | public class LogOutRequestModel 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionMaps/AdvSectionMaps.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Maps 5 | 6 | 7 |

8 | This is the maps area, you must be in the 'Maps' role to access it. 9 |

10 |
-------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionMaps/AdvSectionMapsViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionMaps 2 | { 3 | public class AdvSectionMapsViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionMaps/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionMaps 2 | { 3 | using System; 4 | using FubuMVC.Core.Security; 5 | using Security; 6 | 7 | [AllowRole(RoleReference.Maps)] 8 | public class GetHandler 9 | { 10 | public AdvSectionMapsViewModel Execute() 11 | { 12 | return new AdvSectionMapsViewModel(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionOne/AdvSectionOne.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Advanced Area 5 | 6 | 7 |

8 | This is the advanced area, you must be in the Advanced role to access it. 9 |

10 |
11 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionOne/AdvSectionOneViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionOne 2 | { 3 | public class AdvSectionOneViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionOne/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionOne 2 | { 3 | using System; 4 | using FubuMVC.Core.Security; 5 | using Security; 6 | 7 | [AllowRole(RoleReference.Advanced)] 8 | public class GetHandler 9 | { 10 | public AdvSectionOneViewModel Execute() 11 | { 12 | return new AdvSectionOneViewModel(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/HandlersMarker.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers 2 | { 3 | public class HandlersMarker 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Home/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | using FubuMVC.Core.Security; 5 | using Security; 6 | 7 | [AllowRole(RoleReference.Basic)] 8 | public class GetHandler 9 | { 10 | public HomeViewModel Execute() 11 | { 12 | return new HomeViewModel(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Home/Home.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Home 5 | 6 | 7 |
    8 |
  • 9 | Section One (Advanced role required) 10 |
  • 11 |
  • 12 | Maps (Maps role required) 13 |
  • 14 |
  • 15 | Log out (Basic role required) 16 |
  • 17 |
18 |
-------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Home/HomeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Home 2 | { 3 | public class HomeViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/IRoleStore.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public interface IRoleStore 7 | { 8 | void AddRole(string username, params string[] roles); 9 | void ClearRoles(string username); 10 | void DeleteRole(string username, params string[] roles); 11 | bool IsUserInRole(string username, string role); 12 | IEnumerable GetUserRoles(string username); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/IUserData.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public interface IUserData 7 | { 8 | IDictionary> AllowedGroups { get; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/RoleReference.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | public static class RoleReference 4 | { 5 | /// Access to the basic site (e.g. Home page). 6 | public const string Basic = "BASIC_ACCESS"; 7 | 8 | /// Access to areas of the site classed as advanced. 9 | public const string Advanced = "ADVANCED_ACCESS"; 10 | 11 | /// Access to the dummy 'maps' section. 12 | public const string Maps = "MAPS_ACCESS"; 13 | } 14 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/SecurityRegistry.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using StructureMap.Configuration.DSL; 6 | 7 | public class SecurityRegistry : Registry 8 | { 9 | public SecurityRegistry() 10 | { 11 | // Believe it or not ASP.NET does not ship with an in-memory role provider, so 12 | // here's one I rolled earlier. 13 | For() 14 | .Singleton() 15 | .Use(); 16 | 17 | // This would most likely be a repository pattern or similar, but hey - hacky hacky! 18 | For() 19 | .Use((context) => 20 | { 21 | return new UserData( 22 | new Dictionary>() 23 | { 24 | {"BasicUser", new string[] { RoleReference.Basic } }, 25 | {"AdvUser", new string[] { RoleReference.Basic, RoleReference.Advanced } }, 26 | {"MapsUser", new string[] { RoleReference.Basic, RoleReference.Advanced, RoleReference.Maps } } 27 | }); 28 | }); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/UserData.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public class UserData : IUserData 7 | { 8 | public UserData(IDictionary> allowedGroups) 9 | { 10 | this.AllowedGroups = allowedGroups; 11 | } 12 | 13 | public IDictionary> AllowedGroups { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Shared/Application.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | IAuthorizationPolicyRecipe Recipe 5 | 6 | 7 | 8 |

9 | 10 |

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Shared/_global.spark: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/IAuthorizationPolicyRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IAuthorizationPolicyRecipe.Web", "IAuthorizationPolicyRecipe.Web\IAuthorizationPolicyRecipe.Web.csproj", "{096F8CED-3903-4E03-A025-FC370D8FE2FD}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IAuthorizationPolicyRecipe.Tests.Unit", "IAuthorizationPolicyRecipe.Tests.Unit\IAuthorizationPolicyRecipe.Tests.Unit.csproj", "{F6344C26-99B4-486F-B41D-CD13ABF3A57F}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Recipe", "Recipe", "{E9AAB642-DCC2-4D13-A18A-A7BF5F2B7741}" 9 | ProjectSection(SolutionItems) = preProject 10 | nuget.config = nuget.config 11 | readme.markdown = readme.markdown 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {096F8CED-3903-4E03-A025-FC370D8FE2FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {096F8CED-3903-4E03-A025-FC370D8FE2FD}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {096F8CED-3903-4E03-A025-FC370D8FE2FD}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {096F8CED-3903-4E03-A025-FC370D8FE2FD}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {F6344C26-99B4-486F-B41D-CD13ABF3A57F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {F6344C26-99B4-486F-B41D-CD13ABF3A57F}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {F6344C26-99B4-486F-B41D-CD13ABF3A57F}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {F6344C26-99B4-486F-B41D-CD13ABF3A57F}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/Security/BasicIAuthorizationPolicy/readme.markdown: -------------------------------------------------------------------------------- 1 | 2 | Basic IAuthorizationPolicy Recipe 3 | == 4 | FubuMVC includes a base Authorization policy that aligns itself with the ASP.NET authentication provider, it is therefore possible to implement role-based access control based on input-model using this method. Personally I avoid using any ASP.NET components whenever possible preferring to write my own, but this is a good quick-starter if you are use to this method already. 5 | 6 | **NOTE!** Whilst writing this recipe I discovered there was no ASP.NET in-memory roles provider so I had to knock one up, obviously this is not for production use ;-) -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/Account/LogOn/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.Account.LogOn 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using LogOn = IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new LogOn.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/Account/LogOut/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.Account.LogOut 2 | { 3 | using System; 4 | using IAuthorizationPolicyRecipe.Web.Security; 5 | using Moq; 6 | using NUnit.Framework; 7 | using LogOn = IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn; 8 | using LogOut = IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOut; 9 | 10 | [TestFixture] 11 | public class GetHandlerTests 12 | { 13 | private LogOut.GetHandler handler; 14 | private Mock formsAuthenticationMock; 15 | 16 | [SetUp] 17 | public void test_setup() 18 | { 19 | this.formsAuthenticationMock = new Mock(); 20 | this.formsAuthenticationMock.Setup(x => x.SignOut()); 21 | 22 | this.handler = new LogOut.GetHandler(formsAuthenticationMock.Object); 23 | } 24 | 25 | [Test] 26 | public void when_calling_execute_calls_formsauth() 27 | { 28 | var result = handler.Execute(); 29 | formsAuthenticationMock.Verify(x => x.SignOut(), Times.Once()); 30 | } 31 | 32 | [Test] 33 | public void when_calling_execute_returns_fubucontinuation() 34 | { 35 | var result = handler.Execute(); 36 | result.AssertWasRedirectedTo(x=>x.Execute()); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/AdvSectionMaps/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.AdvSectionMaps 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using AdvSectionMaps = IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionMaps; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new AdvSectionMaps.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/AdvSectionOne/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.AdvSectionOne 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using AdvSectionOne = IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionOne; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new AdvSectionOne.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Handlers/Home/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Handlers.Home 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using Home = IAuthorizationPolicyRecipe.Web.Handlers.Home; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new Home.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/Security/AccessGroupAttributeTests.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Tests.Unit.Security 2 | { 3 | using System; 4 | using System.Linq; 5 | using IAuthorizationPolicyRecipe.Web.Security; 6 | using NUnit.Framework; 7 | 8 | [TestFixture] 9 | public class AccessGroupAttributeTests 10 | { 11 | [Test] 12 | public void when_creating_attribute_with_no_groups_has_no_groups() 13 | { 14 | var attr = new AccessGroupAttribute(); 15 | Assert.AreEqual(0, attr.Groups.Count()); 16 | } 17 | 18 | [Test] 19 | public void when_creating_attribute_with_groups_has_all_groups() 20 | { 21 | var attr = new AccessGroupAttribute("GroupOne", "GroupTwo", "GroupThree"); 22 | Assert.AreEqual(3, attr.Groups.Count()); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/App_Start/FubuMVC.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Routing; 2 | using Bottles; 3 | using FubuMVC.Core; 4 | using FubuMVC.StructureMap; 5 | using StructureMap; 6 | using IAuthorizationPolicyRecipe.Web.Security; 7 | 8 | // You can remove the reference to WebActivator by calling the Start() method from your Global.asax Application_Start 9 | [assembly: WebActivator.PreApplicationStartMethod(typeof(IAuthorizationPolicyRecipe.Web.App_Start.AppStartFubuMVC), "Start", callAfterGlobalAppStart: true)] 10 | 11 | namespace IAuthorizationPolicyRecipe.Web.App_Start 12 | { 13 | public static class AppStartFubuMVC 14 | { 15 | public static void Start() 16 | { 17 | // FubuApplication "guides" the bootstrapping of the FubuMVC 18 | // application 19 | FubuApplication.For() // ConfigureFubuMVC is the main FubuRegistry 20 | // for this application. FubuRegistry classes 21 | // are used to register conventions, policies, 22 | // and various other parts of a FubuMVC application 23 | 24 | 25 | // FubuMVC requires an IoC container for its own internals. 26 | // In this case, we're using a brand new StructureMap container, 27 | // but FubuMVC just adds configuration to an IoC container so 28 | // that you can use the native registration API's for your 29 | // IoC container for the rest of your application 30 | .StructureMapObjectFactory(sof => 31 | { 32 | // We need to add out own registry for IFormsAuthenticationWrapper 33 | sof.AddRegistry(); 34 | }) 35 | .Bootstrap(); 36 | 37 | // Ensure that no errors occurred during bootstrapping 38 | PackageRegistry.AssertNoFailures(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web 2 | { 3 | using FubuMVC.Core; 4 | using FubuMVC.Spark; 5 | using Handlers; 6 | using Security; 7 | using Home = Handlers.Home; 8 | 9 | public class ConfigureFubuMVC : FubuRegistry 10 | { 11 | public ConfigureFubuMVC() 12 | { 13 | // This line turns on the basic diagnostics and request tracing 14 | IncludeDiagnostics(true); 15 | 16 | // Apply handler convention for EndPoints in HandlersMarker namespace root 17 | ApplyHandlerConventions(); 18 | 19 | // Let's add out custom security policy 20 | Policies.Add(); 21 | 22 | // Set the home page 23 | Routes.HomeIs(x=>x.Execute()); 24 | 25 | // Let's use the wonderful Spark 26 | this.UseSpark(); 27 | 28 | // Match views to action methods by matching 29 | // on model type, view name, and namespace 30 | Views.TryToAttachWithDefaultConventions(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Content/css/style.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: Consolas, Courier New, Verdana; 4 | font-size: 12px; 5 | } 6 | 7 | a, a:link, a:visited 8 | { 9 | color: Blue; 10 | } 11 | 12 | ul li 13 | { 14 | margin-bottom: 3px; 15 | } 16 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn 2 | { 3 | using System; 4 | using Security; 5 | 6 | [AccessGroup()] 7 | public class GetHandler 8 | { 9 | public LogOnViewModel Execute() 10 | { 11 | return new LogOnViewModel(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/LogOn.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Log On 5 | 6 | 7 |

You can log into this recipe with any user/password combination below, access is based on:

8 |
    9 |
  • BasicUser + <any password> Can access the system with basic privileges
  • 10 |
  • AdvUser + <any password> Has advanced privileges and access to advanced sections
  • 11 |
  • MapsUser + <any password> Is an advanced user who also access to the maps section
  • 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
-------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/LogOnRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn 2 | { 3 | public class LogOnRequestModel 4 | { 5 | public string Name { get; set; } 6 | public string Password { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/LogOnViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn 2 | { 3 | public class LogOnViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOn/PostHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOn 2 | { 3 | using System; 4 | using FubuMVC.Core.Continuations; 5 | using Security; 6 | using Home = Handlers.Home; 7 | using System.Web.Security; 8 | 9 | [AccessGroup] 10 | public class PostHandler 11 | { 12 | private readonly IFormsAuthenticationWrapper formsAuthenticationWrapper; 13 | 14 | public PostHandler(IFormsAuthenticationWrapper formsAuthenticationWrapper) 15 | { 16 | this.formsAuthenticationWrapper = formsAuthenticationWrapper; 17 | } 18 | 19 | public FubuContinuation Execute(LogOnRequestModel model) 20 | { 21 | if (!String.IsNullOrWhiteSpace(model.Name) && !String.IsNullOrWhiteSpace(model.Password)) 22 | { 23 | formsAuthenticationWrapper.SetAuthCookie(model.Name.Trim(), false); 24 | 25 | // TODO: We should be able to redirect based on ViewModel-In, but 26 | // FubuContinuation assetions don't like. Must investigate! 27 | return FubuContinuation.RedirectTo(x => x.Execute()); 28 | } 29 | 30 | return FubuContinuation.RedirectTo(x => x.Execute()); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Account/LogOut/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Account.LogOut 2 | { 3 | using System; 4 | using FubuMVC.Core.Continuations; 5 | using Security; 6 | 7 | [AccessGroup(AccessGroupReference.Basic)] 8 | public class GetHandler 9 | { 10 | private readonly IFormsAuthenticationWrapper formsAuthenticationWrapper; 11 | 12 | public GetHandler(IFormsAuthenticationWrapper formsAuthenticationWrapper) 13 | { 14 | this.formsAuthenticationWrapper = formsAuthenticationWrapper; 15 | } 16 | 17 | public FubuContinuation Execute() 18 | { 19 | formsAuthenticationWrapper.SignOut(); 20 | 21 | return FubuContinuation.RedirectTo(x => x.Execute()); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionMaps/AdvSectionMaps.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Maps 5 | 6 | 7 |

8 | This is the maps area, you must be in the AccessGroupReference.Advanced & AccessGroupReference.Maps group to access it. 9 |

10 |
-------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionMaps/AdvSectionMapsViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionMaps 2 | { 3 | public class AdvSectionMapsViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionMaps/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionMaps 2 | { 3 | using System; 4 | using Security; 5 | 6 | [AccessGroup(AccessGroupReference.Advanced, AccessGroupReference.Maps)] 7 | public class GetHandler 8 | { 9 | public AdvSectionMapsViewModel Execute() 10 | { 11 | return new AdvSectionMapsViewModel(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionOne/AdvSectionOne.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Advanced Area 5 | 6 | 7 |

8 | This is the advanced area, you must be in the AccessGroupReference.Advanced group to access it. 9 |

10 |
11 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionOne/AdvSectionOneViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionOne 2 | { 3 | public class AdvSectionOneViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/AdvSectionOne/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.AdvSectionOne 2 | { 3 | using System; 4 | using Security; 5 | 6 | [AccessGroup(AccessGroupReference.Advanced)] 7 | public class GetHandler 8 | { 9 | public AdvSectionOneViewModel Execute() 10 | { 11 | return new AdvSectionOneViewModel(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/HandlersMarker.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers 2 | { 3 | public class HandlersMarker 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Home/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Home 2 | { 3 | using System; 4 | using Security; 5 | 6 | [AccessGroup(AccessGroupReference.Basic)] 7 | public class GetHandler 8 | { 9 | public HomeViewModel Execute() 10 | { 11 | return new HomeViewModel(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Home/Home.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Home 5 | 6 | 7 |
    8 |
  • 9 | Section One (Advanced access required) 10 |
  • 11 |
  • 12 | Maps (Advanced & Maps access required) 13 |
  • 14 |
  • 15 | Log out (Basic access required) 16 |
  • 17 |
18 |
-------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Handlers/Home/HomeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Handlers.Home 2 | { 3 | public class HomeViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/AccessGroup.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | 5 | /// 6 | /// Custom access control group. 7 | /// 8 | public class AccessGroup 9 | { 10 | public string Name { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/AccessGroupAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// Custom attribute to attach to our FubuMVC handles 8 | /// 9 | [AttributeUsage(AttributeTargets.Class)] 10 | public class AccessGroupAttribute : Attribute 11 | { 12 | private string[] accessGroups; 13 | 14 | public AccessGroupAttribute() 15 | { 16 | this.accessGroups = new string[0]; 17 | } 18 | 19 | public AccessGroupAttribute(params string[] groups) 20 | { 21 | this.accessGroups = groups; 22 | } 23 | 24 | public IEnumerable Groups 25 | { 26 | get 27 | { 28 | return this.accessGroups; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/AccessGroupConvention.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using FubuMVC.Core.Registration; 7 | 8 | public class AccessGroupConvention : IConfigurationAction 9 | { 10 | public void Configure(BehaviorGraph graph) 11 | { 12 | graph 13 | .Actions() 14 | .Where(action => !action.HandlerType.Namespace.StartsWith("FubuMVC.")) // Don't want this to apply to adv diagnostics! 15 | .Each(action => action 16 | .ParentChain() 17 | .Authorization 18 | .AddPolicy(typeof(AccessGroupAuthorizationPolicy<>).MakeGenericType(action.HandlerType))); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/AccessGroupReference.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | public static class AccessGroupReference 4 | { 5 | /// Access to the basic site (e.g. Home page). 6 | public const string Basic = "BASIC_ACCESS"; 7 | 8 | /// Access to areas of the site classed as advanced. 9 | public const string Advanced = "ADVANCED_ACCESS"; 10 | 11 | /// Access to the dummy 'maps' section. 12 | public const string Maps = "MAPS_ACCESS"; 13 | } 14 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/FormsAuthenticationWrapper.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Web.Security; 5 | 6 | public class FormsAuthenticationWrapper : IFormsAuthenticationWrapper 7 | { 8 | public void SetAuthCookie(string userName, bool createPersistentCookie) 9 | { 10 | FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); 11 | } 12 | 13 | public void SetAuthCookie(string userName, bool createPersistentCookie, string strCookiePath) 14 | { 15 | FormsAuthentication.SetAuthCookie(userName, createPersistentCookie, strCookiePath); 16 | } 17 | 18 | public void SignOut() 19 | { 20 | FormsAuthentication.SignOut(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/IFormsAuthenticationWrapper.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | 5 | public interface IFormsAuthenticationWrapper 6 | { 7 | void SetAuthCookie(string userName, bool createPersistentCookie); 8 | void SetAuthCookie(string userName, bool createPersistentCookie, string strCookiePath); 9 | void SignOut(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/IUserData.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public interface IUserData 7 | { 8 | IDictionary> AllowedGroups { get; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/SecurityRegistry.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using StructureMap.Configuration.DSL; 5 | using System.Collections.Generic; 6 | 7 | public class SecurityRegistry : Registry 8 | { 9 | public SecurityRegistry() 10 | { 11 | For() 12 | .Use(); 13 | 14 | // Normally you might fetch user data from a repository or similar, for the 15 | // purposes of this recipe we're just injecting test data. 16 | 17 | For() 18 | .Use((context) => 19 | { 20 | return new UserData( 21 | new Dictionary>() 22 | { 23 | {"BasicUser", new string[] { AccessGroupReference.Basic } }, 24 | {"AdvUser", new string[] { AccessGroupReference.Basic, AccessGroupReference.Advanced } }, 25 | {"MapsUser", new string[] { AccessGroupReference.Basic, AccessGroupReference.Advanced, AccessGroupReference.Maps } } 26 | }); 27 | }); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Security/UserData.cs: -------------------------------------------------------------------------------- 1 | namespace IAuthorizationPolicyRecipe.Web.Security 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public class UserData : IUserData 7 | { 8 | public UserData(IDictionary> allowedGroups) 9 | { 10 | this.AllowedGroups = allowedGroups; 11 | } 12 | 13 | public IDictionary> AllowedGroups { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Shared/Application.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | IAuthorizationPolicyRecipe Recipe 5 | 6 | 7 | 8 |

9 | 10 |

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Shared/_global.spark: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.Web/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/IAuthorizationPolicyRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IAuthorizationPolicyRecipe.Web", "IAuthorizationPolicyRecipe.Web\IAuthorizationPolicyRecipe.Web.csproj", "{27871DFD-FD15-41FE-B3D0-4F5B342AEB86}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IAuthorizationPolicyRecipe.Tests.Unit", "IAuthorizationPolicyRecipe.Tests.Unit\IAuthorizationPolicyRecipe.Tests.Unit.csproj", "{FF791DA4-6AFF-4CBF-BBE5-0F2E69E1B36F}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Recipe", "Recipe", "{78CB0D8A-590F-4F9A-8CF1-E1BE86AF4827}" 9 | ProjectSection(SolutionItems) = preProject 10 | nuget.config = nuget.config 11 | readme.markdown = readme.markdown 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {27871DFD-FD15-41FE-B3D0-4F5B342AEB86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {27871DFD-FD15-41FE-B3D0-4F5B342AEB86}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {27871DFD-FD15-41FE-B3D0-4F5B342AEB86}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {27871DFD-FD15-41FE-B3D0-4F5B342AEB86}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {FF791DA4-6AFF-4CBF-BBE5-0F2E69E1B36F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {FF791DA4-6AFF-4CBF-BBE5-0F2E69E1B36F}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {FF791DA4-6AFF-4CBF-BBE5-0F2E69E1B36F}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {FF791DA4-6AFF-4CBF-BBE5-0F2E69E1B36F}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/Security/CustomIAuthorizationPolicy/readme.markdown: -------------------------------------------------------------------------------- 1 | 2 | Custom IAuthorizationPolicy Recipe 3 | == 4 | This recipe shows how you can implement a completely custom authorization policy based on the HandlersConvention HTTP handler classes. Particularly interesting here is using an IConfigurationAction to apply the policy conditionally and with a generic type. 5 | 6 | **NOTE!** 7 | FubuMVC has it's own group-access authorization policy built-in, you may wish to check this out first if you're looking for an out-of-the-box solution. -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Tests.Unit/Handlers/Books/Create/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Tests.Unit.Handlers.Books.Create 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using BooksCreate = FubuPageExtensionsRecipe.Web.Handlers.Books.Create; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new BooksCreate.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Tests.Unit/Handlers/Books/Create/PostHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Tests.Unit.Handlers.Books.Create 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using BooksCreate = FubuPageExtensionsRecipe.Web.Handlers.Books.Create; 6 | using Home = FubuPageExtensionsRecipe.Web.Handlers.Home; 7 | 8 | [TestFixture] 9 | public class PostHandlerTests 10 | { 11 | [Test] 12 | public void when_calling_execute_return_is_not_null() 13 | { 14 | var handler = new BooksCreate.PostHandler(); 15 | Assert.IsNotNull(handler.Execute(new BooksCreate.CreateRequestModel())); 16 | } 17 | 18 | [Test] 19 | public void when_calling_execute_returns_continuation_to_home() 20 | { 21 | var handler = new BooksCreate.PostHandler(); 22 | var result = handler.Execute(new BooksCreate.CreateRequestModel()); 23 | 24 | result.AssertWasRedirectedTo(x => x.Execute()); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Tests.Unit/Handlers/Genre/Create/PostHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Tests.Unit.Handlers.Genre.Create 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using GenreCreate = FubuPageExtensionsRecipe.Web.Handlers.Genre.Create; 6 | 7 | [TestFixture] 8 | public class PostHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new GenreCreate.PostHandler(); 14 | Assert.IsNotNull(handler.Execute(new GenreCreate.CreateRequestModel())); 15 | } 16 | 17 | [Test] 18 | public void when_calling_execute_returns_valid_guid() 19 | { 20 | Guid guidResult; 21 | 22 | var handler = new GenreCreate.PostHandler(); 23 | var result = handler.Execute(new GenreCreate.CreateRequestModel()); 24 | 25 | Assert.IsTrue(Guid.TryParse(result, out guidResult)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Tests.Unit/Handlers/Home/GetHandlerTests.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Tests.Unit.Handlers.Home 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | using Home = FubuPageExtensionsRecipe.Web.Handlers.Home; 6 | 7 | [TestFixture] 8 | public class GetHandlerTests 9 | { 10 | [Test] 11 | public void when_calling_execute_return_is_not_null() 12 | { 13 | var handler = new Home.GetHandler(); 14 | Assert.IsNotNull(handler.Execute()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/App_Start/FubuMVC.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Routing; 2 | using Bottles; 3 | using FubuMVC.Core; 4 | using FubuMVC.StructureMap; 5 | using StructureMap; 6 | 7 | // You can remove the reference to WebActivator by calling the Start() method from your Global.asax Application_Start 8 | [assembly: WebActivator.PreApplicationStartMethod(typeof(FubuPageExtensionsRecipe.Web.App_Start.AppStartFubuMVC), "Start", callAfterGlobalAppStart: true)] 9 | 10 | namespace FubuPageExtensionsRecipe.Web.App_Start 11 | { 12 | public static class AppStartFubuMVC 13 | { 14 | public static void Start() 15 | { 16 | // FubuApplication "guides" the bootstrapping of the FubuMVC 17 | // application 18 | FubuApplication.For() // ConfigureFubuMVC is the main FubuRegistry 19 | // for this application. FubuRegistry classes 20 | // are used to register conventions, policies, 21 | // and various other parts of a FubuMVC application 22 | 23 | 24 | // FubuMVC requires an IoC container for its own internals. 25 | // In this case, we're using a brand new StructureMap container, 26 | // but FubuMVC just adds configuration to an IoC container so 27 | // that you can use the native registration API's for your 28 | // IoC container for the rest of your application 29 | .StructureMap(new Container()) 30 | .Bootstrap(); 31 | 32 | // Ensure that no errors occurred during bootstrapping 33 | PackageRegistry.AssertNoFailures(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web 2 | { 3 | using System; 4 | using FubuMVC.Core; 5 | using FubuMVC.Spark; 6 | using FubuPageExtensionsRecipe.Web.Handlers; 7 | using Home = FubuPageExtensionsRecipe.Web.Handlers.Home; 8 | using FubuPageExtensionsRecipe.Web.Conventions; 9 | 10 | public class ConfigureFubuMVC : FubuRegistry 11 | { 12 | public ConfigureFubuMVC() 13 | { 14 | // This line turns on the basic diagnostics and request tracing 15 | IncludeDiagnostics(true); 16 | 17 | // Let's use handler convention 18 | ApplyHandlerConventions(); 19 | 20 | // Where is our home page? 21 | Routes.HomeIs(x => x.Execute()); 22 | 23 | // Using Spark as it's great! 24 | this.UseSpark(); 25 | 26 | // Some fancy HTML conventions 27 | this.HtmlConvention(); 28 | 29 | // Match views to action methods by matching 30 | // on model type, view name, and namespace 31 | Views.TryToAttachWithDefaultConventions(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/Css/style.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: Consolas, Courier New, Verdana; 4 | font-size: 12px; 5 | } 6 | 7 | a, a:link, a:visited 8 | { 9 | color: Blue; 10 | } 11 | 12 | .formInput 13 | { 14 | margin: 10px; 15 | } 16 | 17 | .formInput label 18 | { 19 | float: left; 20 | width: 170px; 21 | padding-top: 5px; 22 | } 23 | 24 | .formInput p 25 | { 26 | clear: both; 27 | } 28 | 29 | a.addItem 30 | { 31 | margin-left: 10px; 32 | } 33 | 34 | .dynamicList 35 | { 36 | list-style-type: square; 37 | } 38 | 39 | .addItem span 40 | { 41 | padding: .2em .6em !important; 42 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/Scripts/RecipeHtmlConventions.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | 3 | $('form').submit(function (event) { 4 | setSequentialIndicesForHiddenFields(); 5 | }); 6 | 7 | $('a.addItem').button(); 8 | 9 | $('a.addItem').click(function (event) { 10 | event.preventDefault(); 11 | 12 | var parentId = $(this).attr('rel'); 13 | 14 | if (parentId.indexOf('_') == 0) { 15 | $('#' + parentId.substring(1)).dialog('open'); 16 | } else { 17 | var input = $(this).siblings('input'); 18 | var text = input.val(); 19 | 20 | if (text != '') { 21 | $(this).siblings('ul').append('
  • ' + text + '
  • '); 22 | 23 | var name = input.attr('name'); 24 | $(this).parent().append(''); 25 | } else { 26 | alert("You must enter a value for '" + parentId + "'"); 27 | } 28 | } 29 | }); 30 | }); 31 | 32 | function setSequentialIndicesForHiddenFields() { 33 | var hiddenGroups = $('div.hasHiddenGroup'); 34 | 35 | hiddenGroups.each(function () { 36 | var hiddenFields = $(this).children('input[type=hidden]'); 37 | 38 | hiddenFields.each(function (index) { 39 | var name = $(this).attr('name') + '[' + index + ']'; 40 | $(this).attr('name', name); 41 | }); 42 | }); 43 | 44 | $('*[name=Authors]').attr('name', ' '); 45 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Content/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Books/Create/CreateRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers.Books.Create 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Web; 6 | using FubuPageExtensionsRecipe.Web.Models; 7 | 8 | public class CreateRequestModel 9 | { 10 | public String Title { get; set; } 11 | 12 | public String Genre { get; set; } 13 | 14 | public String Description_BigText { get; set; } 15 | 16 | public BookStatus BookStatus { get; set; } 17 | 18 | public IList Authors { get; set; } 19 | 20 | public HttpPostedFileBase Image { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Books/Create/CreateViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers.Books.Create 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public class CreateViewModel : CreateRequestModel 7 | { 8 | public CreateViewModel() 9 | { 10 | this.Genres = new Dictionary() 11 | { 12 | { Guid.NewGuid().ToString(), "Fiction" }, 13 | { Guid.NewGuid().ToString(), "Crime" }, 14 | { Guid.NewGuid().ToString(), "Biography" }, 15 | { Guid.NewGuid().ToString(), "History" }, 16 | }; 17 | } 18 | 19 | public IDictionary Genres { get; private set; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Books/Create/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers.Books.Create 2 | { 3 | public class GetHandler 4 | { 5 | public CreateViewModel Execute() 6 | { 7 | return new CreateViewModel(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Books/Create/PostHandler.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers.Books.Create 2 | { 3 | using FubuMVC.Core.Continuations; 4 | using FubuPageExtensionsRecipe.Web.Handlers.Home; 5 | 6 | public class PostHandler 7 | { 8 | public FubuContinuation Execute(CreateRequestModel model) 9 | { 10 | return FubuContinuation.RedirectTo(x => x.Execute()); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Genre/Create/CreateRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers.Genre.Create 2 | { 3 | public class CreateRequestModel 4 | { 5 | public string Name { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Genre/Create/PostHandler.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers.Genre.Create 2 | { 3 | using System; 4 | 5 | public class PostHandler 6 | { 7 | public string Execute(CreateRequestModel model) 8 | { 9 | return Guid.NewGuid().ToString(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/HandlersMarker.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers 2 | { 3 | public class HandlersMarker 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Home/GetHandler.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers.Home 2 | { 3 | public class GetHandler 4 | { 5 | public HomeViewModel Execute() 6 | { 7 | return new HomeViewModel(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Home/Home.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Home 5 | 6 | 7 | Create Book! 8 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Handlers/Home/HomeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Handlers.Home 2 | { 3 | public class HomeViewModel 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Models/BookStatus.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Models 2 | { 3 | public enum BookStatus 4 | { 5 | Wishlist, 6 | CurrentlyReading, 7 | Reviewed 8 | } 9 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Models/Genre.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Models 2 | { 3 | using System; 4 | 5 | public class Genre 6 | { 7 | public string Name { get; set; } 8 | 9 | public string Id { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Models/ImageDisplayModel.cs: -------------------------------------------------------------------------------- 1 | namespace FubuPageExtensionsRecipe.Web.Models 2 | { 3 | public class ImageDisplayModel 4 | { 5 | public string Id { get; set; } 6 | 7 | public int Width { get; set; } 8 | 9 | public int Height { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Shared/Application.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | FubuPageExtensions Recipe 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 |

    16 | 17 |

    18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Shared/_global.spark: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Shared/bindings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | this.FormFor<@model>().Attr("class", "validate").Attr("name", "@name").Attr("id", "@name") 4 | this.EndForm() 5 | 6 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.Web/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/FubuPageExtensionsRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FubuPageExtensionsRecipe.Web", "FubuPageExtensionsRecipe.Web\FubuPageExtensionsRecipe.Web.csproj", "{E2DE09B5-54D5-4A6B-95D7-3D9F5D6F2434}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FubuPageExtensionsRecipe.Tests.Unit", "FubuPageExtensionsRecipe.Tests.Unit\FubuPageExtensionsRecipe.Tests.Unit.csproj", "{8D0EA90B-4CC7-47DF-9F4C-F3C1431AAC09}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Recipe", "Recipe", "{3CA322E9-1DF8-4408-947E-C08A4A9D88CD}" 9 | ProjectSection(SolutionItems) = preProject 10 | nuget.config = nuget.config 11 | readme.markdown = readme.markdown 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {E2DE09B5-54D5-4A6B-95D7-3D9F5D6F2434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {E2DE09B5-54D5-4A6B-95D7-3D9F5D6F2434}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {E2DE09B5-54D5-4A6B-95D7-3D9F5D6F2434}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {E2DE09B5-54D5-4A6B-95D7-3D9F5D6F2434}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {8D0EA90B-4CC7-47DF-9F4C-F3C1431AAC09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {8D0EA90B-4CC7-47DF-9F4C-F3C1431AAC09}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {8D0EA90B-4CC7-47DF-9F4C-F3C1431AAC09}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {8D0EA90B-4CC7-47DF-9F4C-F3C1431AAC09}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/UI/HtmlConventionsWithPageExtensions/readme.markdown: -------------------------------------------------------------------------------- 1 | 2 | Html Conventions with PageExtensions Recipe [Work In Progress] 3 | == 4 | FubuMVC allows not only a plethora of extension helper methods for building your views but also some nifty tricks to use conventions to standardise your view building. 5 | 6 | I was reading an [excellent blog article](http://ntcoding.blogspot.com/2011/11/fun-with-fubus-html-conventions.html) from [@NTCoding](http://twitter.com/ntcoding) and realised it would make for an excellent recipe; with his permission I've taken his example and used it here along with some additional Javascript. 7 | 8 | **NOTE!** The Javascript in this recipe has been 'knocked together' for the purposes of demonstrating Html Conventions, it's not meant to be exemplary. -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Tests.Unit/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("IUrlRegistryRecipe.Tests.Unit")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IUrlRegistryRecipe.Tests.Unit")] 13 | [assembly: AssemblyCopyright("Copyright © 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("db4f9781-d9d3-465f-b16b-c21c3966e87c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/App_Start/FubuMVC.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Routing; 2 | using Bottles; 3 | using FubuMVC.Core; 4 | using FubuMVC.StructureMap; 5 | using StructureMap; 6 | 7 | // You can remove the reference to WebActivator by calling the Start() method from your Global.asax Application_Start 8 | [assembly: WebActivator.PreApplicationStartMethod(typeof(IUrlRegistryRecipe.Web.App_Start.AppStartFubuMVC), "Start", callAfterGlobalAppStart: true)] 9 | 10 | namespace IUrlRegistryRecipe.Web.App_Start 11 | { 12 | public static class AppStartFubuMVC 13 | { 14 | public static void Start() 15 | { 16 | // FubuApplication "guides" the bootstrapping of the FubuMVC 17 | // application 18 | FubuApplication.For() // ConfigureFubuMVC is the main FubuRegistry 19 | // for this application. FubuRegistry classes 20 | // are used to register conventions, policies, 21 | // and various other parts of a FubuMVC application 22 | 23 | 24 | // FubuMVC requires an IoC container for its own internals. 25 | // In this case, we're using a brand new StructureMap container, 26 | // but FubuMVC just adds configuration to an IoC container so 27 | // that you can use the native registration API's for your 28 | // IoC container for the rest of your application 29 | .StructureMap(new Container()) 30 | .Bootstrap(); 31 | 32 | // Ensure that no errors occurred during bootstrapping 33 | PackageRegistry.AssertNoFailures(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/ConfigureFubuMVC.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web 2 | { 3 | using FubuMVC.Core; 4 | using FubuMVC.Spark; 5 | using IUrlRegistryRecipe.Web.Controllers; 6 | 7 | public class ConfigureFubuMVC : FubuRegistry 8 | { 9 | public ConfigureFubuMVC() 10 | { 11 | // This line turns on the basic diagnostics and request tracing 12 | IncludeDiagnostics(true); 13 | 14 | // All public methods from concrete classes ending in "Controller" 15 | // in this assembly are assumed to be action methods 16 | Actions.IncludeClassesSuffixedWithController(); 17 | 18 | // Policies 19 | Routes 20 | .IgnoreControllerNamesEntirely() 21 | .IgnoreMethodSuffix("Html") 22 | .RootAtAssemblyNamespace(); 23 | 24 | // Where is home? 25 | Routes.HomeIs(x => x.Home()); 26 | 27 | // Using Spark 'cause its cool 28 | this.UseSpark(); 29 | 30 | // Match views to action methods by matching 31 | // on model type, view name, and namespace 32 | Views.TryToAttachWithDefaultConventions(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Content/Css/style.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: Consolas, Courier New, Verdana; 4 | font-size: 12px; 5 | } 6 | 7 | a, a:link, a:visited 8 | { 9 | color: Blue; 10 | } 11 | 12 | ul li 13 | { 14 | margin-bottom: 3px; 15 | } 16 | 17 | ul.nodots, li.nodots 18 | { 19 | list-style-type: none; 20 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Controllers/BookController.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Controllers 2 | { 3 | using System; 4 | using FubuMVC.Core.Continuations; 5 | using Models.Books; 6 | 7 | public class BookController 8 | { 9 | public BookViewModel ViewBook(BookViewRequestModel model) 10 | { 11 | Guid id = model.Id; 12 | 13 | // Find book details by Id 14 | 15 | return new BookViewModel( 16 | id, 17 | "Book Title", 18 | "Ian Battersby", 19 | DateTime.Now, 20 | 23.99); 21 | } 22 | 23 | public FubuContinuation FindBook(BookFindRequestModel model) 24 | { 25 | Guid id; 26 | 27 | if (model.FindById != null) 28 | { 29 | id = model.FindById; 30 | } 31 | else 32 | { 33 | // Find book id 34 | id = Guid.NewGuid(); 35 | } 36 | 37 | return FubuContinuation.RedirectTo(x => x.ViewBook(new BookViewRequestModel(id))); 38 | } 39 | 40 | public FubuContinuation AddBook(BookAddRequest model) 41 | { 42 | Guid id = Guid.NewGuid(); 43 | 44 | return FubuContinuation.RedirectTo(x => x.ViewBook(new BookViewRequestModel(id))); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Controllers 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using FubuMVC.Core.Urls; 6 | using Models; 7 | using Models.Books; 8 | 9 | public class HomeController 10 | { 11 | public HomeViewModel Home() 12 | { 13 | var urlForOMI = new CallList("If our action is employing OMIOMO (One Model In, One Model Out) we can derive a Url based on that input model."); 14 | urlForOMI.Calls.Add(x => x.UrlFor(new BookFindRequestModel())); 15 | urlForOMI.Calls.Add(x => x.UrlFor()); 16 | 17 | var urlForZMI = new CallList("Alternatively we can derive Urls based on the action name, especially useful if no input model is being used (ZMIOMO - Zero Model In, One Model Out)."); 18 | urlForZMI.Calls.Add(x => x.UrlFor(a => a.FindBook(new BookFindRequestModel()))); 19 | 20 | return new HomeViewModel( 21 | new List() { 22 | urlForOMI, 23 | urlForZMI 24 | }); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/Books/BookAddRequest.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models.Books 2 | { 3 | using System; 4 | 5 | public class BookAddRequest 6 | { 7 | public BookAddRequest() 8 | { 9 | } 10 | 11 | public BookAddRequest( 12 | string title, 13 | string author, 14 | DateTime published, 15 | double price) 16 | { 17 | this.Title = title; 18 | this.Author = author; 19 | this.Published = published; 20 | this.Price = price; 21 | } 22 | 23 | public string Title { get; private set; } 24 | public string Author { get; private set; } 25 | public DateTime Published { get; private set; } 26 | public double Price { get; private set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/Books/BookFindRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models.Books 2 | { 3 | using System; 4 | 5 | public class BookFindRequestModel 6 | { 7 | public BookFindRequestModel() 8 | { 9 | } 10 | 11 | public BookFindRequestModel( 12 | Guid id, 13 | string title, 14 | string author) 15 | { 16 | this.FindById = id; 17 | this.FindByTitle = title; 18 | this.FindByAuthor = author; 19 | } 20 | 21 | public Guid FindById { get; private set; } 22 | public string FindByTitle { get; private set; } 23 | public string FindByAuthor { get; private set; } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/Books/BookViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models.Books 2 | { 3 | using System; 4 | 5 | public class BookViewModel : BookAddRequest 6 | { 7 | public BookViewModel() 8 | { 9 | } 10 | 11 | public BookViewModel( 12 | Guid Id, 13 | string title, 14 | string author, 15 | DateTime published, 16 | double price) : base (title, author, published, price) 17 | { 18 | this.Id = Id; 19 | } 20 | 21 | public Guid Id { get; private set; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/Books/BookViewRequestModel.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models.Books 2 | { 3 | using System; 4 | 5 | public class BookViewRequestModel 6 | { 7 | public BookViewRequestModel(Guid id) 8 | { 9 | this.Id = id; 10 | } 11 | 12 | public Guid Id { get; private set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/CallList.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using FubuMVC.Core.Urls; 6 | 7 | public class CallList 8 | { 9 | public CallList(string htmlDescription) 10 | { 11 | this.HtmlDescription = htmlDescription; 12 | this.Calls = new DynamicFuncList(); 13 | } 14 | 15 | public string HtmlDescription { get; private set; } 16 | public DynamicFuncList Calls { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/DynamicFuncList.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models 2 | { 3 | using System; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | 7 | public class DynamicFuncList : ValuePairList> 8 | { 9 | public void Add(Expression> expression) 10 | { 11 | MethodCallExpression outermostExpression = expression.Body as MethodCallExpression; 12 | string methodSignature = outermostExpression.ToString(); 13 | 14 | if (outermostExpression.Method.IsGenericMethod) 15 | { 16 | StringBuilder genericList = new StringBuilder(); 17 | 18 | genericList.Append("<"); 19 | 20 | foreach (var param in outermostExpression.Method.GetGenericArguments()) 21 | { 22 | genericList.AppendFormat("{0}{1}", genericList.Length == 0 ? ", " : String.Empty, param.Name); 23 | } 24 | 25 | genericList.Append(">"); 26 | 27 | methodSignature = methodSignature.Insert(methodSignature.IndexOf("("), genericList.ToString()).ToString(); 28 | } 29 | 30 | this.Add(methodSignature, expression.Compile()); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/HomeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using FubuMVC.Core.Urls; 6 | 7 | public class HomeViewModel 8 | { 9 | public HomeViewModel() 10 | { 11 | } 12 | 13 | public HomeViewModel(IEnumerable callLists) 14 | { 15 | this.CallLists = callLists; 16 | } 17 | 18 | public IEnumerable CallLists {get;private set;} 19 | } 20 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/ValuePair.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models 2 | { 3 | using System; 4 | 5 | public class ValuePair 6 | { 7 | public ValuePair( 8 | TKey key, 9 | TValue Value) 10 | { 11 | this.Key = key; 12 | this.Value = Value; 13 | } 14 | 15 | public TKey Key { get; private set; } 16 | public TValue Value { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Models/ValuePairList.cs: -------------------------------------------------------------------------------- 1 | namespace IUrlRegistryRecipe.Web.Models 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web; 7 | 8 | public class ValuePairList 9 | { 10 | private readonly IList> values; 11 | 12 | public ValuePairList() 13 | { 14 | this.values = new List>(); 15 | } 16 | 17 | public void Add(TKey key, TValue value) 18 | { 19 | this.values.Add(new ValuePair(key, value)); 20 | } 21 | 22 | public int Count() 23 | { 24 | return this.values.Count; 25 | } 26 | 27 | public IEnumerable> AsEnumerable() 28 | { 29 | return this.values; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("IUrlRegistryRecipe.Web")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IUrlRegistryRecipe.Web")] 13 | [assembly: AssemblyCopyright("Copyright © 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("38eb9c87-a5d4-4d3e-9040-baff99a1dca8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Shared/Application.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | IUrlRegistry Recipe 5 | 6 | 7 | 8 |

    9 | 10 |

    11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Shared/_global.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Views/HomeViewModel.spark: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | Home 9 | 10 |

    Actions

    11 | 12 |

    ${ cl.HtmlDescription }

    13 |

    None

    14 |
      15 | 16 |
    • ${ a.Key } >> "${ a.Value.Invoke(this.Urls) }"
    • 17 |
      18 |
    19 |
    20 |
    -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/fubu-content/FubuMVC.GettingStarted.dll -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/fubu-content/fubumvc-diagnostics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianbattersby/FubuMVC.Recipes/23a2532c8df0c519cd31cacd8e10d0cecaba1a6d/src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/fubu-content/fubumvc-diagnostics.zip -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.Web/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/IUrlRegistryRecipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IUrlRegistryRecipe.Web", "IUrlRegistryRecipe.Web\IUrlRegistryRecipe.Web.csproj", "{8B9396EB-2189-4771-B111-6DFE6F7D4BAA}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IUrlRegistryRecipe.Tests.Unit", "IUrlRegistryRecipe.Tests.Unit\IUrlRegistryRecipe.Tests.Unit.csproj", "{BC96C260-FE60-49DB-968E-FD340CE22525}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8B9396EB-2189-4771-B111-6DFE6F7D4BAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8B9396EB-2189-4771-B111-6DFE6F7D4BAA}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8B9396EB-2189-4771-B111-6DFE6F7D4BAA}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8B9396EB-2189-4771-B111-6DFE6F7D4BAA}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {BC96C260-FE60-49DB-968E-FD340CE22525}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {BC96C260-FE60-49DB-968E-FD340CE22525}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {BC96C260-FE60-49DB-968E-FD340CE22525}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {BC96C260-FE60-49DB-968E-FD340CE22525}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | ..\..\packages 3 | -------------------------------------------------------------------------------- /src/Urls/IUrlRegistry/readme.markdown: -------------------------------------------------------------------------------- 1 | 2 | IUrlRegistry Recipe 3 | == 4 | TBC --------------------------------------------------------------------------------