├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── SmartResult.Demo ├── Controllers │ └── CustomersController.cs ├── Mappings │ └── SmartResultProfile.cs ├── Models │ ├── Customer.cs │ ├── MobileCustomer.cs │ └── NativeCustomer.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Repository.cs ├── SmartResult.Demo.csproj ├── Startup.cs ├── appsettings.Development.json └── appsettings.json ├── SmartResult.Integration.Tests ├── Constants.cs ├── DesktopTests.cs ├── MobileTests.cs └── SmartResult.Integration.Tests.csproj ├── SmartResult.Unit.Tests ├── Constants.cs ├── Mappings │ └── SmartResultProfile.cs ├── MobileTests.cs ├── Models │ ├── Customer.cs │ ├── MobileCustomer.cs │ └── NativeCustomer.cs ├── NativeTests.cs ├── Repository.cs └── SmartResult.Unit.Tests.csproj ├── SmartResult ├── ISmartResultProfile.cs ├── RequestExtensions.cs ├── SmartResult.cs ├── SmartResult.csproj ├── SmartResultConfiguration.cs └── SmartResultProfile.cs ├── appveyor.yml └── smart-result.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc 262 | 263 | .vscode -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Christos Sakellarios 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AspNet.Core.SmartResult 2 | 3 | [![License](https://img.shields.io/github/license/chsakell/aspnet-core-smartresult.svg)](https://github.com/chsakell/aspnet-core-smartresult/blob/master/LICENSE) [![Build status](https://ci.appveyor.com/api/projects/status/i63utoec8j7wsjwy/branch/master?svg=true)](https://ci.appveyor.com/project/chsakell/aspnet-core-smartresult/branch/master) [![AppVeyor tests](https://img.shields.io/appveyor/tests/chsakell/aspnet-core-smartresult.svg)](https://ci.appveyor.com/project/chsakell/aspnet-core-smartresult) 4 | 5 | Available as [NuGet package](https://www.nuget.org/packages/AspNet.Core.SmartResult/) 6 | 7 | Result filter for ASP.NET Core MVC Controllers that can produce multiple types of results for the same action. Used in **multi-client** APIs that need to serve different types of results per device. 8 | 9 | ![AspNet.Core.SmartResult](https://chsakell.files.wordpress.com/2018/05/smart-result.png) 10 | 11 | ### Description 12 | 13 | Most of the times mobile devices/browsers consume and render only partial data in contrast with those rendered by desktop browsers. This usually results to create different MVC actions or even applications that serve different content to different types of clients in order to reduce unused data tranfered over the wire. `SmartResult` filter can help you solve this problem by transforming the type of the action's result based on the device. 14 | 15 | `SmartResult` implements `IResultFilter` and `Attribute` so it can be placed as a filter attribute above ASP.NET Core MVC Controller actions. You declare the default returned type of the result *(which is for desktop)*, the returned type for mobile browsers and native apps as well. The filter upon `OnResultExecuting` event detects the type of the client and uses `AutoMapper` to transform the result if required. 16 | 17 | ### Examples of usage 18 | 19 | In the following examples the `NativeCustomer` class is the base and more light weighted class that supposed to be consumed by native apps. `MobileCustomer` inherits it and adds a single property. `Customer` contains all available information for a single customer. 20 | 21 | ```csharp 22 | public class Customer : MobileCustomer 23 | { 24 | public string PhoneNumber { get; set; } 25 | public int Age { get; set; } 26 | } 27 | 28 | public class MobileCustomer : NativeCustomer 29 | { 30 | public string Address { get; set; } 31 | } 32 | 33 | public class NativeCustomer 34 | { 35 | public int Id { get; set; } 36 | public string Name { get; set; } 37 | } 38 | 39 | ``` 40 | 41 | The action below will return type of `IEnumerable` for desktop, type of `IEnumerable` for mobile browsers and `IEnumerable` based on configuration that follows. 42 | 43 | ```csharp 44 | 45 | // GET api/customers 46 | [HttpGet] 47 | [SmartResult] 48 | public IActionResult Get() 49 | { 50 | return repository.GetCustomers(); 51 | } 52 | 53 | ``` 54 | 55 | The configuration: 56 | 57 | ```csharp 58 | 59 | List profiles = new List 60 | { 61 | new SmartResultProfile(new CustomerProfile()) 62 | }; 63 | 64 | // Use the minimum configuration 65 | SmartResult.Configure( 66 | new SmartResultConfiguration( 67 | profiles 68 | ) 69 | ); 70 | 71 | ``` 72 | 73 | Works with ActionResults and base types as well 74 | 75 | ```csharp 76 | 77 | // GET api/customers/id 78 | [HttpGet("{id}")] 79 | [SmartResult] 80 | public Customer Get(int id) 81 | { 82 | return repository.GetCustomer(id); 83 | } 84 | 85 | ``` 86 | 87 | The configuration is a generic class that accepts the types of classes for Desktop, Mobile and/or Native plus an `AutoMapper` **profile**. For example: 88 | 89 | ```csharp 90 | 91 | List profiles = new List 92 | { 93 | new SmartResultProfile(new CustomerProfile()) 94 | }; 95 | 96 | // Use the minimum configuration 97 | SmartResult.Configure( 98 | new SmartResultConfiguration( 99 | profiles 100 | ) 101 | ); 102 | 103 | ``` 104 | 105 | 1. `Customer` for desktop browsers 106 | 2. `MobileCustomer` for mobile browsers 107 | 3. `NativeCustomer` for native apps 108 | 109 | The Desktop Generic type is mandatory but you can choose to support only Mobile or Native clients as follow: 110 | 111 | ```csharp 112 | 113 | // Desktop & Mobile Only 114 | List profiles = new List 115 | { 116 | new SmartResultProfile(new CustomerTestProfile(), Client.Mobile) 117 | }; 118 | 119 | // Desktop & Native Only 120 | List profiles = new List 121 | { 122 | new SmartResultProfile(new CustomerTestProfile(), Client.Native) 123 | }; 124 | 125 | ``` 126 | 127 | ### How it works 128 | When you apply the `SmartResult` filter on an Action, the filter will search for an `ISmartResultProfile` profile having as it's Desktop class type the base type of your Action's result *(e.g. if the action's result type is `IEnumerable` or just `Customer` the filter will search a profile with desktop type of `Customer`)*. If it founds one then it will detect if the request comes from mobile or native device and manipulate the result respectively if needed. 129 | 130 | 131 | ### Installation 132 | 133 | The package can be installed using one of the following ways: 134 | 135 | * **Package Manager**: `Install-Package AspNet.Core.SmartResult` 136 | * **.NET CLI**: `dotnet add package AspNet.Core.SmartResult` 137 | * **Paket CLI**: `paket add AspNet.Core.SmartResult` 138 | 139 | ### Configuration 140 | 141 | The transformation of the result types is based on [AutoMapper](https://github.com/AutoMapper/AutoMapper) profiles and functions that determine if the `HttpRequest` comes from a mobile or a native device. The minimum requirement is to create the `AutoMapper` profiles and pass the list to a `SmartResultConfiguration` object using the `SmartResult.Configure` method. Place that code inside the `Startup` class before the `app.UseMvc()` call as follow: 142 | 143 | #### Minimum Configuration 144 | 145 | ```csharp 146 | 147 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 148 | { 149 | if (env.IsDevelopment()) 150 | { 151 | app.UseDeveloperExceptionPage(); 152 | } 153 | 154 | // Add a list of AutoMapper profiles to be used by SmartResult 155 | List profiles = new List 156 | { 157 | new SmartResultProfile(new CustomerProfile()) 158 | }; 159 | 160 | // Use the minimum configuration 161 | SmartResult.Configure( 162 | new SmartResultConfiguration( 163 | profiles 164 | )); 165 | 166 | app.UseMvc(); 167 | } 168 | 169 | ``` 170 | 171 | The above configuration will use a default implementation for detecting mobile devices. `CustomerProfile` is an AutoMapper profile *(just for this demonstration)* and could look like this: 172 | 173 | ```csharp 174 | 175 | public class CustomerProfile : Profile 176 | { 177 | public SmartResultProfile() 178 | { 179 | CreateMap(); 180 | CreateMap(); 181 | } 182 | } 183 | 184 | ``` 185 | 186 | Use your own AutoMapper profiles and pass them to `SmartResultConfiguration` constructor. 187 | 188 | #### Advance Configuration 189 | 190 | You can override how mobile and native devices detection takes place by providing your own implementations. For example you may want to detect native devices based on a custom header sent by them. The `SmartResultConfiguration` accepts the following two optional delegates: 191 | 192 | ```csharp 193 | 194 | delegate bool IsMobile(HttpContext context); 195 | delegate bool IsNative(HttpContext context); 196 | 197 | ``` 198 | 199 | Hence, an advanced configuration would look like this: 200 | 201 | ```csharp 202 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 203 | { 204 | if (env.IsDevelopment()) 205 | { 206 | app.UseDeveloperExceptionPage(); 207 | } 208 | 209 | List profiles = new List 210 | { 211 | new SmartResultProfile(new CustomerProfile()) 212 | }; 213 | 214 | // Use the minimum configuration 215 | SmartResult.Configure( 216 | new SmartResultConfiguration( 217 | profiles, 218 | isMobile: MyCustomMobileDetection, 219 | isNative: MyCustomNativeDetection 220 | )); 221 | 222 | app.UseMvc(); 223 | } 224 | 225 | private bool MyCustomMobileDetection(HttpContext request) 226 | { 227 | // Place your custom logic here for detecting Mobile browsers 228 | return true; 229 | } 230 | 231 | private bool MyCustomNativeDetection(HttpContext request) 232 | { 233 | // Place your custom logic here for detecting Native devices 234 | return true; 235 | } 236 | 237 | ``` 238 | 239 | #### Contributing to AspNet.Core.SmartResult 240 | Feel free to contribute to this project by: 241 | 242 | * Reporting a bug 243 | * Discussing the current state of the code 244 | * Submitting a fix 245 | * Proposing new features 246 | 247 | Pull requests are the best way to propose changes to the codebase so: 248 | 249 | 1. Fork the repo and create your branch from `master` 250 | 2. If you've added code that should be tested, add tests 251 | 3. If you've changed APIs, update the documentation 252 | 4. Ensure the test suite passes 253 | 5. Issue that pull request! 254 | 255 | ## License 256 | Code released under the MIT license. 257 | -------------------------------------------------------------------------------- /SmartResult.Demo/Controllers/CustomersController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using SmartResult.Demo; 7 | using SmartResult.Demo.Models; 8 | 9 | namespace AspNet.Core.SmartResult.Demo.Controllers 10 | { 11 | [Route("api/[controller]")] 12 | public class CustomersController : Controller 13 | { 14 | private readonly IRepository _repository; 15 | 16 | public CustomersController(IRepository repository) 17 | { 18 | _repository = repository; 19 | } 20 | 21 | // GET api/customers 22 | [HttpGet] 23 | [SmartResult] 24 | public IActionResult Get() 25 | { 26 | return Ok(_repository.GetCustomers()); 27 | } 28 | 29 | // GET api/customers/id 30 | [HttpGet("{id}")] 31 | [SmartResult] 32 | public Customer Get(int id) 33 | { 34 | return _repository.GetCustomer(id); 35 | } 36 | 37 | 38 | // POST api/values 39 | [HttpPost] 40 | [SmartResult] 41 | public IActionResult Post([FromBody]Customer value) 42 | { 43 | return Ok(value); 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SmartResult.Demo/Mappings/SmartResultProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using SmartResult.Demo.Models; 7 | 8 | namespace AspNet.Core.SmartResult.Demo.Mappings 9 | { 10 | public class CustomerProfile : Profile 11 | { 12 | public CustomerProfile() 13 | { 14 | CreateMap(); 15 | CreateMap(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SmartResult.Demo/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SmartResult.Demo.Models 7 | { 8 | public class Customer : MobileCustomer 9 | { 10 | public string PhoneNumber { get; set; } 11 | public int Age { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SmartResult.Demo/Models/MobileCustomer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SmartResult.Demo.Models 7 | { 8 | public class MobileCustomer : NativeCustomer 9 | { 10 | public string Address { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SmartResult.Demo/Models/NativeCustomer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SmartResult.Demo.Models 7 | { 8 | public class NativeCustomer 9 | { 10 | public int Id { get; set; } 11 | public string Name { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SmartResult.Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace AspNet.Core.SmartResult.Demo 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | BuildWebHost(args).Run(); 18 | } 19 | 20 | public static IWebHost BuildWebHost(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup() 23 | .Build(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SmartResult.Demo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:5000/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "launchUrl": "api/customers", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "SmartResult.Demo": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "launchUrl": "api/customers", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | }, 26 | "applicationUrl": "http://localhost:5000/" 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SmartResult.Demo/Repository.cs: -------------------------------------------------------------------------------- 1 | using SmartResult.Demo.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace SmartResult.Demo 8 | { 9 | public class Repository : IRepository 10 | { 11 | static List Customers = new List 12 | { 13 | new Customer() { Id = 1, Name = "Christos", Address = "Athens", Age = 32, PhoneNumber = "123456789"}, 14 | new Customer() { Id = 2, Name = "John", Address = "Paris", Age = 44, PhoneNumber = "253525252"}, 15 | new Customer() { Id = 3, Name = "Mary", Address = "Milano", Age = 35, PhoneNumber = "425225252"} 16 | }; 17 | //static Repository 18 | public Customer GetCustomer(int id) 19 | { 20 | return Customers.FirstOrDefault(c => c.Id == id); 21 | } 22 | 23 | public IEnumerable GetCustomers() 24 | { 25 | return Customers; 26 | } 27 | } 28 | 29 | public interface IRepository 30 | { 31 | IEnumerable GetCustomers(); 32 | Customer GetCustomer(int id); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SmartResult.Demo/SmartResult.Demo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.2 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SmartResult.Demo/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using AutoMapper; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Logging; 12 | using Microsoft.Extensions.Options; 13 | using AspNet.Core.SmartResult.Demo.Mappings; 14 | using SmartResult; 15 | using SmartResult.Demo; 16 | using SmartResult.Demo.Models; 17 | 18 | namespace AspNet.Core.SmartResult.Demo 19 | { 20 | public class Startup 21 | { 22 | public Startup(IConfiguration configuration) 23 | { 24 | Configuration = configuration; 25 | } 26 | 27 | public IConfiguration Configuration { get; } 28 | 29 | // This method gets called by the runtime. Use this method to add services to the container. 30 | public void ConfigureServices(IServiceCollection services) 31 | { 32 | services.AddSingleton(); 33 | services.AddMvc(); 34 | } 35 | 36 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 37 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 38 | { 39 | if (env.IsDevelopment()) 40 | { 41 | app.UseDeveloperExceptionPage(); 42 | } 43 | 44 | // Add a list of AutoMapper profiles to be used by SmartResult 45 | List profiles = new List 46 | { 47 | new SmartResultProfile(new CustomerProfile()) 48 | }; 49 | 50 | // Use the minimum configuration 51 | SmartResult.Configure( 52 | new SmartResultConfiguration( 53 | profiles 54 | ) 55 | ); 56 | 57 | app.UseMvc(); 58 | } 59 | 60 | /// 61 | /// Implement your own custom logic for detecting Mobile Browsers 62 | /// 63 | /// 64 | /// 65 | private bool MyCustomMobileDetection(HttpContext request) 66 | { 67 | // Place your custom logic here for detecting Mobile browsers 68 | return true; 69 | } 70 | 71 | /// 72 | /// Implement your own custom logic for detecting Native Devices 73 | /// 74 | /// 75 | /// 76 | private bool MyCustomNativeDetection(HttpContext request) 77 | { 78 | // Place your custom logic here for detecting Native devices 79 | return true; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /SmartResult.Demo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SmartResult.Demo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "Debug": { 5 | "LogLevel": { 6 | "Default": "Warning" 7 | } 8 | }, 9 | "Console": { 10 | "LogLevel": { 11 | "Default": "Warning" 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SmartResult.Integration.Tests/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SmartResult.Integration.Tests 6 | { 7 | public class Constants 8 | { 9 | public static string AndroidMobileBrowser = "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; SCH-I535 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"; 10 | public static string ChromeMobileBrowser = "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36"; 11 | public static string SafariIOSBrowser = "Safari for iOS"; 12 | public static string FirefoxForAndroidMobileBrowser = "Firefox for Android"; 13 | public static string IEMobileBrowser = "IE Mobile"; 14 | public static string BlackBerryMobileBrowser = "BlackBerry Browser"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SmartResult.Integration.Tests/DesktopTests.cs: -------------------------------------------------------------------------------- 1 | using AspNet.Core.SmartResult.Demo; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.TestHost; 4 | using Newtonsoft.Json; 5 | using SmartResult.Demo.Models; 6 | using System; 7 | using System.Collections; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Net.Http; 11 | using System.Threading.Tasks; 12 | using Xunit; 13 | 14 | namespace SmartResult.Integration.Tests 15 | { 16 | public class DesktopTests 17 | { 18 | private readonly TestServer _server; 19 | private readonly HttpClient _client; 20 | 21 | public DesktopTests() 22 | { 23 | // Arrange 24 | _server = new TestServer(new WebHostBuilder() 25 | .UseStartup()); 26 | _client = _server.CreateClient(); 27 | } 28 | 29 | [Fact] 30 | public async Task Returns_Default_Result_Whithout_User_Agent() 31 | { 32 | // Act 33 | var response = await _client.GetAsync("/api/customers/"); 34 | response.EnsureSuccessStatusCode(); 35 | 36 | var responseString = await response.Content.ReadAsStringAsync(); 37 | var headerResult = response.Headers.GetValues("Result-Type").ToList().First(); 38 | var responseResult = JsonConvert.DeserializeObject>(responseString); 39 | 40 | // Assert 41 | Assert.Equal("Default", headerResult); 42 | Assert.IsType>(responseResult); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SmartResult.Integration.Tests/MobileTests.cs: -------------------------------------------------------------------------------- 1 | using AspNet.Core.SmartResult.Demo; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.TestHost; 4 | using Newtonsoft.Json; 5 | using SmartResult.Demo.Models; 6 | using System; 7 | using System.Collections; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Net.Http; 11 | using System.Threading.Tasks; 12 | using Xunit; 13 | 14 | namespace SmartResult.Integration.Tests 15 | { 16 | public class MobileTests 17 | { 18 | private readonly TestServer _server; 19 | private readonly HttpClient _client; 20 | 21 | public MobileTests() 22 | { 23 | // Arrange 24 | _server = new TestServer(new WebHostBuilder() 25 | .UseStartup()); 26 | _client = _server.CreateClient(); 27 | } 28 | 29 | [Fact] 30 | public async Task Returns_Mobile_Result_When_Android_In_User_Agent() 31 | { 32 | // Act 33 | _client.DefaultRequestHeaders.Add("User-Agent", Constants.AndroidMobileBrowser); 34 | var response = await _client.GetAsync("/api/customers/"); 35 | response.EnsureSuccessStatusCode(); 36 | 37 | var responseString = await response.Content.ReadAsStringAsync(); 38 | var headerResult = response.Headers.GetValues("Result-Type").ToList().First(); 39 | var responseResult = JsonConvert.DeserializeObject>(responseString); 40 | 41 | // Assert 42 | Assert.Equal("Mobile", headerResult); 43 | Assert.IsType>(responseResult); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SmartResult.Integration.Tests/SmartResult.Integration.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.2 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SmartResult.Unit.Tests 6 | { 7 | public class Constants 8 | { 9 | public static string AndroidMobileBrowser = "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; SCH-I535 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"; 10 | public static string ChromeMobileBrowser = "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36"; 11 | public static string SafariIOSBrowser = "Safari for iOS"; 12 | public static string FirefoxForAndroidMobileBrowser = "Firefox for Android"; 13 | public static string IEMobileBrowser = "IE Mobile"; 14 | public static string BlackBerryMobileBrowser = "BlackBerry Browser"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/Mappings/SmartResultProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using SmartResult.Unit.Tests.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace SmartResult.Unit.Tests.Mappings 9 | { 10 | public class CustomerTestProfile : Profile 11 | { 12 | public CustomerTestProfile() 13 | { 14 | CreateMap(); 15 | CreateMap(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/MobileTests.cs: -------------------------------------------------------------------------------- 1 | using AspNet.Core.SmartResult; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.AspNetCore.Mvc.Abstractions; 5 | using Microsoft.AspNetCore.Mvc.Filters; 6 | using Microsoft.AspNetCore.Mvc.ModelBinding; 7 | using Microsoft.AspNetCore.Routing; 8 | using Moq; 9 | using SmartResult.Unit.Tests.Mappings; 10 | using SmartResult.Unit.Tests.Models; 11 | using System.Collections.Generic; 12 | using Xunit; 13 | 14 | [assembly: CollectionBehavior(DisableTestParallelization = true)] 15 | namespace SmartResult.Unit.Tests 16 | { 17 | public class MobileTests 18 | { 19 | private readonly IRepository _repository; 20 | public MobileTests() 21 | { 22 | AspNet.Core.SmartResult.SmartResult.Reset(); 23 | _repository = new Repository(); 24 | } 25 | 26 | [Fact] 27 | public void Should_Return_Default_Result_When_Mobile_Not_Defined() 28 | { 29 | List profiles = new List 30 | { 31 | new SmartResultProfile(new CustomerTestProfile(), Client.Native) 32 | }; 33 | 34 | AspNet.Core.SmartResult.SmartResult.Configure( 35 | new SmartResultConfiguration( 36 | profiles 37 | ) 38 | ); 39 | 40 | var filter = new AspNet.Core.SmartResult.SmartResult(); 41 | 42 | // Mock out the context to run the action filter. 43 | var request = new Mock(); 44 | var requestHeaders = new HeaderDictionary(); 45 | requestHeaders.Add("User-Agent", Constants.AndroidMobileBrowser); 46 | request.SetupGet(r => r.Headers).Returns(requestHeaders); 47 | var response = new Mock(); 48 | response.SetupGet(r => r.Headers).Returns(new HeaderDictionary()); 49 | 50 | var httpContext = new Mock(); 51 | httpContext.SetupGet(c => c.Request).Returns(request.Object); 52 | httpContext.SetupGet(c => c.Response).Returns(response.Object); 53 | 54 | var modelState = new ModelStateDictionary(); 55 | 56 | var actionContext = new ActionContext( 57 | httpContext.Object, 58 | new Mock().Object, 59 | new Mock().Object, 60 | modelState 61 | ); 62 | 63 | var resultExecutedContext = new ResultExecutingContext(actionContext, 64 | new List(), 65 | new OkObjectResult(_repository.GetCustomers()), 66 | new Mock().Object); 67 | 68 | filter.OnResultExecuting(resultExecutedContext); 69 | var resultHeaderType = resultExecutedContext.HttpContext.Response.Headers["Result-Type"].ToString(); 70 | var result = resultExecutedContext.Result; 71 | 72 | // Assert 73 | Assert.IsAssignableFrom>((result as ObjectResult).Value); 74 | Assert.Equal("Default", resultHeaderType); 75 | } 76 | 77 | [Fact] 78 | public void Should_Return_Mobile_Result() 79 | { 80 | List profiles = new List 81 | { 82 | new SmartResultProfile(new CustomerTestProfile()) 83 | }; 84 | 85 | AspNet.Core.SmartResult.SmartResult.Configure( 86 | new SmartResultConfiguration( 87 | profiles 88 | ) 89 | ); 90 | 91 | var filter = new AspNet.Core.SmartResult.SmartResult(); 92 | 93 | // Mock out the context to run the action filter. 94 | var request = new Mock(); 95 | var requestHeaders = new HeaderDictionary(); 96 | requestHeaders.Add("User-Agent", Constants.AndroidMobileBrowser); 97 | request.SetupGet(r => r.Headers).Returns(requestHeaders); 98 | var response = new Mock(); 99 | response.SetupGet(r => r.Headers).Returns(new HeaderDictionary()); 100 | 101 | var httpContext = new Mock(); 102 | httpContext.SetupGet(c => c.Request).Returns(request.Object); 103 | httpContext.SetupGet(c => c.Response).Returns(response.Object); 104 | 105 | var modelState = new ModelStateDictionary(); 106 | 107 | var actionContext = new ActionContext( 108 | httpContext.Object, 109 | new Mock().Object, 110 | new Mock().Object, 111 | modelState 112 | ); 113 | 114 | var resultExecutedContext = new ResultExecutingContext(actionContext, 115 | new List(), 116 | new OkObjectResult(_repository.GetCustomers()), 117 | new Mock().Object); 118 | 119 | filter.OnResultExecuting(resultExecutedContext); 120 | var resultHeaderType = resultExecutedContext.HttpContext.Response.Headers["Result-Type"].ToString(); 121 | var result = resultExecutedContext.Result; 122 | 123 | // Assert 124 | Assert.IsAssignableFrom>((result as ObjectResult).Value); 125 | Assert.Equal("Mobile", resultHeaderType); 126 | } 127 | 128 | 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SmartResult.Unit.Tests.Models 7 | { 8 | public class Customer : MobileCustomer 9 | { 10 | public string PhoneNumber { get; set; } 11 | public int Age { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/Models/MobileCustomer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SmartResult.Unit.Tests.Models 7 | { 8 | public class MobileCustomer : NativeCustomer 9 | { 10 | public string Address { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/Models/NativeCustomer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SmartResult.Unit.Tests.Models 7 | { 8 | public class NativeCustomer 9 | { 10 | public int Id { get; set; } 11 | public string Name { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/NativeTests.cs: -------------------------------------------------------------------------------- 1 | using AspNet.Core.SmartResult; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.AspNetCore.Mvc.Abstractions; 5 | using Microsoft.AspNetCore.Mvc.Filters; 6 | using Microsoft.AspNetCore.Mvc.ModelBinding; 7 | using Microsoft.AspNetCore.Routing; 8 | using Moq; 9 | using SmartResult.Unit.Tests.Mappings; 10 | using SmartResult.Unit.Tests.Models; 11 | using System.Collections.Generic; 12 | using Xunit; 13 | 14 | namespace SmartResult.Unit.Tests 15 | { 16 | public class NativeTests 17 | { 18 | private readonly IRepository _repository; 19 | public NativeTests() 20 | { 21 | AspNet.Core.SmartResult.SmartResult.Reset(); 22 | _repository = new Repository(); 23 | } 24 | 25 | [Fact] 26 | public void Should_Return_Native_Result() 27 | { 28 | List profiles = new List 29 | { 30 | new SmartResultProfile(new CustomerTestProfile()) 31 | }; 32 | 33 | AspNet.Core.SmartResult.SmartResult.Configure( 34 | new SmartResultConfiguration( 35 | profiles, 36 | isNative: IsNativeDevice 37 | ) 38 | ); 39 | 40 | var filter = new AspNet.Core.SmartResult.SmartResult(); 41 | 42 | // Mock out the context to run the action filter. 43 | var request = new Mock(); 44 | var requestHeaders = new HeaderDictionary(); 45 | requestHeaders.Add("Native-Header", "I am a native device"); 46 | request.SetupGet(r => r.Headers).Returns(requestHeaders); 47 | var response = new Mock(); 48 | response.SetupGet(r => r.Headers).Returns(new HeaderDictionary()); 49 | 50 | var httpContext = new Mock(); 51 | httpContext.SetupGet(c => c.Request).Returns(request.Object); 52 | httpContext.SetupGet(c => c.Response).Returns(response.Object); 53 | 54 | var modelState = new ModelStateDictionary(); 55 | 56 | var actionContext = new ActionContext( 57 | httpContext.Object, 58 | new Mock().Object, 59 | new Mock().Object, 60 | modelState 61 | ); 62 | 63 | var resultExecutedContext = new ResultExecutingContext(actionContext, 64 | new List(), 65 | new OkObjectResult(_repository.GetCustomers()), 66 | new Mock().Object); 67 | 68 | filter.OnResultExecuting(resultExecutedContext); 69 | var resultHeaderType = resultExecutedContext.HttpContext.Response.Headers["Result-Type"].ToString(); 70 | var result = resultExecutedContext.Result; 71 | 72 | // Assert 73 | Assert.IsAssignableFrom>((result as ObjectResult).Value); 74 | } 75 | 76 | [Fact] 77 | public void Should_Return_Default_Result_When_Native_Type_Not_Defined() 78 | { 79 | List profiles = new List 80 | { 81 | new SmartResultProfile (new CustomerTestProfile(),Client.Mobile) 82 | }; 83 | 84 | AspNet.Core.SmartResult.SmartResult.Configure( 85 | new SmartResultConfiguration( 86 | profiles, 87 | isNative: IsNativeDevice 88 | ) 89 | ); 90 | 91 | var filter = new AspNet.Core.SmartResult.SmartResult(); 92 | 93 | // Mock out the context to run the action filter. 94 | var request = new Mock(); 95 | var requestHeaders = new HeaderDictionary(); 96 | requestHeaders.Add("Native-Header", "I am a native device"); 97 | request.SetupGet(r => r.Headers).Returns(requestHeaders); 98 | var response = new Mock(); 99 | response.SetupGet(r => r.Headers).Returns(new HeaderDictionary()); 100 | 101 | var httpContext = new Mock(); 102 | httpContext.SetupGet(c => c.Request).Returns(request.Object); 103 | httpContext.SetupGet(c => c.Response).Returns(response.Object); 104 | 105 | var modelState = new ModelStateDictionary(); 106 | 107 | var actionContext = new ActionContext( 108 | httpContext.Object, 109 | new Mock().Object, 110 | new Mock().Object, 111 | modelState 112 | ); 113 | 114 | var resultExecutedContext = new ResultExecutingContext(actionContext, 115 | new List(), 116 | new OkObjectResult(_repository.GetCustomers()), 117 | new Mock().Object); 118 | 119 | filter.OnResultExecuting(resultExecutedContext); 120 | var resultHeaderType = resultExecutedContext.HttpContext.Response.Headers["Result-Type"].ToString(); 121 | var result = resultExecutedContext.Result; 122 | 123 | // Assert 124 | Assert.IsAssignableFrom>((result as ObjectResult).Value); 125 | Assert.Equal(expected: "Default", actual: resultHeaderType); 126 | } 127 | 128 | private bool IsNativeDevice(HttpContext request) 129 | { 130 | return !string.IsNullOrEmpty(request.Request.Headers["Native-Header"]); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/Repository.cs: -------------------------------------------------------------------------------- 1 | using SmartResult.Unit.Tests.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace SmartResult.Unit.Tests 8 | { 9 | public class Repository : IRepository 10 | { 11 | static List Customers = new List 12 | { 13 | new Customer() { Id = 1, Name = "Christos", Address = "Athens", Age = 32, PhoneNumber = "123456789"}, 14 | new Customer() { Id = 2, Name = "John", Address = "Paris", Age = 44, PhoneNumber = "253525252"}, 15 | new Customer() { Id = 3, Name = "Mary", Address = "Milano", Age = 35, PhoneNumber = "425225252"} 16 | }; 17 | //static Repository 18 | public Customer GetCustomer(int id) 19 | { 20 | return Customers.FirstOrDefault(c => c.Id == id); 21 | } 22 | 23 | public IEnumerable GetCustomers() 24 | { 25 | return Customers; 26 | } 27 | } 28 | 29 | public interface IRepository 30 | { 31 | IEnumerable GetCustomers(); 32 | Customer GetCustomer(int id); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SmartResult.Unit.Tests/SmartResult.Unit.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.2 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SmartResult/ISmartResultProfile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AutoMapper; 3 | 4 | namespace SmartResult 5 | { 6 | public interface ISmartResultProfile : ISmartResultProfile 7 | { 8 | Type Desktop { get; } 9 | Type Mobile { get; } 10 | Type Native { get; } 11 | } 12 | 13 | public interface ISmartResultProfile : ISmartResultProfile 14 | { 15 | Type Desktop { get; } 16 | Type MobileOrNative { get; } 17 | } 18 | 19 | public interface ISmartResultProfile 20 | { 21 | Profile Profile { get; } 22 | } 23 | 24 | public enum Client 25 | { 26 | Mobile, 27 | Native 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SmartResult/RequestExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace AspNet.Core.SmartResult 8 | { 9 | internal static class RequestExtensions 10 | { 11 | //regex from http://detectmobilebrowsers.com/ 12 | private static readonly Regex b = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline); 13 | private static readonly Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline); 14 | 15 | public static bool IsMobileBrowser(this HttpRequest request) 16 | { 17 | var userAgent = request.UserAgent(); 18 | if (userAgent != null && (b.IsMatch(userAgent) || v.IsMatch(userAgent.Substring(0, 4)))) 19 | { 20 | return true; 21 | } 22 | 23 | return false; 24 | } 25 | 26 | public static string UserAgent(this HttpRequest request) 27 | { 28 | return request.Headers["User-Agent"]; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SmartResult/SmartResult.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.AspNetCore.Mvc.Filters; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Resources; 8 | using System.Text; 9 | using SmartResult; 10 | 11 | namespace AspNet.Core.SmartResult 12 | { 13 | public class SmartResult : Attribute, IResultFilter 14 | { 15 | private static SmartResultConfiguration _configuration; 16 | 17 | #region Mapper 18 | 19 | static MapperConfiguration _mapperConfiguration; 20 | static IMapper _mapper; 21 | 22 | #endregion 23 | 24 | #region Properties 25 | 26 | /// 27 | /// The Default returned Type. Usually configured for desktop 28 | /// 29 | private Type _desktop; 30 | 31 | /// 32 | /// The returned Type for Mobile browsers 33 | /// 34 | private Type _mobile; 35 | 36 | /// 37 | /// The returned Type for native devices 38 | /// 39 | private Type _native; 40 | 41 | #endregion 42 | 43 | #region Methods 44 | 45 | static IsMobile isMobile; 46 | static IsNative isNative; 47 | 48 | #endregion 49 | 50 | #region Processing 51 | 52 | public void OnResultExecuting(ResultExecutingContext context) 53 | { 54 | if (context.Result is ObjectResult objectResult) 55 | { 56 | if (!CanProcess(objectResult.Value.GetType())) 57 | { 58 | context.HttpContext.Response.Headers.Add("Result-Type", "Default"); 59 | return; 60 | } 61 | 62 | var isMobileBrowser = isMobile != null && isMobile(context.HttpContext); 63 | var isNativeDevice = isNative != null && isNative(context.HttpContext); 64 | 65 | 66 | Type resultType = GetType(objectResult.Value.GetType()); 67 | Type mobileType = _mobile != null ? GetType(_mobile) : null; 68 | Type nativeType = _native != null ? GetType(_native) : null; 69 | 70 | if (_mobile != null && isMobileBrowser && resultType != mobileType) 71 | { 72 | objectResult.Value = _mapper.Map(objectResult.Value, _desktop, _mobile); 73 | context.HttpContext.Response.Headers.Add("Result-Type", "Mobile"); 74 | } 75 | else if (_native != null && isNativeDevice && resultType != nativeType) 76 | { 77 | objectResult.Value = _mapper.Map(objectResult.Value, _desktop, _native); 78 | context.HttpContext.Response.Headers.Add("Result-Type", "Native"); 79 | } 80 | else 81 | { 82 | context.HttpContext.Response.Headers.Add("Result-Type", "Default"); 83 | } 84 | } 85 | } 86 | 87 | #endregion 88 | 89 | #region Configuration 90 | public static void Configure(SmartResultConfiguration configuration) 91 | { 92 | _configuration = configuration; 93 | 94 | _mapperConfiguration = new MapperConfiguration(cfg => 95 | { 96 | configuration.Profiles.ForEach(p => 97 | { 98 | cfg.AddProfile(p.Profile); 99 | }); 100 | }); 101 | _mapper = _mapperConfiguration.CreateMapper(); 102 | 103 | isMobile = configuration.IsMobileBrowser(); 104 | isNative = configuration.IsNativeDevice(); 105 | } 106 | 107 | public static void Reset() 108 | { 109 | _configuration = null; 110 | _mapper = null; 111 | isMobile = null; 112 | isNative = null; 113 | } 114 | 115 | #endregion 116 | 117 | private Type GetType(Type type) 118 | { 119 | Type objectType = type; 120 | 121 | foreach (Type interfaceType in type.GetInterfaces()) 122 | { 123 | if (interfaceType.IsGenericType && 124 | interfaceType.GetGenericTypeDefinition() 125 | == typeof(IList<>)) 126 | { 127 | objectType = type.GetGenericArguments()[0]; 128 | break; 129 | } 130 | else 131 | { 132 | objectType = type.GetGenericArguments()[0]; 133 | } 134 | } 135 | 136 | return objectType; 137 | } 138 | 139 | private Type CreateType(Type defaultType, Type type) 140 | { 141 | Type objectType = type; 142 | 143 | foreach (Type interfaceType in defaultType.GetInterfaces()) 144 | { 145 | if (interfaceType.IsGenericType && 146 | interfaceType.GetGenericTypeDefinition() 147 | == typeof(IList<>)) 148 | { 149 | objectType = typeof(List<>).MakeGenericType(type); 150 | break; 151 | } 152 | } 153 | 154 | return objectType; 155 | } 156 | 157 | private bool CanProcess(Type type) 158 | { 159 | var baseType = GetType(type); 160 | 161 | var config = GetProfile(baseType); 162 | 163 | if (config == null) 164 | return false; 165 | 166 | var mobileType = GetClientType(config, Client.Mobile); 167 | var nativeType = GetClientType(config, Client.Native); 168 | 169 | var canProcess = (mobileType != null || nativeType != null) && _mapper != null; 170 | 171 | if (canProcess) 172 | { 173 | _desktop = type; 174 | 175 | if (mobileType != null) 176 | { 177 | _mobile = CreateType(type, mobileType); 178 | } 179 | 180 | if (nativeType != null) 181 | { 182 | _native = CreateType(type, nativeType); 183 | } 184 | } 185 | 186 | //return canProcess; 187 | return true; 188 | } 189 | 190 | private ISmartResultProfile GetProfile(Type desktopType) 191 | { 192 | ISmartResultProfile profile = null; 193 | 194 | foreach (var smartProfile in _configuration.Profiles) 195 | { 196 | var baseType = smartProfile.GetType().GetProperty("Desktop") 197 | .GetValue(smartProfile, null); 198 | 199 | if (baseType != null && (Type)baseType == desktopType) 200 | { 201 | profile = smartProfile; 202 | break; 203 | } 204 | } 205 | 206 | return profile; 207 | } 208 | 209 | private Type GetClientType(ISmartResultProfile profile, Client type) 210 | { 211 | var mobileType = (Type)profile.GetType().GetProperty(type.ToString()) 212 | .GetValue(profile, null); 213 | 214 | return mobileType; 215 | } 216 | 217 | public void OnResultExecuted(ResultExecutedContext context) 218 | { 219 | 220 | } 221 | } 222 | } -------------------------------------------------------------------------------- /SmartResult/SmartResult.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | AspNet.Core.SmartResult 6 | AspNet.Core.SmartResult 7 | chsakell's Blog 8 | Christos Sakellarios 9 | https://github.com/chsakell/aspnet-core-smartresult 10 | Result filter for ASP.NET Core MVC Controllers that can produce multiple types of results for the same action. Used in multi-client APIs that need to serve different types of results per device 11 | https://github.com/chsakell/aspnet-core-smartresult 12 | smart result cross platform chsakell aspnet core web mapper result map 13 | Result filter for ASP.NET Core MVC Controllers that can produce multiple types of results for the same action 14 | 2.2.2 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /SmartResult/SmartResultConfiguration.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using Microsoft.AspNetCore.Http; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using SmartResult; 7 | 8 | namespace AspNet.Core.SmartResult 9 | { 10 | #region Detection 11 | 12 | public delegate bool IsMobile(HttpContext context); 13 | public delegate bool IsNative(HttpContext context); 14 | 15 | #endregion 16 | 17 | /// 18 | /// Configuration for SmartResult 19 | /// 20 | public class SmartResultConfiguration 21 | { 22 | readonly IsMobile isMobile; 23 | readonly IsNative isNative; 24 | 25 | public List Profiles { get; } 26 | 27 | public SmartResultConfiguration(List profiles, IsMobile isMobile = null, IsNative isNative = null) 28 | { 29 | this.Profiles = profiles; 30 | this.isMobile = isMobile ?? IsMobileBrowser; 31 | this.isNative = isNative; 32 | } 33 | 34 | private bool IsMobileBrowser(HttpContext context) 35 | { 36 | return context.Request.IsMobileBrowser(); 37 | } 38 | 39 | public IsMobile IsMobileBrowser() 40 | { 41 | return this.isMobile; 42 | } 43 | 44 | public IsNative IsNativeDevice() 45 | { 46 | return this.isNative; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /SmartResult/SmartResultProfile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AutoMapper; 3 | 4 | namespace SmartResult 5 | { 6 | public class SmartResultProfile : ISmartResultProfile, ISmartResultProfile 7 | { 8 | public Profile Profile { get; } 9 | 10 | public Type Desktop => typeof(D); 11 | 12 | public Type Mobile => typeof(M); 13 | 14 | public Type Native => typeof(N); 15 | 16 | public SmartResultProfile(Profile profile) 17 | { 18 | Profile = profile; 19 | } 20 | } 21 | 22 | public class SmartResultProfile : ISmartResultProfile, ISmartResultProfile 23 | { 24 | public Profile Profile { get; } 25 | 26 | public Type Desktop => typeof(D); 27 | 28 | public Type Mobile => Client == Client.Mobile ? typeof(T) : null; 29 | 30 | public Type Native => Client == Client.Native ? typeof(T) : null; 31 | 32 | public Type MobileOrNative => typeof(T); 33 | 34 | public Client Client { get; } 35 | 36 | public SmartResultProfile(Profile profile, Client client) 37 | { 38 | Profile = profile; 39 | Client = client; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '2.0.{build}' 2 | image: Visual Studio 2017 3 | branches: 4 | only: 5 | - master 6 | clone_depth: 1 7 | init: 8 | # Good practise, because Windows 9 | - git config --global core.autocrlf true 10 | 11 | # Install scripts. (runs after repo cloning) 12 | install: 13 | # Get the latest stable version of Node.js or io.js 14 | # - ps: Install-Product node $env:nodejs_version 15 | - cd SmartResult 16 | before_build: 17 | # Display minimal restore text 18 | - cmd: dotnet restore --verbosity m 19 | build_script: 20 | - cmd: dotnet publish -c Release 21 | 22 | # scripts to run before tests 23 | before_test: 24 | - cd ../SmartResult.Unit.Tests 25 | - cmd: dotnet restore --verbosity m 26 | - cd ../SmartResult.Integration.Tests 27 | - cmd: dotnet restore --verbosity m 28 | 29 | # scripts to run after tests 30 | after_test: 31 | 32 | # to run your custom scripts instead of automatic tests 33 | test_script: 34 | - cd ../SmartResult.Unit.Tests 35 | - cmd: dotnet test 36 | - cd ../SmartResult.Integration.Tests 37 | - cmd: dotnet test 38 | -------------------------------------------------------------------------------- /smart-result.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2043 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmartResult", "SmartResult\SmartResult.csproj", "{D9367210-1DB9-402B-A62E-5D3DBD818639}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "package", "package", "{E160B723-702E-44B9-BACF-39D46A5D2404}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{4D24DACD-45B5-4985-812D-5B229B640B50}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmartResult.Demo", "SmartResult.Demo\SmartResult.Demo.csproj", "{DD081A91-EA47-455B-AEE5-2E4B2135E417}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D0C4BDCE-EC64-405C-BC34-E9353F466025}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmartResult.Integration.Tests", "SmartResult.Integration.Tests\SmartResult.Integration.Tests.csproj", "{D5620F24-6AA3-4C09-8EE8-C6D72FA09A41}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartResult.Unit.Tests", "SmartResult.Unit.Tests\SmartResult.Unit.Tests.csproj", "{346D88DC-8BAA-4265-976C-7EDDF1B7E04A}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Release|Any CPU = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {D9367210-1DB9-402B-A62E-5D3DBD818639}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {D9367210-1DB9-402B-A62E-5D3DBD818639}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {D9367210-1DB9-402B-A62E-5D3DBD818639}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {D9367210-1DB9-402B-A62E-5D3DBD818639}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {DD081A91-EA47-455B-AEE5-2E4B2135E417}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {DD081A91-EA47-455B-AEE5-2E4B2135E417}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {DD081A91-EA47-455B-AEE5-2E4B2135E417}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {DD081A91-EA47-455B-AEE5-2E4B2135E417}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {D5620F24-6AA3-4C09-8EE8-C6D72FA09A41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {D5620F24-6AA3-4C09-8EE8-C6D72FA09A41}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {D5620F24-6AA3-4C09-8EE8-C6D72FA09A41}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {D5620F24-6AA3-4C09-8EE8-C6D72FA09A41}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {346D88DC-8BAA-4265-976C-7EDDF1B7E04A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {346D88DC-8BAA-4265-976C-7EDDF1B7E04A}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {346D88DC-8BAA-4265-976C-7EDDF1B7E04A}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {346D88DC-8BAA-4265-976C-7EDDF1B7E04A}.Release|Any CPU.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | GlobalSection(NestedProjects) = preSolution 47 | {D9367210-1DB9-402B-A62E-5D3DBD818639} = {E160B723-702E-44B9-BACF-39D46A5D2404} 48 | {DD081A91-EA47-455B-AEE5-2E4B2135E417} = {4D24DACD-45B5-4985-812D-5B229B640B50} 49 | {D5620F24-6AA3-4C09-8EE8-C6D72FA09A41} = {D0C4BDCE-EC64-405C-BC34-E9353F466025} 50 | {346D88DC-8BAA-4265-976C-7EDDF1B7E04A} = {D0C4BDCE-EC64-405C-BC34-E9353F466025} 51 | EndGlobalSection 52 | GlobalSection(ExtensibilityGlobals) = postSolution 53 | SolutionGuid = {357FB8C6-7D56-4307-8431-F04C3549787C} 54 | EndGlobalSection 55 | EndGlobal 56 | --------------------------------------------------------------------------------