Browse Source

Merge branch 'order-processflow-redesign' of https://github.com/dotnet-architecture/eShopOnContainers into order-processflow-redesign

# Conflicts:
#	eShopOnContainers-ServicesAndWebApps.sln
pull/809/head
Christian Arenas 7 years ago
parent
commit
c5cca8f320
126 changed files with 2560 additions and 986 deletions
  1. +8
    -7
      README.md
  2. +0
    -1
      docker-compose.override.yml
  3. +0
    -1
      docker-compose.prod.yml
  4. BIN
      docs/Enterprise-Application-Patterns-using-XamarinForms.pdf
  5. BIN
      docs/architecting-and-developing-containerized-and-microservice-based-net-applications-ebook-early-draft.pdf
  6. +153
    -102
      eShopOnContainers-ServicesAndWebApps.sln
  7. BIN
      img/ebook_arch_dev_microservices_containers_cover.png
  8. BIN
      img/ebook_arch_dev_microservices_containers_cover_LARGE.png
  9. BIN
      img/ebook_arch_dev_microservices_containers_cover_OLD.png
  10. BIN
      img/xamarin-enterprise-patterns-ebook-cover-small.png
  11. +8
    -0
      src/BuildingBlocks/CommandBus/CommandBus/CommandBus.csproj
  12. +13
    -0
      src/BuildingBlocks/CommandBus/CommandBus/ICommandBus.cs
  13. +18
    -0
      src/BuildingBlocks/CommandBus/CommandBus/IntegrationCommand.cs
  14. +7
    -0
      src/BuildingBlocks/CommandBus/CommandBusRabbitMQ/CommandBusRabbitMQ.csproj
  15. +8
    -0
      src/BuildingBlocks/EventBus/CommandBus/CommandBus.csproj
  16. +16
    -0
      src/BuildingBlocks/EventBus/CommandBus/ICommandBus.cs
  17. +16
    -0
      src/BuildingBlocks/EventBus/CommandBus/IIntegrationCommandHandler.cs
  18. +35
    -0
      src/BuildingBlocks/EventBus/CommandBus/IntegrationCommand.cs
  19. +22
    -0
      src/BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj
  20. +56
    -0
      src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs
  21. +11
    -0
      src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEvent.cs
  22. +23
    -0
      src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs
  23. +23
    -0
      src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs
  24. +13
    -0
      src/BuildingBlocks/EventBus/EventBus/Abstractions/IDynamicIntegrationEventHandler.cs
  25. +14
    -2
      src/BuildingBlocks/EventBus/EventBus/Abstractions/IEventBus.cs
  26. +0
    -4
      src/BuildingBlocks/EventBus/EventBus/EventBus.csproj
  27. +34
    -0
      src/BuildingBlocks/EventBus/EventBus/IEventBusSubscriptionsManager.cs
  28. +162
    -0
      src/BuildingBlocks/EventBus/EventBus/InMemoryEventBusSubscriptionsManager.cs
  29. +28
    -0
      src/BuildingBlocks/EventBus/EventBus/SubscriptionInfo.cs
  30. +145
    -0
      src/BuildingBlocks/EventBus/EventBusRabbitMQ/CommandBusRabbitMQ.cs
  31. +6
    -6
      src/BuildingBlocks/EventBus/EventBusRabbitMQ/DefaultRabbitMQPersisterConnection.cs
  32. +88
    -79
      src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs
  33. +1
    -2
      src/BuildingBlocks/EventBus/EventBusRabbitMQ/IRabbitMQPersisterConnection.cs
  34. +15
    -7
      src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/HealthCheckMiddleware.cs
  35. +11
    -4
      src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/HealthCheckStartupFilter.cs
  36. +16
    -5
      src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/HealthCheckWebHostBuilderExtension.cs
  37. +2
    -2
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/HealthCheckBuilderSqlServerExtensions.cs
  38. +0
    -0
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj
  39. +109
    -0
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/CachedHealthCheck.cs
  40. +19
    -0
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/CachedHealthCheckExtensions.cs
  41. +30
    -24
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Checks/AddCheck.cs
  42. +5
    -5
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Checks/NumericChecks.cs
  43. +1
    -64
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Checks/UrlChecks.cs
  44. +11
    -8
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/CompositeHealthCheckResult.cs
  45. +15
    -49
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheck.cs
  46. +102
    -7
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckBuilder.cs
  47. +0
    -18
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckExtensions.cs
  48. +37
    -0
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckGroup.cs
  49. +0
    -1
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckResult.cs
  50. +91
    -26
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckService.cs
  51. +13
    -5
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckServiceCollectionExtensions.cs
  52. +0
    -38
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckServiceExtensions.cs
  53. +1
    -4
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/IHealthCheck.cs
  54. +46
    -1
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/IHealthCheckService.cs
  55. +18
    -42
      src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Internal/UrlChecker.cs
  56. +22
    -10
      src/BuildingBlocks/HealthChecks/src/common/Guard.cs
  57. +1
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs
  58. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Behaviors/EventToCommandBehavior.cs
  59. +0
    -3
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Helpers/Settings.cs
  60. +5
    -7
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketService.cs
  61. +0
    -7
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs
  62. +11
    -24
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs
  63. +0
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs
  64. +2
    -5
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Identity/IIdentityService.cs
  65. +3
    -33
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Identity/IdentityService.cs
  66. +0
    -8
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/RequestProvider/IRequestProvider.cs
  67. +2
    -46
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/RequestProvider/RequestProvider.cs
  68. +35
    -35
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/Base/ViewModelLocator.cs
  69. +0
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs
  70. +2
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs
  71. +1
    -4
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/OrderDetailViewModel.cs
  72. +3
    -5
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/SettingsViewModel.cs
  73. +2
    -80
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj
  74. +0
    -21
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/packages.config
  75. +25
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/project.json
  76. +2
    -11
      src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj
  77. +0
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Droid/packages.config
  78. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/MainActivity.cs
  79. +1
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj
  80. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Windows/App.xaml.cs
  81. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/AppDelegate.cs
  82. +6
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj
  83. +1
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/packages.config
  84. +120
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Behaviors/EventToCommandBehaviorTests.cs
  85. +0
    -27
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/DummyTests.cs
  86. +12
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockEventToCommandBehavior.cs
  87. +53
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockViewModel.cs
  88. +0
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Services/BasketServiceTests.cs
  89. +0
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Services/CatalogServiceTests.cs
  90. +9
    -11
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Services/OrdersServiceTests.cs
  91. +223
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/ViewModels/CatalogViewModelTests.cs
  92. +54
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/ViewModels/MainViewModelTests.cs
  93. +113
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/ViewModels/MockViewModelTests.cs
  94. +55
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/ViewModels/OrderViewModelTests.cs
  95. +26
    -4
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/eShopOnContainers.UnitTests.csproj
  96. +8
    -7
      src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/packages.config
  97. +0
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Windows/project.json
  98. +0
    -4
      src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj
  99. +0
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.iOS/packages.config
  100. +0
    -1
      src/Services/Basket/Basket.API/Basket.API.csproj

+ 8
- 7
README.md View File

@ -1,12 +1,13 @@
# eShopOnContainers - Microservices Architecture and Containers based Reference Application (**ALPHA state** - VS 2017 and CLI environments compatible)
# eShopOnContainers - Microservices Architecture and Containers based Reference Application (**BETA state** - Visual Studio 2017 and CLI environments compatible)
Sample .NET Core reference application, powered by Microsoft, based on a simplified microservices architecture and Docker containers. <p>
> ### DISCLAIMER
> **IMPORTANT:** The current state of this sample application is **ALPHA**, consider it version a 0.1 foundational version, therefore, many areas could be improved and change significantly while refactoring current code and implementing new features. **Feedback with improvements and pull requests from the community will be highly appreciated and accepted.**
> **IMPORTANT:** The current state of this sample application is **BETA**, consider it version a 0.1 foundational version, therefore, many areas could be improved and change significantly while refactoring current code and implementing new features. **Feedback with improvements and pull requests from the community will be highly appreciated and accepted.**
>
> This reference application proposes a simplified microservice oriented architecture implementation to introduce technologies like .NET Core with Docker containers through a comprehensive application. However, this reference application it is not trying to solve all the problems in a large and mission-critical distributed system, it is just a bootstrap for developers to easily get started in the world of Docker containers and microservices with .NET Core.
> This reference application proposes a simplified microservice oriented architecture implementation to introduce technologies like .NET Core with Docker containers through a comprehensive application. The chosen domain is an eShop/eCommerce but simply because it is a well-know domain by most people/developers.
However, this sample application should not be considered as an "eCommerce reference model", at all. The implemented business domain might not be ideal from an eCommerce business point of view. It is neither trying to solve all the problems in a large, scalable and mission-critical distributed system. It is just a bootstrap for developers to easily get started in the world of Docker containers and microservices with .NET Core.
> <p>For example, the next step (still not covered in eShopOnContainers) after understanding Docker containers and microservices development with .NET Core, is to select a microservice cluster/orchestrator like Docker Swarm, Kubernetes or DC/OS (in Azure Container Service) or Azure Service Fabric which in most of the cases will require additional partial changes to your application's configuration (although the present architecture should work on most orchestrators with small changes).
> Or moving your databases to HA cloud services, or implementing your EventBus with Azure Service Bus or any other production ready Service Bus in the market.
> Additional steps would be to move your databases to HA cloud services, or to implement your EventBus with Azure Service Bus or any other production ready Service Bus in the market.
> <p> In the future we might fork this project and make multiple versions targeting specific microservice cluster/orchestrators plus using additional cloud infrastructure. <p>
> <img src="img/exploring-to-production-ready.png">
> Read the planned <a href='https://github.com/dotnet/eShopOnContainers/wiki/01.-Roadmap-and-Milestones-for-future-releases'>Roadmap and Milestones for future releases of eShopOnContainers</a> within the Wiki for further info about possible new implementations and provide feedback at the <a href='https://github.com/dotnet/eShopOnContainers/issues'>ISSUES section</a> if you'd like to see any specific scenario implemented or improved. Also, feel free to discuss on any current issue.
@ -32,7 +33,7 @@ Additional miroservice styles with other frameworks and No-SQL databases will be
> <p> However, in a real production environment it is recommended to have your databases (SQL Server and Redis, in this case) in HA (High Available) services like Azure SQL Database, Redis as a service or any other clustering system. If you want to change to a production configuration, you'll just need to change the connection strings once you have set up the servers in a HA cloud or on-premises.
## Related documentation and guidance
While developing this reference application, we are creating a reference Guide/eBook named <b>"Architecting and Developing Containerized and Microservice based .NET Applications"</b> which explains in detail how to develop this kind of architectural style (microservices, Docker containers, Domain-Driven Design for certain microservices) plus other simpler architectural styles, like monolithic apps that can also live as Docker containers.
While developing this reference application, we've been creating a reference <b>Guide/eBook</b> focusing on <b>architecting and developing containerized and microservice based .NET Applications</b> (download link available below) which explains in detail how to develop this kind of architectural style (microservices, Docker containers, Domain-Driven Design for certain microservices) plus other simpler architectural styles, like monolithic apps that can also live as Docker containers.
<p>
There are also additional eBooks focusing on Containers/Docker lifecycle (DevOps, CI/CD, etc.) with Microsoft Tools, already published plus an additional eBook focusing on Enterprise Apps Patterns with Xamarin.Forms.
You can download them and start reviewing these Guides/eBooks here:
@ -41,9 +42,9 @@ You can download them and start reviewing these Guides/eBooks here:
| Architecting & Developing | Containers Lifecycle & CI/CD | App patterns with Xamarin.Forms |
| ------------ | ------------| ------------|
| <a href='https://aka.ms/microservicesebook'><img src="img/ebook_arch_dev_microservices_containers_cover.png"> </a> | <a href='https://aka.ms/dockerlifecycleebook'> <img src="img/ebook_containers_lifecycle.png"> </a> | <a href='https://aka.ms/xamarinpatternsebook'> <img src="img/xamarin-enterprise-patterns-ebook-cover-small.png"> </a> |
| <sup> <a href='https://aka.ms/microservicesebook'>**Download** (Early DRAFT, still work in progress)</a> </sup> | <sup> <a href='https://aka.ms/dockerlifecycleebook'>**Download** (First Edition from late 2016) </a> </sup> | <sup> <a href='https://aka.ms/xamarinpatternsebook'>**Download** (Early DRAFT, still work in progress) </a> </sup> |
| <sup> <a href='https://aka.ms/microservicesebook'>**Download** (Early DRAFT, still work in progress)</a> </sup> | <sup> <a href='https://aka.ms/dockerlifecycleebook'>**Download** (First Edition from late 2016) </a> </sup> | <sup> <a href='https://aka.ms/xamarinpatternsebook'>**Download** (Preview Edition) </a> </sup> |
Send feedback to [cesardl@microsoft.com](cesardl@microsoft.com)
Send feedback to [dotnet-architecture-ebooks-feedback@service.microsoft.com](dotnet-architecture-ebooks-feedback@service.microsoft.com)
<p>
However, we encourage to download and review the "Architecting & Developing eBook" because the architectural styles and architectural patterns and technologies explained in the guidance are using this reference application when explaining many pattern implementations, so you'll understand much better the context, design and decisions taken in the current architecture and internal designs.


+ 0
- 1
docker-compose.override.yml View File

@ -50,7 +50,6 @@ services:
- ASPNETCORE_URLS=http://0.0.0.0:5102
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word
- identityUrl=http://identity.api:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
- BasketUrl=http://basket.api:5103
- EventBusConnection=rabbitmq
ports:
- "5102:5102"


+ 0
- 1
docker-compose.prod.yml View File

@ -50,7 +50,6 @@ services:
- ASPNETCORE_URLS=http://0.0.0.0:5102
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word
- identityUrl=http://identity.api:5105 #Local: You need to open your host's firewall at range 5100-5105. at range 5100-5105.
- BasketUrl=http://basket.api:5103
- EventBusConnection=rabbitmq
ports:
- "5102:5102"


BIN
docs/Enterprise-Application-Patterns-using-XamarinForms.pdf View File


BIN
docs/architecting-and-developing-containerized-and-microservice-based-net-applications-ebook-early-draft.pdf View File


+ 153
- 102
eShopOnContainers-ServicesAndWebApps.sln View File

@ -62,12 +62,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationEventLogEF", "sr
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HealthChecks", "HealthChecks", "{A81ECBC2-6B00-4DCD-8388-469174033379}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.HealthChecks", "src\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj", "{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.HealthChecks", "src\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj", "{942ED6E8-0050-495F-A0EA-01E97F63760C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.HealthChecks.Data", "src\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.Data\Microsoft.Extensions.HealthChecks.Data.csproj", "{7804FC60-23E6-490C-8E08-F9FEF829F184}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebStatus", "src\Web\WebStatus\WebStatus.csproj", "{C0A7918D-B4F2-4E7F-8DE2-1E5279EF079F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Resilience", "Resilience", "{FBF43D93-F2E7-4FF8-B4AB-186895949B88}"
@ -82,6 +78,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SagaManager", "SagaManager"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SagaManager", "src\Services\SagaManager\SagaManager\SagaManager.csproj", "{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.HealthChecks", "src\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj", "{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.HealthChecks.SqlServer", "src\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj", "{4BD76717-3102-4969-8C2C-BAAA3F0263B6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventBus.Tests", "src\BuildingBlocks\EventBus\EventBus.Tests\EventBus.Tests.csproj", "{4A980AC4-7205-46BF-8CCB-09E44D700FD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@ -720,54 +722,6 @@ Global
{9EE28E45-1533-472B-8267-56C48855BA0E}.Release|x64.Build.0 = Release|Any CPU
{9EE28E45-1533-472B-8267-56C48855BA0E}.Release|x86.ActiveCfg = Release|Any CPU
{9EE28E45-1533-472B-8267-56C48855BA0E}.Release|x86.Build.0 = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|ARM.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|iPhone.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|x64.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|x64.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|x86.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.AppStore|x86.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|ARM.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|iPhone.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|x64.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|x64.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|x86.ActiveCfg = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Debug|x86.Build.0 = Debug|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|Any CPU.Build.0 = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|ARM.ActiveCfg = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|ARM.Build.0 = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|iPhone.ActiveCfg = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|iPhone.Build.0 = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|x64.ActiveCfg = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|x64.Build.0 = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|x86.ActiveCfg = Release|Any CPU
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E}.Release|x86.Build.0 = Release|Any CPU
{942ED6E8-0050-495F-A0EA-01E97F63760C}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{942ED6E8-0050-495F-A0EA-01E97F63760C}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{942ED6E8-0050-495F-A0EA-01E97F63760C}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
@ -816,54 +770,6 @@ Global
{942ED6E8-0050-495F-A0EA-01E97F63760C}.Release|x64.Build.0 = Release|Any CPU
{942ED6E8-0050-495F-A0EA-01E97F63760C}.Release|x86.ActiveCfg = Release|Any CPU
{942ED6E8-0050-495F-A0EA-01E97F63760C}.Release|x86.Build.0 = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|ARM.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|iPhone.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|x64.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|x64.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|x86.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.AppStore|x86.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|ARM.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|iPhone.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|x64.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|x64.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|x86.ActiveCfg = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Debug|x86.Build.0 = Debug|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|Any CPU.Build.0 = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|ARM.ActiveCfg = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|ARM.Build.0 = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|iPhone.ActiveCfg = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|iPhone.Build.0 = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|x64.ActiveCfg = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|x64.Build.0 = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|x86.ActiveCfg = Release|Any CPU
{7804FC60-23E6-490C-8E08-F9FEF829F184}.Release|x86.Build.0 = Release|Any CPU
{C0A7918D-B4F2-4E7F-8DE2-1E5279EF079F}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{C0A7918D-B4F2-4E7F-8DE2-1E5279EF079F}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{C0A7918D-B4F2-4E7F-8DE2-1E5279EF079F}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
@ -1008,6 +914,150 @@ Global
{1A01AF82-6FCB-464C-B39C-F127AEBD315D}.Release|x64.Build.0 = Release|Any CPU
{1A01AF82-6FCB-464C-B39C-F127AEBD315D}.Release|x86.ActiveCfg = Release|Any CPU
{1A01AF82-6FCB-464C-B39C-F127AEBD315D}.Release|x86.Build.0 = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|ARM.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|iPhone.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|x64.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|x64.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|x86.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.AppStore|x86.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|ARM.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|ARM.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|iPhone.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|x64.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|x64.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|x86.ActiveCfg = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Debug|x86.Build.0 = Debug|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|Any CPU.Build.0 = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|ARM.ActiveCfg = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|ARM.Build.0 = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|iPhone.ActiveCfg = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|iPhone.Build.0 = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|x64.ActiveCfg = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|x64.Build.0 = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|x86.ActiveCfg = Release|Any CPU
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5}.Release|x86.Build.0 = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|ARM.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|iPhone.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|x64.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|x64.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|x86.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.AppStore|x86.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|ARM.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|ARM.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|iPhone.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|x64.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|x64.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|x86.ActiveCfg = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Debug|x86.Build.0 = Debug|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|Any CPU.Build.0 = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|ARM.ActiveCfg = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|ARM.Build.0 = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|iPhone.ActiveCfg = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|iPhone.Build.0 = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|x64.ActiveCfg = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|x64.Build.0 = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|x86.ActiveCfg = Release|Any CPU
{4BD76717-3102-4969-8C2C-BAAA3F0263B6}.Release|x86.Build.0 = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|ARM.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|iPhone.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|x64.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|x64.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|x86.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.AppStore|x86.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|ARM.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|ARM.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|iPhone.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|x64.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|x64.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|x86.ActiveCfg = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Debug|x86.Build.0 = Debug|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|Any CPU.Build.0 = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|ARM.ActiveCfg = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|ARM.Build.0 = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|iPhone.ActiveCfg = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|iPhone.Build.0 = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|x64.ActiveCfg = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|x64.Build.0 = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|x86.ActiveCfg = Release|Any CPU
{4A980AC4-7205-46BF-8CCB-09E44D700FD4}.Release|x86.Build.0 = Release|Any CPU
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
@ -1085,9 +1135,7 @@ Global
{8088F3FC-6787-45FA-A924-816EC81CBFAC} = {807BB76E-B2BB-47A2-A57B-3D1B20FF5E7F}
{9EE28E45-1533-472B-8267-56C48855BA0E} = {807BB76E-B2BB-47A2-A57B-3D1B20FF5E7F}
{A81ECBC2-6B00-4DCD-8388-469174033379} = {DB0EFB20-B024-4E5E-A75C-52143C131D25}
{DF8367F8-E6BD-4D07-99D2-E416BF8AB01E} = {A81ECBC2-6B00-4DCD-8388-469174033379}
{942ED6E8-0050-495F-A0EA-01E97F63760C} = {A81ECBC2-6B00-4DCD-8388-469174033379}
{7804FC60-23E6-490C-8E08-F9FEF829F184} = {A81ECBC2-6B00-4DCD-8388-469174033379}
{C0A7918D-B4F2-4E7F-8DE2-1E5279EF079F} = {E279BF0F-7F66-4F3A-A3AB-2CDA66C1CD04}
{FBF43D93-F2E7-4FF8-B4AB-186895949B88} = {DB0EFB20-B024-4E5E-A75C-52143C131D25}
{D1C47FF1-91F1-4CAF-9ABB-AD642B821502} = {FBF43D93-F2E7-4FF8-B4AB-186895949B88}
@ -1095,5 +1143,8 @@ Global
{1A01AF82-6FCB-464C-B39C-F127AEBD315D} = {022E145D-1593-47EE-9608-8E323D3C63F5}
{F38B4FF0-0B49-405A-B1B4-F7A5E3BC4C4E} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47} = {F38B4FF0-0B49-405A-B1B4-F7A5E3BC4C4E}
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5} = {A81ECBC2-6B00-4DCD-8388-469174033379}
{4BD76717-3102-4969-8C2C-BAAA3F0263B6} = {A81ECBC2-6B00-4DCD-8388-469174033379}
{4A980AC4-7205-46BF-8CCB-09E44D700FD4} = {807BB76E-B2BB-47A2-A57B-3D1B20FF5E7F}
EndGlobalSection
EndGlobal

BIN
img/ebook_arch_dev_microservices_containers_cover.png View File

Before After
Width: 257  |  Height: 336  |  Size: 31 KiB Width: 260  |  Height: 336  |  Size: 38 KiB

BIN
img/ebook_arch_dev_microservices_containers_cover_LARGE.png View File

Before After
Width: 1139  |  Height: 1469  |  Size: 242 KiB

BIN
img/ebook_arch_dev_microservices_containers_cover_OLD.png View File

Before After
Width: 257  |  Height: 336  |  Size: 31 KiB

BIN
img/xamarin-enterprise-patterns-ebook-cover-small.png View File

Before After
Width: 260  |  Height: 336  |  Size: 28 KiB Width: 260  |  Height: 336  |  Size: 25 KiB

+ 8
- 0
src/BuildingBlocks/CommandBus/CommandBus/CommandBus.csproj View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.CommandBus</RootNamespace>
</PropertyGroup>
</Project>

+ 13
- 0
src/BuildingBlocks/CommandBus/CommandBus/ICommandBus.cs View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus
{
public interface ICommandBus
{
Task SendAsync<T>(T command) where T : IntegrationCommand;
}
}

+ 18
- 0
src/BuildingBlocks/CommandBus/CommandBus/IntegrationCommand.cs View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus
{
public abstract class IntegrationCommand
{
public Guid Id { get; private set; }
public DateTime Sent { get; private set; }
protected IntegrationCommand()
{
Id = Guid.NewGuid();
Sent = DateTime.UtcNow;
}
}
}

+ 7
- 0
src/BuildingBlocks/CommandBus/CommandBusRabbitMQ/CommandBusRabbitMQ.csproj View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>
</Project>

+ 8
- 0
src/BuildingBlocks/EventBus/CommandBus/CommandBus.csproj View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.CommandBus</RootNamespace>
</PropertyGroup>
</Project>

+ 16
- 0
src/BuildingBlocks/EventBus/CommandBus/ICommandBus.cs View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus
{
public interface ICommandBus
{
void Send<T>(string name, T data);
void Handle<TC>(string name, IIntegrationCommandHandler<TC> handler);
void Handle(string name, IIntegrationCommandHandler handler);
void Handle<TI, TC>(TI handler)
where TI : IIntegrationCommandHandler<TC>;
}
}

+ 16
- 0
src/BuildingBlocks/EventBus/CommandBus/IIntegrationCommandHandler.cs View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus
{
public interface IIntegrationCommandHandler
{
void Handle(IntegrationCommand command);
}
public interface IIntegrationCommandHandler<T> : IIntegrationCommandHandler
{
void Handle(IntegrationCommand<T> command);
}
}

+ 35
- 0
src/BuildingBlocks/EventBus/CommandBus/IntegrationCommand.cs View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus
{
public abstract class IntegrationCommand
{
public Guid Id { get; }
public DateTime Sent { get; }
public abstract object GetDataAsObject();
protected IntegrationCommand()
{
Id = Guid.NewGuid();
Sent = DateTime.UtcNow;
}
}
public class IntegrationCommand<T> : IntegrationCommand
{
public T Data { get; }
public string Name { get; }
public override object GetDataAsObject() => Data;
public IntegrationCommand(string name, T data) : base()
{
Data = data;
Name = name;
}
}
}

+ 22
- 0
src/BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
<ProjectReference Include="..\EventBus\EventBus.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>

+ 56
- 0
src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs View File

@ -0,0 +1,56 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using System;
using System.Linq;
using Xunit;
namespace EventBus.Tests
{
public class InMemory_SubscriptionManager_Tests
{
[Fact]
public void After_Creation_Should_Be_Empty()
{
var manager = new InMemoryEventBusSubscriptionsManager();
Assert.True(manager.IsEmpty);
}
[Fact]
public void After_One_Event_Subscription_Should_Contain_The_Event()
{
var manager = new InMemoryEventBusSubscriptionsManager();
manager.AddSubscription<TestIntegrationEvent,TestIntegrationEventHandler>(() => new TestIntegrationEventHandler());
Assert.True(manager.HasSubscriptionsForEvent<TestIntegrationEvent>());
}
[Fact]
public void After_All_Subscriptions_Are_Deleted_Event_Should_No_Longer_Exists()
{
var manager = new InMemoryEventBusSubscriptionsManager();
manager.AddSubscription<TestIntegrationEvent, TestIntegrationEventHandler>(() => new TestIntegrationEventHandler());
manager.RemoveSubscription<TestIntegrationEvent, TestIntegrationEventHandler>();
Assert.False(manager.HasSubscriptionsForEvent<TestIntegrationEvent>());
}
[Fact]
public void Deleting_Last_Subscription_Should_Raise_On_Deleted_Event()
{
bool raised = false;
var manager = new InMemoryEventBusSubscriptionsManager();
manager.OnEventRemoved += (o, e) => raised = true;
manager.AddSubscription<TestIntegrationEvent, TestIntegrationEventHandler>(() => new TestIntegrationEventHandler());
manager.RemoveSubscription<TestIntegrationEvent, TestIntegrationEventHandler>();
Assert.True(raised);
}
[Fact]
public void Get_Handlers_For_Event_Should_Return_All_Handlers()
{
var manager = new InMemoryEventBusSubscriptionsManager();
manager.AddSubscription<TestIntegrationEvent, TestIntegrationEventHandler>(() => new TestIntegrationEventHandler());
manager.AddSubscription<TestIntegrationEvent, TestIntegrationOtherEventHandler>(() => new TestIntegrationOtherEventHandler());
var handlers = manager.GetHandlersForEvent<TestIntegrationEvent>();
Assert.Equal(2, handlers.Count());
}
}
}

+ 11
- 0
src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEvent.cs View File

@ -0,0 +1,11 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System;
using System.Collections.Generic;
using System.Text;
namespace EventBus.Tests
{
public class TestIntegrationEvent : IntegrationEvent
{
}
}

+ 23
- 0
src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs View File

@ -0,0 +1,23 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace EventBus.Tests
{
public class TestIntegrationOtherEventHandler : IIntegrationEventHandler<TestIntegrationEvent>
{
public bool Handled { get; private set; }
public TestIntegrationOtherEventHandler()
{
Handled = false;
}
public async Task Handle(TestIntegrationEvent @event)
{
Handled = true;
}
}
}

+ 23
- 0
src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs View File

@ -0,0 +1,23 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace EventBus.Tests
{
public class TestIntegrationEventHandler : IIntegrationEventHandler<TestIntegrationEvent>
{
public bool Handled { get; private set; }
public TestIntegrationEventHandler()
{
Handled = false;
}
public async Task Handle(TestIntegrationEvent @event)
{
Handled = true;
}
}
}

+ 13
- 0
src/BuildingBlocks/EventBus/EventBus/Abstractions/IDynamicIntegrationEventHandler.cs View File

@ -0,0 +1,13 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
{
public interface IDynamicIntegrationEventHandler
{
Task Handle(dynamic eventData);
}
}

+ 14
- 2
src/BuildingBlocks/EventBus/EventBus/Abstractions/IEventBus.cs View File

@ -1,11 +1,23 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
{
public interface IEventBus
{
void Subscribe<T>(IIntegrationEventHandler<T> handler) where T: IntegrationEvent;
void Unsubscribe<T>(IIntegrationEventHandler<T> handler) where T : IntegrationEvent;
void Subscribe<T, TH>(Func<TH> handler)
where T : IntegrationEvent
where TH : IIntegrationEventHandler<T>;
void SubscribeDynamic<TH>(string eventName, Func<TH> handler)
where TH : IDynamicIntegrationEventHandler;
void UnsubscribeDynamic<TH>(string eventName)
where TH : IDynamicIntegrationEventHandler;
void Unsubscribe<T, TH>()
where TH : IIntegrationEventHandler<T>
where T : IntegrationEvent;
void Publish(IntegrationEvent @event);
}
}

+ 0
- 4
src/BuildingBlocks/EventBus/EventBus/EventBus.csproj View File

@ -6,10 +6,6 @@
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBus</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Folder Include="Abstractions\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>


+ 34
- 0
src/BuildingBlocks/EventBus/EventBus/IEventBusSubscriptionsManager.cs View File

@ -0,0 +1,34 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System;
using System.Collections.Generic;
using static Microsoft.eShopOnContainers.BuildingBlocks.EventBus.InMemoryEventBusSubscriptionsManager;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
{
public interface IEventBusSubscriptionsManager
{
bool IsEmpty { get; }
event EventHandler<string> OnEventRemoved;
void AddDynamicSubscription<TH>(string eventName, Func<TH> handler)
where TH : IDynamicIntegrationEventHandler;
void AddSubscription<T, TH>(Func<TH> handler)
where T : IntegrationEvent
where TH : IIntegrationEventHandler<T>;
void RemoveSubscription<T, TH>()
where TH : IIntegrationEventHandler<T>
where T : IntegrationEvent;
void RemoveDynamicSubscription<TH>(string eventName)
where TH : IDynamicIntegrationEventHandler;
bool HasSubscriptionsForEvent<T>() where T : IntegrationEvent;
bool HasSubscriptionsForEvent(string eventName);
Type GetEventTypeByName(string eventName);
void Clear();
IEnumerable<SubscriptionInfo> GetHandlersForEvent<T>() where T : IntegrationEvent;
IEnumerable<SubscriptionInfo> GetHandlersForEvent(string eventName);
string GetEventKey<T>();
}
}

+ 162
- 0
src/BuildingBlocks/EventBus/EventBus/InMemoryEventBusSubscriptionsManager.cs View File

@ -0,0 +1,162 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
{
public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
{
private readonly Dictionary<string, List<SubscriptionInfo>> _handlers;
private readonly List<Type> _eventTypes;
public event EventHandler<string> OnEventRemoved;
public InMemoryEventBusSubscriptionsManager()
{
_handlers = new Dictionary<string, List<SubscriptionInfo>>();
_eventTypes = new List<Type>();
}
public bool IsEmpty => !_handlers.Keys.Any();
public void Clear() => _handlers.Clear();
public void AddDynamicSubscription<TH>(string eventName, Func<TH> handler)
where TH : IDynamicIntegrationEventHandler
{
DoAddSubscription(handler, eventName, isDynamic: true);
}
public void AddSubscription<T, TH>(Func<TH> handler)
where T : IntegrationEvent
where TH : IIntegrationEventHandler<T>
{
var eventName = GetEventKey<T>();
DoAddSubscription(handler, eventName, isDynamic: false);
_eventTypes.Add(typeof(T));
}
private void DoAddSubscription(Delegate handler, string eventName, bool isDynamic)
{
if (!HasSubscriptionsForEvent(eventName))
{
_handlers.Add(eventName, new List<SubscriptionInfo>());
}
if (isDynamic)
{
_handlers[eventName].Add(SubscriptionInfo.Dynamic(handler));
}
else
{
_handlers[eventName].Add(SubscriptionInfo.Typed(handler));
}
}
public void RemoveDynamicSubscription<TH>(string eventName)
where TH : IDynamicIntegrationEventHandler
{
var handlerToRemove = FindDynamicSubscriptionToRemove<TH>(eventName);
DoRemoveHandler(eventName, handlerToRemove);
}
public void RemoveSubscription<T, TH>()
where TH : IIntegrationEventHandler<T>
where T : IntegrationEvent
{
var handlerToRemove = FindSubscriptionToRemove<T, TH>();
var eventName = GetEventKey<T>();
DoRemoveHandler(eventName, handlerToRemove);
}
private void DoRemoveHandler(string eventName, SubscriptionInfo subsToRemove)
{
if (subsToRemove != null)
{
_handlers[eventName].Remove(subsToRemove);
if (!_handlers[eventName].Any())
{
_handlers.Remove(eventName);
var eventType = _eventTypes.SingleOrDefault(e => e.Name == eventName);
if (eventType != null)
{
_eventTypes.Remove(eventType);
}
RaiseOnEventRemoved(eventName);
}
}
}
public IEnumerable<SubscriptionInfo> GetHandlersForEvent<T>() where T : IntegrationEvent
{
var key = GetEventKey<T>();
return GetHandlersForEvent(key);
}
public IEnumerable<SubscriptionInfo> GetHandlersForEvent(string eventName) => _handlers[eventName];
private void RaiseOnEventRemoved(string eventName)
{
var handler = OnEventRemoved;
if (handler != null)
{
OnEventRemoved(this, eventName);
}
}
private SubscriptionInfo FindDynamicSubscriptionToRemove<TH>(string eventName)
where TH : IDynamicIntegrationEventHandler
{
return DoFindHandlerToRemove(eventName, typeof(TH));
}
private SubscriptionInfo FindSubscriptionToRemove<T, TH>()
where T : IntegrationEvent
where TH : IIntegrationEventHandler<T>
{
var eventName = GetEventKey<T>();
return DoFindHandlerToRemove(eventName, typeof(TH));
}
private SubscriptionInfo DoFindHandlerToRemove(string eventName, Type handlerType)
{
if (!HasSubscriptionsForEvent(eventName))
{
return null;
}
foreach (var subscription in _handlers[eventName])
{
var genericArgs = subscription.Factory.GetType().GetGenericArguments();
if (genericArgs.SingleOrDefault() == handlerType)
{
return subscription;
}
}
return null;
}
public bool HasSubscriptionsForEvent<T>() where T : IntegrationEvent
{
var key = GetEventKey<T>();
return HasSubscriptionsForEvent(key);
}
public bool HasSubscriptionsForEvent(string eventName) => _handlers.ContainsKey(eventName);
public Type GetEventTypeByName(string eventName) => _eventTypes.SingleOrDefault(t => t.Name == eventName);
public string GetEventKey<T>()
{
return typeof(T).Name;
}
}
}

+ 28
- 0
src/BuildingBlocks/EventBus/EventBus/SubscriptionInfo.cs View File

@ -0,0 +1,28 @@
using System;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
{
public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
{
public class SubscriptionInfo
{
public bool IsDynamic { get; }
public Delegate Factory { get; }
private SubscriptionInfo(bool isDynamic, Delegate factory)
{
IsDynamic = isDynamic;
Factory = factory;
}
public static SubscriptionInfo Dynamic(Delegate factory)
{
return new SubscriptionInfo(true, factory);
}
public static SubscriptionInfo Typed(Delegate factory)
{
return new SubscriptionInfo(false, factory);
}
}
}
}

+ 145
- 0
src/BuildingBlocks/EventBus/EventBusRabbitMQ/CommandBusRabbitMQ.cs View File

@ -0,0 +1,145 @@
//using Microsoft.eShopOnContainers.BuildingBlocks.CommandBus;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Polly;
using Polly.Retry;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using RabbitMQ.Client.Exceptions;
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
/*
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
{
public class CommandBusRabbitMQ : ICommandBus, IDisposable
{
const string BROKER_NAME = "eshop_command_bus";
private readonly IRabbitMQPersistentConnection _persistentConnection;
private readonly ILogger<CommandBusRabbitMQ> _logger;
private IModel _consumerChannel;
private string _queueName;
private readonly Dictionary<string, IIntegrationCommandHandler> _handlers;
private readonly Dictionary<string, Type> _typeMappings;
public CommandBusRabbitMQ(IRabbitMQPersistentConnection persistentConnection,
ILogger<CommandBusRabbitMQ> logger)
{
_logger = logger;
_persistentConnection = persistentConnection;
_handlers = new Dictionary<string, IIntegrationCommandHandler>();
_typeMappings = new Dictionary<string, Type>();
}
public void Send<T>(string name, T data)
{
Send(new IntegrationCommand<T>(name, data));
}
public void Handle<TC>(string name, IIntegrationCommandHandler<TC> handler)
{
_handlers.Add(name, handler);
_typeMappings.Add(name, typeof(TC));
}
public void Handle(string name, IIntegrationCommandHandler handler)
{
_handlers.Add(name, handler);
}
public void Handle<TI, TC>(TI handler) where TI : IIntegrationCommandHandler<TC>
{
var name = typeof(TI).Name;
_handlers.Add(name, handler);
_typeMappings.Add(name, typeof(TC));
}
private void Send<T>(IntegrationCommand<T> command)
{
if (!_persistentConnection.IsConnected)
{
_persistentConnection.TryConnect();
}
var policy = RetryPolicy.Handle<BrokerUnreachableException>()
.Or<SocketException>()
.WaitAndRetry(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
{
_logger.LogWarning(ex.ToString());
});
using (var channel = _persistentConnection.CreateModel())
{
var commandName = command.Name;
channel.ExchangeDeclare(exchange: BROKER_NAME, type: "direct");
var message = JsonConvert.SerializeObject(command);
var body = Encoding.UTF8.GetBytes(message);
policy.Execute(() =>
{
channel.BasicPublish(exchange: BROKER_NAME,
routingKey: commandName,
basicProperties: null,
body: body);
});
}
}
private IModel CreateConsumerChannel()
{
if (!_persistentConnection.IsConnected)
{
_persistentConnection.TryConnect();
}
var channel = _persistentConnection.CreateModel();
channel.ExchangeDeclare(exchange: BROKER_NAME, type: "direct");
_queueName = channel.QueueDeclare().QueueName;
var consumer = new EventingBasicConsumer(channel);
consumer.Received += async (model, ea) =>
{
var commandName = ea.RoutingKey;
var message = Encoding.UTF8.GetString(ea.Body);
await InvokeHandler(commandName, message);
};
channel.BasicConsume(queue: _queueName,
noAck: true,
consumer: consumer);
channel.CallbackException += (sender, ea) =>
{
_consumerChannel.Dispose();
_consumerChannel = CreateConsumerChannel();
};
return channel;
}
private Task InvokeHandler(string commandName, string message)
{
if (_handlers.ContainsKey(commandName))
{
}
}
public void Dispose()
{
if (_consumerChannel != null)
{
_consumerChannel.Dispose();
}
}
}
}
*/

+ 6
- 6
src/BuildingBlocks/EventBus/EventBusRabbitMQ/DefaultRabbitMQPersisterConnection.cs View File

@ -10,18 +10,18 @@ using System.Net.Sockets;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
{
public class DefaultRabbitMQPersisterConnection
: IRabbitMQPersisterConnection
public class DefaultRabbitMQPersistentConnection
: IRabbitMQPersistentConnection
{
private readonly IConnectionFactory _connectionFactory;
private readonly ILogger<DefaultRabbitMQPersisterConnection> _logger;
private readonly ILogger<DefaultRabbitMQPersistentConnection> _logger;
IConnection _connection;
bool _disposed;
object sync_root = new object();
public DefaultRabbitMQPersisterConnection(IConnectionFactory connectionFactory,ILogger<DefaultRabbitMQPersisterConnection> logger)
public DefaultRabbitMQPersistentConnection(IConnectionFactory connectionFactory,ILogger<DefaultRabbitMQPersistentConnection> logger)
{
_connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
@ -87,13 +87,13 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
_connection.CallbackException += OnCallbackException;
_connection.ConnectionBlocked += OnConnectionBlocked;
_logger.LogInformation($"RabbitMQ persister connection acquire a connection {_connection.Endpoint.HostName} and is subscribed to failure events");
_logger.LogInformation($"RabbitMQ persistent connection acquired a connection {_connection.Endpoint.HostName} and is subscribed to failure events");
return true;
}
else
{
_logger.LogCritical("FATAL ERROR: RabbitMQ connections can't be created and opened");
_logger.LogCritical("FATAL ERROR: RabbitMQ connections could not be created and opened");
return false;
}


+ 88
- 79
src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs View File

@ -1,7 +1,9 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Polly;
using Polly.Retry;
using RabbitMQ.Client;
@ -21,32 +23,50 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
{
const string BROKER_NAME = "eshop_event_bus";
private readonly IRabbitMQPersisterConnection _persisterConnection;
private readonly IRabbitMQPersistentConnection _persistentConnection;
private readonly ILogger<EventBusRabbitMQ> _logger;
private readonly Dictionary<string, List<IIntegrationEventHandler>> _handlers
= new Dictionary<string, List<IIntegrationEventHandler>>();
private readonly List<Type> _eventTypes
= new List<Type>();
private readonly IEventBusSubscriptionsManager _subsManager;
private IModel _consumerChannel;
private string _queueName;
public EventBusRabbitMQ(IRabbitMQPersisterConnection persisterConnection, ILogger<EventBusRabbitMQ> logger)
public EventBusRabbitMQ(IRabbitMQPersistentConnection persistentConnection, ILogger<EventBusRabbitMQ> logger, IEventBusSubscriptionsManager subsManager)
{
_persisterConnection = persisterConnection ?? throw new ArgumentNullException(nameof(persisterConnection));
_persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();
_consumerChannel = CreateConsumerChannel();
_subsManager.OnEventRemoved += SubsManager_OnEventRemoved;
}
private void SubsManager_OnEventRemoved(object sender, string eventName)
{
if (!_persistentConnection.IsConnected)
{
_persistentConnection.TryConnect();
}
using (var channel = _persistentConnection.CreateModel())
{
channel.QueueUnbind(queue: _queueName,
exchange: BROKER_NAME,
routingKey: eventName);
if (_subsManager.IsEmpty)
{
_queueName = string.Empty;
_consumerChannel.Close();
}
}
}
public void Publish(IntegrationEvent @event)
{
if (!_persisterConnection.IsConnected)
if (!_persistentConnection.IsConnected)
{
_persisterConnection.TryConnect();
_persistentConnection.TryConnect();
}
var policy = RetryPolicy.Handle<BrokerUnreachableException>()
@ -56,7 +76,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
_logger.LogWarning(ex.ToString());
});
using (var channel = _persisterConnection.CreateModel())
using (var channel = _persistentConnection.CreateModel())
{
var eventName = @event.GetType()
.Name;
@ -77,95 +97,73 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
}
}
public void Subscribe<T>(IIntegrationEventHandler<T> handler) where T : IntegrationEvent
public void SubscribeDynamic<TH>(string eventName, Func<TH> handler)
where TH: IDynamicIntegrationEventHandler
{
var eventName = typeof(T).Name;
DoInternalSubscription(eventName);
_subsManager.AddDynamicSubscription<TH>(eventName,handler);
}
if (_handlers.ContainsKey(eventName))
{
_handlers[eventName].Add(handler);
}
else
public void Subscribe<T, TH>(Func<TH> handler)
where T : IntegrationEvent
where TH : IIntegrationEventHandler<T>
{
var eventName = _subsManager.GetEventKey<T>();
DoInternalSubscription(eventName);
_subsManager.AddSubscription<T, TH>(handler);
}
private void DoInternalSubscription(string eventName)
{
var containsKey = _subsManager.HasSubscriptionsForEvent(eventName);
if (!containsKey)
{
if (!_persisterConnection.IsConnected)
if (!_persistentConnection.IsConnected)
{
_persisterConnection.TryConnect();
_persistentConnection.TryConnect();
}
using (var channel = _persisterConnection.CreateModel())
using (var channel = _persistentConnection.CreateModel())
{
channel.QueueBind(queue: _queueName,
exchange: BROKER_NAME,
routingKey: eventName);
_handlers.Add(eventName, new List<IIntegrationEventHandler>());
_handlers[eventName].Add(handler);
_eventTypes.Add(typeof(T));
}
}
}
public void Unsubscribe<T>(IIntegrationEventHandler<T> handler) where T : IntegrationEvent
public void Unsubscribe<T, TH>()
where TH : IIntegrationEventHandler<T>
where T : IntegrationEvent
{
var eventName = typeof(T).Name;
if (_handlers.ContainsKey(eventName) && _handlers[eventName].Contains(handler))
{
_handlers[eventName].Remove(handler);
if (_handlers[eventName].Count == 0)
{
_handlers.Remove(eventName);
var eventType = _eventTypes.SingleOrDefault(e => e.Name == eventName);
_subsManager.RemoveSubscription<T, TH>();
}
if (eventType != null)
{
_eventTypes.Remove(eventType);
if (!_persisterConnection.IsConnected)
{
_persisterConnection.TryConnect();
}
using (var channel = _persisterConnection.CreateModel())
{
channel.QueueUnbind(queue: _queueName,
exchange: BROKER_NAME,
routingKey: eventName);
if (_handlers.Keys.Count == 0)
{
_queueName = string.Empty;
_consumerChannel.Close();
}
}
}
}
}
public void UnsubscribeDynamic<TH>(string eventName)
where TH: IDynamicIntegrationEventHandler
{
_subsManager.RemoveDynamicSubscription<TH>(eventName);
}
public void Dispose()
{
if (_consumerChannel != null)
{
_consumerChannel.Dispose();
}
_handlers.Clear();
_subsManager.Clear();
}
private IModel CreateConsumerChannel()
{
if (!_persisterConnection.IsConnected)
if (!_persistentConnection.IsConnected)
{
_persisterConnection.TryConnect();
_persistentConnection.TryConnect();
}
var channel = _persisterConnection.CreateModel();
var channel = _persistentConnection.CreateModel();
channel.ExchangeDeclare(exchange: BROKER_NAME,
type: "direct");
@ -196,16 +194,27 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
private async Task ProcessEvent(string eventName, string message)
{
if (_handlers.ContainsKey(eventName))
if (_subsManager.HasSubscriptionsForEvent(eventName))
{
Type eventType = _eventTypes.Single(t => t.Name == eventName);
var integrationEvent = JsonConvert.DeserializeObject(message, eventType);
var concreteType = typeof(IIntegrationEventHandler<>).MakeGenericType(eventType);
var handlers = _handlers[eventName];
var subscriptions = _subsManager.GetHandlersForEvent(eventName);
foreach (var handler in handlers)
foreach (var subscription in subscriptions)
{
await (Task)concreteType.GetMethod("Handle").Invoke(handler, new object[] { integrationEvent });
if (subscription.IsDynamic)
{
var handler = subscription.Factory.DynamicInvoke() as IDynamicIntegrationEventHandler;
dynamic eventData = JObject.Parse(message);
await handler.Handle(eventData);
}
else
{
var eventType = _subsManager.GetEventTypeByName(eventName);
var integrationEvent = JsonConvert.DeserializeObject(message, eventType);
var handler = subscription.Factory.DynamicInvoke();
var concreteType = typeof(IIntegrationEventHandler<>).MakeGenericType(eventType);
await (Task)concreteType.GetMethod("Handle").Invoke(handler, new object[] { integrationEvent });
}
}
}
}


+ 1
- 2
src/BuildingBlocks/EventBus/EventBusRabbitMQ/IRabbitMQPersisterConnection.cs View File

@ -3,8 +3,7 @@ using System;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
{
public interface IRabbitMQPersisterConnection
public interface IRabbitMQPersistentConnection
: IDisposable
{
bool IsConnected { get; }


+ 15
- 7
src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/HealthCheckMiddleware.cs View File

@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
@ -11,30 +13,34 @@ namespace Microsoft.AspNetCore.HealthChecks
{
public class HealthCheckMiddleware
{
private RequestDelegate _next;
private string _path;
private int? _port;
private IHealthCheckService _service;
private readonly RequestDelegate _next;
private readonly string _path;
private readonly int? _port;
private readonly IHealthCheckService _service;
private readonly TimeSpan _timeout;
public HealthCheckMiddleware(RequestDelegate next, IHealthCheckService service, int port)
public HealthCheckMiddleware(RequestDelegate next, IHealthCheckService service, int port, TimeSpan timeout)
{
_port = port;
_service = service;
_next = next;
_timeout = timeout;
}
public HealthCheckMiddleware(RequestDelegate next, IHealthCheckService service, string path)
public HealthCheckMiddleware(RequestDelegate next, IHealthCheckService service, string path, TimeSpan timeout)
{
_path = path;
_service = service;
_next = next;
_timeout = timeout;
}
public async Task Invoke(HttpContext context)
{
if (IsHealthCheckRequest(context))
{
var result = await _service.CheckHealthAsync();
var timeoutTokenSource = new CancellationTokenSource(_timeout);
var result = await _service.CheckHealthAsync(timeoutTokenSource.Token);
var status = result.CheckStatus;
if (status != CheckStatus.Healthy)
@ -60,7 +66,9 @@ namespace Microsoft.AspNetCore.HealthChecks
}
if (context.Request.Path == _path)
{
return true;
}
return false;
}


+ 11
- 4
src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/HealthCheckStartupFilter.cs View File

@ -11,15 +11,18 @@ namespace Microsoft.AspNetCore.HealthChecks
{
private string _path;
private int? _port;
private TimeSpan _timeout;
public HealthCheckStartupFilter(int port)
public HealthCheckStartupFilter(int port, TimeSpan timeout)
{
_port = port;
_timeout = timeout;
}
public HealthCheckStartupFilter(string path)
public HealthCheckStartupFilter(string path, TimeSpan timeout)
{
_path = path;
_timeout = timeout;
}
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
@ -27,9 +30,13 @@ namespace Microsoft.AspNetCore.HealthChecks
return app =>
{
if (_port.HasValue)
app.UseMiddleware<HealthCheckMiddleware>(_port);
{
app.UseMiddleware<HealthCheckMiddleware>(_port, _timeout);
}
else
app.UseMiddleware<HealthCheckMiddleware>(_path);
{
app.UseMiddleware<HealthCheckMiddleware>(_path, _timeout);
}
next(app);
};


+ 16
- 5
src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/HealthCheckWebHostBuilderExtension.cs View File

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
@ -8,28 +9,38 @@ namespace Microsoft.AspNetCore.Hosting
{
public static class HealthCheckWebHostBuilderExtension
{
public static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(10);
public static IWebHostBuilder UseHealthChecks(this IWebHostBuilder builder, int port)
=> UseHealthChecks(builder, port, DefaultTimeout);
public static IWebHostBuilder UseHealthChecks(this IWebHostBuilder builder, int port, TimeSpan timeout)
{
Guard.ArgumentValid(port > 0 && port < 65536, nameof(port), "Port must be a value between 1 and 65535");
Guard.ArgumentValid(port > 0 && port < 65536, nameof(port), "Port must be a value between 1 and 65535.");
Guard.ArgumentValid(timeout > TimeSpan.Zero, nameof(timeout), "Health check timeout must be a positive time span.");
builder.ConfigureServices(services =>
{
var existingUrl = builder.GetSetting(WebHostDefaults.ServerUrlsKey);
builder.UseSetting(WebHostDefaults.ServerUrlsKey, $"{existingUrl};http://localhost:{port}");
services.AddSingleton<IStartupFilter>(new HealthCheckStartupFilter(port));
services.AddSingleton<IStartupFilter>(new HealthCheckStartupFilter(port, timeout));
});
return builder;
}
public static IWebHostBuilder UseHealthChecks(this IWebHostBuilder builder, string path)
=> UseHealthChecks(builder, path, DefaultTimeout);
public static IWebHostBuilder UseHealthChecks(this IWebHostBuilder builder, string path, TimeSpan timeout)
{
Guard.ArgumentNotNull(nameof(path), path);
// REVIEW: Is there a better URL path validator somewhere?
Guard.ArgumentValid(!path.Contains("?"), nameof(path), "Path cannot contain query string values");
Guard.ArgumentValid(path.StartsWith("/"), nameof(path), "Path should start with /");
Guard.ArgumentValid(!path.Contains("?"), nameof(path), "Path cannot contain query string values.");
Guard.ArgumentValid(path.StartsWith("/"), nameof(path), "Path should start with '/'.");
Guard.ArgumentValid(timeout > TimeSpan.Zero, nameof(timeout), "Health check timeout must be a positive time span.");
builder.ConfigureServices(services => services.AddSingleton<IStartupFilter>(new HealthCheckStartupFilter(path)));
builder.ConfigureServices(services => services.AddSingleton<IStartupFilter>(new HealthCheckStartupFilter(path, timeout)));
return builder;
}
}


src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.Data/HealthCheckBuilderDataExtensions.cs → src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/HealthCheckBuilderSqlServerExtensions.cs View File

@ -7,7 +7,7 @@ using System.Data.SqlClient;
namespace Microsoft.Extensions.HealthChecks
{
public static class HealthCheckBuilderDataExtensions
public static class HealthCheckBuilderSqlServerExtensions
{
public static HealthCheckBuilder AddSqlCheck(this HealthCheckBuilder builder, string name, string connectionString)
{
@ -33,7 +33,7 @@ namespace Microsoft.Extensions.HealthChecks
}
}
}
catch(Exception ex)
catch (Exception ex)
{
return HealthCheckResult.Unhealthy($"SqlCheck({name}): Exception during check: {ex.GetType().FullName}");
}

src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.Data/Microsoft.Extensions.HealthChecks.Data.csproj → src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj View File


+ 109
- 0
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/CachedHealthCheck.cs View File

@ -0,0 +1,109 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.Extensions.HealthChecks
{
public abstract class CachedHealthCheck
{
private static readonly TypeInfo HealthCheckTypeInfo = typeof(IHealthCheck).GetTypeInfo();
private volatile int _writerCount;
public CachedHealthCheck(string name, TimeSpan cacheDuration)
{
Guard.ArgumentNotNullOrEmpty(nameof(name), name);
Guard.ArgumentValid(cacheDuration.TotalMilliseconds >= 0, nameof(cacheDuration), "Cache duration must be zero (disabled) or greater than zero.");
Name = name;
CacheDuration = cacheDuration;
}
public IHealthCheckResult CachedResult { get; internal set; }
public TimeSpan CacheDuration { get; }
public DateTimeOffset CacheExpiration { get; internal set; }
public string Name { get; }
protected virtual DateTimeOffset UtcNow => DateTimeOffset.UtcNow;
protected abstract IHealthCheck Resolve(IServiceProvider serviceProvider);
public async ValueTask<IHealthCheckResult> RunAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken = default(CancellationToken))
{
while (CacheExpiration <= UtcNow)
{
// Can't use a standard lock here because of async, so we'll use this flag to determine when we should write a value,
// and the waiters who aren't allowed to write will just spin wait for the new value.
if (Interlocked.Exchange(ref _writerCount, 1) != 0)
{
await Task.Delay(5, cancellationToken).ConfigureAwait(false);
continue;
}
try
{
var check = Resolve(serviceProvider);
CachedResult = await check.CheckAsync(cancellationToken);
}
catch (OperationCanceledException)
{
CachedResult = HealthCheckResult.Unhealthy("The health check operation timed out");
}
catch (Exception ex)
{
CachedResult = HealthCheckResult.Unhealthy($"Exception during check: {ex.GetType().FullName}");
}
CacheExpiration = UtcNow + CacheDuration;
_writerCount = 0;
break;
}
return CachedResult;
}
public static CachedHealthCheck FromHealthCheck(string name, TimeSpan cacheDuration, IHealthCheck healthCheck)
{
Guard.ArgumentNotNull(nameof(healthCheck), healthCheck);
return new TypeOrHealthCheck_HealthCheck(name, cacheDuration, healthCheck);
}
public static CachedHealthCheck FromType(string name, TimeSpan cacheDuration, Type healthCheckType)
{
Guard.ArgumentNotNull(nameof(healthCheckType), healthCheckType);
Guard.ArgumentValid(HealthCheckTypeInfo.IsAssignableFrom(healthCheckType.GetTypeInfo()), nameof(healthCheckType), $"Health check must implement '{typeof(IHealthCheck).FullName}'.");
return new TypeOrHealthCheck_Type(name, cacheDuration, healthCheckType);
}
class TypeOrHealthCheck_HealthCheck : CachedHealthCheck
{
private readonly IHealthCheck _healthCheck;
public TypeOrHealthCheck_HealthCheck(string name, TimeSpan cacheDuration, IHealthCheck healthCheck) : base(name, cacheDuration)
=> _healthCheck = healthCheck;
protected override IHealthCheck Resolve(IServiceProvider serviceProvider) => _healthCheck;
}
class TypeOrHealthCheck_Type : CachedHealthCheck
{
private readonly Type _healthCheckType;
public TypeOrHealthCheck_Type(string name, TimeSpan cacheDuration, Type healthCheckType) : base(name, cacheDuration)
=> _healthCheckType = healthCheckType;
protected override IHealthCheck Resolve(IServiceProvider serviceProvider)
=> (IHealthCheck)serviceProvider.GetRequiredService(_healthCheckType);
}
}
}

+ 19
- 0
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/CachedHealthCheckExtensions.cs View File

@ -0,0 +1,19 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Extensions.HealthChecks
{
public static class CachedHealthCheckExtensions
{
public static ValueTask<IHealthCheckResult> RunAsync(this CachedHealthCheck check, IServiceProvider serviceProvider)
{
Guard.ArgumentNotNull(nameof(check), check);
return check.RunAsync(serviceProvider, CancellationToken.None);
}
}
}

+ 30
- 24
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Checks/AddCheck.cs View File

@ -15,96 +15,102 @@ namespace Microsoft.Extensions.HealthChecks
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromCheck(check, builder.DefaultCacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromCheck(check), builder.DefaultCacheDuration);
}
public static HealthCheckBuilder AddCheck(this HealthCheckBuilder builder, string name, Func<CancellationToken, IHealthCheckResult> check)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromCheck(check, builder.DefaultCacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromCheck(check), builder.DefaultCacheDuration);
}
public static HealthCheckBuilder AddCheck(this HealthCheckBuilder builder, string name, Func<IHealthCheckResult> check, TimeSpan cacheDuration)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromCheck(check, cacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromCheck(check), cacheDuration);
}
public static HealthCheckBuilder AddCheck(this HealthCheckBuilder builder, string name, Func<CancellationToken, IHealthCheckResult> check, TimeSpan cacheDuration)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromCheck(check, cacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromCheck(check), cacheDuration);
}
public static HealthCheckBuilder AddCheck(this HealthCheckBuilder builder, string name, Func<Task<IHealthCheckResult>> check)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromTaskCheck(check, builder.DefaultCacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromTaskCheck(check), builder.DefaultCacheDuration);
}
public static HealthCheckBuilder AddCheck(this HealthCheckBuilder builder, string name, Func<CancellationToken, Task<IHealthCheckResult>> check)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromTaskCheck(check, builder.DefaultCacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromTaskCheck(check), builder.DefaultCacheDuration);
}
public static HealthCheckBuilder AddCheck(this HealthCheckBuilder builder, string name, Func<Task<IHealthCheckResult>> check, TimeSpan cacheDuration)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromTaskCheck(check, cacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromTaskCheck(check), cacheDuration);
}
public static HealthCheckBuilder AddCheck(this HealthCheckBuilder builder, string name, Func<CancellationToken, Task<IHealthCheckResult>> check, TimeSpan cacheDuration)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromTaskCheck(check, cacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromTaskCheck(check), cacheDuration);
}
public static HealthCheckBuilder AddValueTaskCheck(this HealthCheckBuilder builder, string name, Func<ValueTask<IHealthCheckResult>> check)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromValueTaskCheck(check, builder.DefaultCacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromValueTaskCheck(check), builder.DefaultCacheDuration);
}
public static HealthCheckBuilder AddValueTaskCheck(this HealthCheckBuilder builder, string name, Func<CancellationToken, ValueTask<IHealthCheckResult>> check)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromValueTaskCheck(check, builder.DefaultCacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromValueTaskCheck(check), builder.DefaultCacheDuration);
}
public static HealthCheckBuilder AddValueTaskCheck(this HealthCheckBuilder builder, string name, Func<ValueTask<IHealthCheckResult>> check, TimeSpan cacheDuration)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromValueTaskCheck(check, cacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromValueTaskCheck(check), cacheDuration);
}
public static HealthCheckBuilder AddValueTaskCheck(this HealthCheckBuilder builder, string name, Func<CancellationToken, ValueTask<IHealthCheckResult>> check, TimeSpan cacheDuration)
{
Guard.ArgumentNotNull(nameof(builder), builder);
builder.AddCheck(name, HealthCheck.FromValueTaskCheck(check, cacheDuration));
return builder;
return builder.AddCheck(name, HealthCheck.FromValueTaskCheck(check), cacheDuration);
}
// IHealthCheck versions of AddCheck
public static HealthCheckBuilder AddCheck(this HealthCheckBuilder builder, string checkName, IHealthCheck check)
{
Guard.ArgumentNotNull(nameof(builder), builder);
return builder.AddCheck(checkName, check, builder.DefaultCacheDuration);
}
// Type versions of AddCheck
public static HealthCheckBuilder AddCheck<TCheck>(this HealthCheckBuilder builder, string name) where TCheck : class, IHealthCheck
{
Guard.ArgumentNotNull(nameof(builder), builder);
return builder.AddCheck<TCheck>(name, builder.DefaultCacheDuration);
}
}
}

+ 5
- 5
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Checks/NumericChecks.cs View File

@ -14,7 +14,7 @@ namespace Microsoft.Extensions.HealthChecks
where T : IComparable<T>
{
Guard.ArgumentNotNull(nameof(builder), builder);
Guard.ArgumentNotNullOrWhitespace(nameof(name), name);
Guard.ArgumentNotNullOrEmpty(nameof(name), name);
Guard.ArgumentNotNull(nameof(currentValueFunc), currentValueFunc);
builder.AddCheck(name, () =>
@ -23,7 +23,7 @@ namespace Microsoft.Extensions.HealthChecks
var status = currentValue.CompareTo(minValue) >= 0 ? CheckStatus.Healthy : CheckStatus.Unhealthy;
return HealthCheckResult.FromStatus(
status,
$"{name}: min={minValue}, current={currentValue}",
$"min={minValue}, current={currentValue}",
new Dictionary<string, object> { { "min", minValue }, { "current", currentValue } }
);
});
@ -35,16 +35,16 @@ namespace Microsoft.Extensions.HealthChecks
where T : IComparable<T>
{
Guard.ArgumentNotNull(nameof(builder), builder);
Guard.ArgumentNotNullOrWhitespace(nameof(name), name);
Guard.ArgumentNotNullOrEmpty(nameof(name), name);
Guard.ArgumentNotNull(nameof(currentValueFunc), currentValueFunc);
builder.AddCheck($"{name}", () =>
builder.AddCheck(name, () =>
{
var currentValue = currentValueFunc();
var status = currentValue.CompareTo(maxValue) <= 0 ? CheckStatus.Healthy : CheckStatus.Unhealthy;
return HealthCheckResult.FromStatus(
status,
$"{name}: max={maxValue}, current={currentValue}",
$"max={maxValue}, current={currentValue}",
new Dictionary<string, object> { { "max", maxValue }, { "current", currentValue } }
);
});


+ 1
- 64
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Checks/UrlChecks.cs View File

@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.HealthChecks.Internal;
@ -37,73 +35,12 @@ namespace Microsoft.Extensions.HealthChecks
Func<HttpResponseMessage, ValueTask<IHealthCheckResult>> checkFunc)
{
Guard.ArgumentNotNull(nameof(builder), builder);
Guard.ArgumentNotNullOrWhitespace(nameof(url), url);
Guard.ArgumentNotNullOrEmpty(nameof(url), url);
Guard.ArgumentNotNull(nameof(checkFunc), checkFunc);
var urlCheck = new UrlChecker(checkFunc, url);
builder.AddCheck($"UrlCheck({url})", () => urlCheck.CheckAsync());
return builder;
}
public static HealthCheckBuilder AddUrlChecks(this HealthCheckBuilder builder, IEnumerable<string> urlItems, string groupName)
=> AddUrlChecks(builder, urlItems, groupName, CheckStatus.Warning, response => UrlChecker.DefaultUrlCheck(response));
public static HealthCheckBuilder AddUrlChecks(this HealthCheckBuilder builder, IEnumerable<string> urlItems, string groupName,
Func<HttpResponseMessage, IHealthCheckResult> checkFunc)
{
Guard.ArgumentNotNull(nameof(checkFunc), checkFunc);
return AddUrlChecks(builder, urlItems, groupName, CheckStatus.Warning, response => new ValueTask<IHealthCheckResult>(checkFunc(response)));
}
public static HealthCheckBuilder AddUrlChecks(this HealthCheckBuilder builder, IEnumerable<string> urlItems, string groupName,
Func<HttpResponseMessage, Task<IHealthCheckResult>> checkFunc)
{
Guard.ArgumentNotNull(nameof(checkFunc), checkFunc);
return AddUrlChecks(builder, urlItems, groupName, CheckStatus.Warning, response => new ValueTask<IHealthCheckResult>(checkFunc(response)));
}
public static HealthCheckBuilder AddUrlChecks(this HealthCheckBuilder builder, IEnumerable<string> urlItems, string groupName,
Func<HttpResponseMessage, ValueTask<IHealthCheckResult>> checkFunc)
{
Guard.ArgumentNotNull(nameof(checkFunc), checkFunc);
return AddUrlChecks(builder, urlItems, groupName, CheckStatus.Warning, response => checkFunc(response));
}
public static HealthCheckBuilder AddUrlChecks(this HealthCheckBuilder builder, IEnumerable<string> urlItems, string groupName,
CheckStatus partialSuccessStatus)
=> AddUrlChecks(builder, urlItems, groupName, partialSuccessStatus, response => UrlChecker.DefaultUrlCheck(response));
public static HealthCheckBuilder AddUrlChecks(this HealthCheckBuilder builder, IEnumerable<string> urlItems, string groupName,
CheckStatus partialSuccessStatus, Func<HttpResponseMessage, IHealthCheckResult> checkFunc)
{
Guard.ArgumentNotNull(nameof(checkFunc), checkFunc);
return AddUrlChecks(builder, urlItems, groupName, partialSuccessStatus, response => new ValueTask<IHealthCheckResult>(checkFunc(response)));
}
public static HealthCheckBuilder AddUrlChecks(this HealthCheckBuilder builder, IEnumerable<string> urlItems, string groupName,
CheckStatus partialSuccessStatus, Func<HttpResponseMessage, Task<IHealthCheckResult>> checkFunc)
{
Guard.ArgumentNotNull(nameof(checkFunc), checkFunc);
return AddUrlChecks(builder, urlItems, groupName, partialSuccessStatus, response => new ValueTask<IHealthCheckResult>(checkFunc(response)));
}
public static HealthCheckBuilder AddUrlChecks(this HealthCheckBuilder builder, IEnumerable<string> urlItems, string groupName,
CheckStatus partialSuccessStatus, Func<HttpResponseMessage, ValueTask<IHealthCheckResult>> checkFunc)
{
var urls = urlItems?.ToArray();
Guard.ArgumentNotNull(nameof(builder), builder);
Guard.ArgumentNotNullOrEmpty(nameof(urlItems), urls);
Guard.ArgumentNotNullOrWhitespace(nameof(groupName), groupName);
var urlChecker = new UrlChecker(checkFunc, urls) { PartiallyHealthyStatus = partialSuccessStatus };
builder.AddCheck($"UrlChecks({groupName})", () => urlChecker.CheckAsync());
return builder;
}
}
}

+ 11
- 8
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/CompositeHealthCheckResult.cs View File

@ -7,7 +7,6 @@ using System.Linq;
namespace Microsoft.Extensions.HealthChecks
{
// REVIEW: Does this need to be thread safe?
/// <summary>
/// Represents a composite health check result built from several results.
/// </summary>
@ -31,17 +30,23 @@ namespace Microsoft.Extensions.HealthChecks
{
var checkStatuses = new HashSet<CheckStatus>(_results.Select(x => x.Value.CheckStatus));
if (checkStatuses.Count == 0)
{
return _initialStatus;
}
if (checkStatuses.Count == 1)
{
return checkStatuses.First();
}
if (checkStatuses.Contains(CheckStatus.Healthy))
{
return _partiallyHealthyStatus;
}
return CheckStatus.Unhealthy;
}
}
public string Description => string.Join(Environment.NewLine, _results.Select(r => r.Value.Description));
public string Description => string.Join(Environment.NewLine, _results.Select(r => $"{r.Key}: {r.Value.Description}"));
public IReadOnlyDictionary<string, object> Data
{
@ -58,23 +63,21 @@ namespace Microsoft.Extensions.HealthChecks
public IReadOnlyDictionary<string, IHealthCheckResult> Results => _results;
// REVIEW: Should description be required? Seems redundant for success checks.
public void Add(string name, CheckStatus status, string description)
=> Add(name, status, description, null);
public void Add(string name, CheckStatus status, string description, Dictionary<string, object> data)
{
Guard.ArgumentNotNullOrWhitespace(nameof(name), name);
Guard.ArgumentValid(status != CheckStatus.Unknown, nameof(status), "Cannot add unknown status to composite health check result");
Guard.ArgumentNotNullOrWhitespace(nameof(description), description);
Guard.ArgumentNotNullOrEmpty(nameof(name), name);
Guard.ArgumentValid(status != CheckStatus.Unknown, nameof(status), "Cannot add 'Unknown' status to composite health check result.");
Guard.ArgumentNotNullOrEmpty(nameof(description), description);
_results.Add(name, HealthCheckResult.FromStatus(status, description, data));
}
public void Add(string name, IHealthCheckResult checkResult)
{
Guard.ArgumentNotNullOrWhitespace(nameof(name), name);
Guard.ArgumentNotNullOrEmpty(nameof(name), name);
Guard.ArgumentNotNull(nameof(checkResult), checkResult);
_results.Add(name, checkResult);


+ 15
- 49
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheck.cs View File

@ -9,68 +9,34 @@ namespace Microsoft.Extensions.HealthChecks
{
public class HealthCheck : IHealthCheck
{
private DateTimeOffset _cacheExpiration;
private IHealthCheckResult _cachedResult;
private volatile int _writerCount;
protected HealthCheck(Func<CancellationToken, ValueTask<IHealthCheckResult>> check, TimeSpan cacheDuration)
protected HealthCheck(Func<CancellationToken, ValueTask<IHealthCheckResult>> check)
{
Guard.ArgumentNotNull(nameof(check), check);
Guard.ArgumentValid(cacheDuration >= TimeSpan.Zero, nameof(cacheDuration), "Cache duration must either be zero (disabled) or a positive value");
Check = check;
CacheDuration = cacheDuration;
}
public TimeSpan CacheDuration { get; }
protected Func<CancellationToken, ValueTask<IHealthCheckResult>> Check { get; }
protected virtual DateTimeOffset UtcNow => DateTimeOffset.UtcNow;
public async ValueTask<IHealthCheckResult> CheckAsync(CancellationToken cancellationToken)
{
while (_cacheExpiration <= UtcNow)
{
// Can't use a standard lock here because of async, so we'll use this flag to determine when we should write a value,
// and the waiters who aren't allowed to write will just spin wait for the new value.
if (Interlocked.Exchange(ref _writerCount, 1) != 0)
{
await Task.Delay(5, cancellationToken).ConfigureAwait(false);
continue;
}
try
{
_cachedResult = await Check(cancellationToken).ConfigureAwait(false);
_cacheExpiration = UtcNow + CacheDuration;
break;
}
finally
{
_writerCount = 0;
}
}
return _cachedResult;
}
public ValueTask<IHealthCheckResult> CheckAsync(CancellationToken cancellationToken = default(CancellationToken))
=> Check(cancellationToken);
public static HealthCheck FromCheck(Func<IHealthCheckResult> check, TimeSpan cacheDuration)
=> new HealthCheck(token => new ValueTask<IHealthCheckResult>(check()), cacheDuration);
public static HealthCheck FromCheck(Func<IHealthCheckResult> check)
=> new HealthCheck(token => new ValueTask<IHealthCheckResult>(check()));
public static HealthCheck FromCheck(Func<CancellationToken, IHealthCheckResult> check, TimeSpan cacheDuration)
=> new HealthCheck(token => new ValueTask<IHealthCheckResult>(check(token)), cacheDuration);
public static HealthCheck FromCheck(Func<CancellationToken, IHealthCheckResult> check)
=> new HealthCheck(token => new ValueTask<IHealthCheckResult>(check(token)));
public static HealthCheck FromTaskCheck(Func<Task<IHealthCheckResult>> check, TimeSpan cacheDuration)
=> new HealthCheck(token => new ValueTask<IHealthCheckResult>(check()), cacheDuration);
public static HealthCheck FromTaskCheck(Func<Task<IHealthCheckResult>> check)
=> new HealthCheck(token => new ValueTask<IHealthCheckResult>(check()));
public static HealthCheck FromTaskCheck(Func<CancellationToken, Task<IHealthCheckResult>> check, TimeSpan cacheDuration)
=> new HealthCheck(token => new ValueTask<IHealthCheckResult>(check(token)), cacheDuration);
public static HealthCheck FromTaskCheck(Func<CancellationToken, Task<IHealthCheckResult>> check)
=> new HealthCheck(token => new ValueTask<IHealthCheckResult>(check(token)));
public static HealthCheck FromValueTaskCheck(Func<ValueTask<IHealthCheckResult>> check, TimeSpan cacheDuration)
=> new HealthCheck(token => check(), cacheDuration);
public static HealthCheck FromValueTaskCheck(Func<ValueTask<IHealthCheckResult>> check)
=> new HealthCheck(token => check());
public static HealthCheck FromValueTaskCheck(Func<CancellationToken, ValueTask<IHealthCheckResult>> check, TimeSpan cacheDuration)
=> new HealthCheck(check, cacheDuration);
public static HealthCheck FromValueTaskCheck(Func<CancellationToken, ValueTask<IHealthCheckResult>> check)
=> new HealthCheck(check);
}
}

+ 102
- 7
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckBuilder.cs View File

@ -8,33 +8,128 @@ namespace Microsoft.Extensions.HealthChecks
{
public class HealthCheckBuilder
{
private readonly Dictionary<string, IHealthCheck> _checks;
private readonly Dictionary<string, CachedHealthCheck> _checksByName;
private readonly HealthCheckGroup _currentGroup;
private readonly Dictionary<string, HealthCheckGroup> _groups;
public HealthCheckBuilder()
{
_checks = new Dictionary<string, IHealthCheck>(StringComparer.OrdinalIgnoreCase);
_checksByName = new Dictionary<string, CachedHealthCheck>(StringComparer.OrdinalIgnoreCase);
_currentGroup = new HealthCheckGroup(string.Empty, CheckStatus.Unhealthy);
_groups = new Dictionary<string, HealthCheckGroup>(StringComparer.OrdinalIgnoreCase)
{
[string.Empty] = _currentGroup
};
DefaultCacheDuration = TimeSpan.FromMinutes(5);
}
public IReadOnlyDictionary<string, IHealthCheck> Checks => _checks;
/// <summary>
/// This constructor should only be used when creating a grouped health check builder.
/// </summary>
public HealthCheckBuilder(HealthCheckBuilder rootBuilder, HealthCheckGroup currentGroup)
{
Guard.ArgumentNotNull(nameof(rootBuilder), rootBuilder);
Guard.ArgumentNotNull(nameof(currentGroup), currentGroup);
_checksByName = rootBuilder._checksByName;
_currentGroup = currentGroup;
_groups = rootBuilder._groups;
DefaultCacheDuration = rootBuilder.DefaultCacheDuration;
}
/// <summary>
/// Gets the registered checks, indexed by check name.
/// </summary>
public IReadOnlyDictionary<string, CachedHealthCheck> ChecksByName => _checksByName;
/// <summary>
/// Gets the current default cache duration used when registering checks.
/// </summary>
public TimeSpan DefaultCacheDuration { get; private set; }
public HealthCheckBuilder AddCheck(string name, IHealthCheck check)
/// <summary>
/// Gets the registered groups, indexed by group name. The root group's name is <see cref="string.Empty"/>.
/// </summary>
public IReadOnlyDictionary<string, HealthCheckGroup> Groups => _groups;
/// <summary>
/// Registers a health check type that will later be resolved via dependency
/// injection.
/// </summary>
public HealthCheckBuilder AddCheck<TCheck>(string checkName, TimeSpan cacheDuration) where TCheck : class, IHealthCheck
{
Guard.ArgumentNotNullOrWhitespace(nameof(name), name);
Guard.ArgumentNotNullOrEmpty(nameof(checkName), checkName);
Guard.ArgumentValid(!_checksByName.ContainsKey(checkName), nameof(checkName), $"A check with name '{checkName}' has already been registered.");
var namedCheck = CachedHealthCheck.FromType(checkName, cacheDuration, typeof(TCheck));
_checksByName.Add(checkName, namedCheck);
_currentGroup.ChecksInternal.Add(namedCheck);
return this;
}
/// <summary>
/// Registers a concrete health check to the builder.
/// </summary>
public HealthCheckBuilder AddCheck(string checkName, IHealthCheck check, TimeSpan cacheDuration)
{
Guard.ArgumentNotNullOrEmpty(nameof(checkName), checkName);
Guard.ArgumentNotNull(nameof(check), check);
Guard.ArgumentValid(!_checksByName.ContainsKey(checkName), nameof(checkName), $"A check with name '{checkName}' has already been registered.");
var namedCheck = CachedHealthCheck.FromHealthCheck(checkName, cacheDuration, check);
_checksByName.Add(checkName, namedCheck);
_currentGroup.ChecksInternal.Add(namedCheck);
return this;
}
/// <summary>
/// Creates a new health check group, to which you can add one or more health
/// checks. Uses <see cref="CheckStatus.Unhealthy"/> when the group is
/// partially successful.
/// </summary>
public HealthCheckBuilder AddHealthCheckGroup(string groupName, Action<HealthCheckBuilder> groupChecks)
=> AddHealthCheckGroup(groupName, groupChecks, CheckStatus.Unhealthy);
/// <summary>
/// Creates a new health check group, to which you can add one or more health
/// checks.
/// </summary>
public HealthCheckBuilder AddHealthCheckGroup(string groupName, Action<HealthCheckBuilder> groupChecks, CheckStatus partialSuccessStatus)
{
Guard.ArgumentNotNullOrEmpty(nameof(groupName), groupName);
Guard.ArgumentNotNull(nameof(groupChecks), groupChecks);
Guard.ArgumentValid(partialSuccessStatus != CheckStatus.Unknown, nameof(partialSuccessStatus), "Check status 'Unknown' is not valid for partial success.");
Guard.ArgumentValid(!_groups.ContainsKey(groupName), nameof(groupName), $"A group with name '{groupName}' has already been registered.");
Guard.OperationValid(_currentGroup.GroupName == string.Empty, "Nested groups are not supported by HealthCheckBuilder.");
var group = new HealthCheckGroup(groupName, partialSuccessStatus);
_groups.Add(groupName, group);
var innerBuilder = new HealthCheckBuilder(this, group);
groupChecks(innerBuilder);
_checks.Add(name, check);
return this;
}
public HealthCheckBuilder WithDefaultCacheDuration(TimeSpan duration)
{
Guard.ArgumentValid(duration >= TimeSpan.Zero, nameof(duration), "Duration must be zero (disabled) or a positive duration");
Guard.ArgumentValid(duration >= TimeSpan.Zero, nameof(duration), "Duration must be zero (disabled) or a positive duration.");
DefaultCacheDuration = duration;
return this;
}
public HealthCheckBuilder WithPartialSuccessStatus(CheckStatus partiallyHealthyStatus)
{
_currentGroup.PartiallyHealthyStatus = partiallyHealthyStatus;
return this;
}
}
}

+ 0
- 18
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckExtensions.cs View File

@ -1,18 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Extensions.HealthChecks
{
public static class HealthCheckExtensions
{
public static ValueTask<IHealthCheckResult> CheckAsync(this IHealthCheck healthCheck)
{
Guard.ArgumentNotNull(nameof(healthCheck), healthCheck);
return healthCheck.CheckAsync(CancellationToken.None);
}
}
}

+ 37
- 0
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckGroup.cs View File

@ -0,0 +1,37 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
namespace Microsoft.Extensions.HealthChecks
{
public class HealthCheckGroup
{
private CheckStatus _partialSuccessStatus;
public HealthCheckGroup(string groupName, CheckStatus partialSuccessStatus)
{
Guard.ArgumentNotNull(nameof(groupName), groupName);
GroupName = groupName;
PartiallyHealthyStatus = partialSuccessStatus;
}
public IReadOnlyList<CachedHealthCheck> Checks => ChecksInternal.AsReadOnly();
internal List<CachedHealthCheck> ChecksInternal { get; } = new List<CachedHealthCheck>();
public string GroupName { get; }
public CheckStatus PartiallyHealthyStatus
{
get => _partialSuccessStatus;
internal set
{
Guard.ArgumentValid(value != CheckStatus.Unknown, nameof(value), "Check status 'Unknown' is not valid for partial success.");
_partialSuccessStatus = value;
}
}
}
}

+ 0
- 1
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckResult.cs View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.Extensions.HealthChecks
{


+ 91
- 26
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckService.cs View File

@ -3,52 +3,117 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.Extensions.HealthChecks
{
public class HealthCheckService : IHealthCheckService
{
public IReadOnlyDictionary<string, IHealthCheck> _checks;
private readonly HealthCheckBuilder _builder;
private readonly IReadOnlyList<HealthCheckGroup> _groups;
private readonly HealthCheckGroup _root;
private readonly IServiceProvider _serviceProvider;
private readonly IServiceScopeFactory _serviceScopeFactory;
private ILogger<HealthCheckService> _logger;
public HealthCheckService(HealthCheckBuilder builder, ILogger<HealthCheckService> logger)
public HealthCheckService(HealthCheckBuilder builder, IServiceProvider serviceProvider, IServiceScopeFactory serviceScopeFactory)
{
_checks = builder.Checks;
_logger = logger;
_builder = builder;
_groups = GetGroups().Where(group => group.GroupName != string.Empty).ToList();
_root = GetGroup(string.Empty);
_serviceProvider = serviceProvider;
_serviceScopeFactory = serviceScopeFactory;
}
public async Task<CompositeHealthCheckResult> CheckHealthAsync(CheckStatus partiallyHealthyStatus, CancellationToken cancellationToken)
public async Task<CompositeHealthCheckResult> CheckHealthAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var logMessage = new StringBuilder();
var result = new CompositeHealthCheckResult(partiallyHealthyStatus);
foreach (var check in _checks)
using (var scope = GetServiceScope())
{
try
{
var healthCheckResult = await check.Value.CheckAsync().ConfigureAwait(false);
logMessage.AppendLine($"HealthCheck: {check.Key} : {healthCheckResult.CheckStatus}");
result.Add(check.Key, healthCheckResult);
}
catch (Exception ex)
var scopeServiceProvider = scope.ServiceProvider;
var groupTasks = _groups.Select(group => new { Group = group, Task = RunGroupAsync(scopeServiceProvider, group, cancellationToken) }).ToList();
var result = await RunGroupAsync(scopeServiceProvider, _root, cancellationToken).ConfigureAwait(false);
await Task.WhenAll(groupTasks.Select(x => x.Task));
foreach (var groupTask in groupTasks)
{
logMessage.AppendLine($"HealthCheck: {check.Key} : Exception {ex.GetType().FullName} thrown");
result.Add(check.Key, CheckStatus.Unhealthy, $"Exception during check: {ex.GetType().FullName}");
result.Add($"Group({groupTask.Group.GroupName})", groupTask.Task.Result);
}
return result;
}
}
public IReadOnlyList<CachedHealthCheck> GetAllChecks()
=> _builder.ChecksByName.Values.ToList().AsReadOnly();
if (logMessage.Length == 0)
logMessage.AppendLine("HealthCheck: No checks have been registered");
public CachedHealthCheck GetCheck(string checkName)
=> _builder.ChecksByName[checkName];
public HealthCheckGroup GetGroup(string groupName)
=> _builder.Groups[groupName];
public IReadOnlyList<HealthCheckGroup> GetGroups()
=> _builder.Groups.Values.ToList().AsReadOnly();
private IServiceScope GetServiceScope()
=> _serviceScopeFactory == null ? new UnscopedServiceProvider(_serviceProvider) : _serviceScopeFactory.CreateScope();
public async ValueTask<IHealthCheckResult> RunCheckAsync(CachedHealthCheck healthCheck, CancellationToken cancellationToken = default(CancellationToken))
{
using (var scope = GetServiceScope())
{
return await RunCheckAsync(scope.ServiceProvider, healthCheck, cancellationToken).ConfigureAwait(false);
}
}
/// <summary>
/// Uses the provided service provider and executes the provided check.
/// </summary>
public ValueTask<IHealthCheckResult> RunCheckAsync(IServiceProvider serviceProvider, CachedHealthCheck healthCheck, CancellationToken cancellationToken = default(CancellationToken))
{
Guard.ArgumentNotNull(nameof(serviceProvider), serviceProvider);
Guard.ArgumentNotNull(nameof(healthCheck), healthCheck);
return healthCheck.RunAsync(serviceProvider, cancellationToken);
}
/// <summary>
/// Creates a new resolution scope from the default service provider and executes the checks in the given group.
/// </summary>
public async Task<CompositeHealthCheckResult> RunGroupAsync(HealthCheckGroup group, CancellationToken cancellationToken = default(CancellationToken))
{
using (var scope = GetServiceScope())
return await RunGroupAsync(scope.ServiceProvider, group, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Uses the provided service provider and executes the checks in the given group.
/// </summary>
public async Task<CompositeHealthCheckResult> RunGroupAsync(IServiceProvider serviceProvider, HealthCheckGroup group, CancellationToken cancellationToken = default(CancellationToken))
{
var result = new CompositeHealthCheckResult(group.PartiallyHealthyStatus);
var checkTasks = group.Checks.Select(check => new { Check = check, Task = check.RunAsync(serviceProvider, cancellationToken).AsTask() }).ToList();
await Task.WhenAll(checkTasks.Select(checkTask => checkTask.Task));
foreach (var checkTask in checkTasks)
{
result.Add(checkTask.Check.Name, checkTask.Task.Result);
}
_logger.Log((result.CheckStatus == CheckStatus.Healthy ? LogLevel.Information : LogLevel.Error), 0, logMessage.ToString(), null, MessageFormatter);
return result;
}
private static string MessageFormatter(string state, Exception error) => state;
private class UnscopedServiceProvider : IServiceScope
{
public UnscopedServiceProvider(IServiceProvider serviceProvider)
=> ServiceProvider = serviceProvider;
public IServiceProvider ServiceProvider { get; }
public void Dispose() { }
}
}
}

+ 13
- 5
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckServiceCollectionExtensions.cs View File

@ -2,20 +2,28 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Linq;
using Microsoft.Extensions.HealthChecks;
namespace Microsoft.Extensions.DependencyInjection
{
public static class HealthCheckServiceCollectionExtensions
{
public static IServiceCollection AddHealthChecks(this IServiceCollection services, Action<HealthCheckBuilder> checkupAction)
private static readonly Type HealthCheckServiceInterface = typeof(IHealthCheckService);
public static IServiceCollection AddHealthChecks(this IServiceCollection services, Action<HealthCheckBuilder> checks)
{
var checkupBuilder = new HealthCheckBuilder();
Guard.OperationValid(!services.Any(descriptor => descriptor.ServiceType == HealthCheckServiceInterface), "AddHealthChecks may only be called once.");
var builder = new HealthCheckBuilder();
checkupAction.Invoke(checkupBuilder);
services.AddSingleton<IHealthCheckService, HealthCheckService>(serviceProvider =>
{
var serviceScopeFactory = serviceProvider.GetService<IServiceScopeFactory>();
return new HealthCheckService(builder, serviceProvider, serviceScopeFactory);
});
services.AddSingleton(checkupBuilder);
services.AddSingleton<IHealthCheckService, HealthCheckService>();
checks(builder);
return services;
}
}


+ 0
- 38
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckServiceExtensions.cs View File

@ -1,38 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Extensions.HealthChecks
{
public static class HealthCheckServiceExtensions
{
public static Task<CompositeHealthCheckResult> CheckHealthAsync(this IHealthCheckService service)
{
Guard.ArgumentNotNull(nameof(service), service);
return service.CheckHealthAsync(CheckStatus.Unhealthy, CancellationToken.None);
}
public static Task<CompositeHealthCheckResult> CheckHealthAsync(this IHealthCheckService service, CheckStatus partiallyHealthyStatus)
{
Guard.ArgumentNotNull(nameof(service), service);
return service.CheckHealthAsync(partiallyHealthyStatus, CancellationToken.None);
}
public static Task<CompositeHealthCheckResult> CheckHealthAsync(this IHealthCheckService service, CancellationToken cancellationToken)
{
Guard.ArgumentNotNull(nameof(service), service);
return service.CheckHealthAsync(CheckStatus.Unhealthy, cancellationToken);
}
public static Task<CompositeHealthCheckResult> CheckHealthAsync(this IHealthCheckService service, CheckStatus partiallyHealthyStatus, CancellationToken cancellationToken)
{
Guard.ArgumentNotNull(nameof(service), service);
return service.CheckHealthAsync(partiallyHealthyStatus, cancellationToken);
}
}
}

+ 1
- 4
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/IHealthCheck.cs View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading;
using System.Threading.Tasks;
@ -9,8 +8,6 @@ namespace Microsoft.Extensions.HealthChecks
{
public interface IHealthCheck
{
TimeSpan CacheDuration { get; }
ValueTask<IHealthCheckResult> CheckAsync(CancellationToken cancellationToken);
ValueTask<IHealthCheckResult> CheckAsync(CancellationToken cancellationToken = default(CancellationToken));
}
}

+ 46
- 1
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/IHealthCheckService.cs View File

@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@ -8,6 +10,49 @@ namespace Microsoft.Extensions.HealthChecks
{
public interface IHealthCheckService
{
Task<CompositeHealthCheckResult> CheckHealthAsync(CheckStatus partiallyHealthyStatus, CancellationToken cancellationToken);
/// <summary>
/// Runs all registered health checks.
/// </summary>
Task<CompositeHealthCheckResult> CheckHealthAsync(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Gets all registered health checks as a flat list.
/// </summary>
IReadOnlyList<CachedHealthCheck> GetAllChecks();
/// <summary>
/// Gets a health check by name.
/// </summary>
CachedHealthCheck GetCheck(string checkName);
/// <summary>
/// Gets all health checks in a group.
/// </summary>
HealthCheckGroup GetGroup(string groupName);
/// <summary>
/// Gets all the health check groups.
/// </summary>
IReadOnlyList<HealthCheckGroup> GetGroups();
/// <summary>
/// Creates a new resolution scope from the default service provider and executes the provided check.
/// </summary>
ValueTask<IHealthCheckResult> RunCheckAsync(CachedHealthCheck healthCheck, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Uses the provided service provider and executes the provided check.
/// </summary>
ValueTask<IHealthCheckResult> RunCheckAsync(IServiceProvider serviceProvider, CachedHealthCheck healthCheck, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Creates a new resolution scope from the default service provider and executes the checks in the given group.
/// </summary>
Task<CompositeHealthCheckResult> RunGroupAsync(HealthCheckGroup group, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Uses the provided service provider and executes the checks in the given group.
/// </summary>
Task<CompositeHealthCheckResult> RunGroupAsync(IServiceProvider serviceProvider, HealthCheckGroup group, CancellationToken cancellationToken = default(CancellationToken));
}
}

+ 18
- 42
src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Internal/UrlChecker.cs View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
@ -13,55 +12,33 @@ namespace Microsoft.Extensions.HealthChecks.Internal
public class UrlChecker
{
private readonly Func<HttpResponseMessage, ValueTask<IHealthCheckResult>> _checkFunc;
private readonly string[] _urls;
private readonly string _url;
// REVIEW: Cache timeout here?
public UrlChecker(Func<HttpResponseMessage, ValueTask<IHealthCheckResult>> checkFunc, params string[] urls)
public UrlChecker(Func<HttpResponseMessage, ValueTask<IHealthCheckResult>> checkFunc, string url)
{
Guard.ArgumentNotNull(nameof(checkFunc), checkFunc);
Guard.ArgumentNotNullOrEmpty(nameof(urls), urls);
Guard.ArgumentNotNullOrEmpty(nameof(url), url);
_checkFunc = checkFunc;
_urls = urls;
_url = url;
}
public CheckStatus PartiallyHealthyStatus { get; set; } = CheckStatus.Warning;
public Task<IHealthCheckResult> CheckAsync()
=> _urls.Length == 1 ? CheckSingleAsync() : CheckMultiAsync();
public async Task<IHealthCheckResult> CheckSingleAsync()
{
var httpClient = CreateHttpClient();
var result = default(IHealthCheckResult);
await CheckUrlAsync(httpClient, _urls[0], (_, checkResult) => result = checkResult).ConfigureAwait(false);
return result;
}
public async Task<IHealthCheckResult> CheckMultiAsync()
public async Task<IHealthCheckResult> CheckAsync()
{
var composite = new CompositeHealthCheckResult(PartiallyHealthyStatus);
var httpClient = CreateHttpClient();
// REVIEW: Should these be done in parallel?
foreach (var url in _urls)
await CheckUrlAsync(httpClient, url, (name, checkResult) => composite.Add(name, checkResult)).ConfigureAwait(false);
return composite;
}
private async Task CheckUrlAsync(HttpClient httpClient, string url, Action<string, IHealthCheckResult> adder)
{
var name = $"UrlCheck({url})";
try
{
var response = await httpClient.GetAsync(url).ConfigureAwait(false);
var result = await _checkFunc(response);
adder(name, result);
}
catch (Exception ex)
using (var httpClient = CreateHttpClient())
{
adder(name, HealthCheckResult.Unhealthy($"Exception during check: {ex.GetType().FullName}"));
try
{
var response = await httpClient.GetAsync(_url).ConfigureAwait(false);
return await _checkFunc(response);
}
catch (Exception ex)
{
var data = new Dictionary<string, object> { { "url", _url } };
return HealthCheckResult.Unhealthy($"Exception during check: {ex.GetType().FullName}", data);
}
}
}
@ -74,8 +51,7 @@ namespace Microsoft.Extensions.HealthChecks.Internal
public static async ValueTask<IHealthCheckResult> DefaultUrlCheck(HttpResponseMessage response)
{
// REVIEW: Should this be an explicit 200 check, or just an "is success" check?
var status = response.StatusCode == HttpStatusCode.OK ? CheckStatus.Healthy : CheckStatus.Unhealthy;
var status = response.IsSuccessStatusCode ? CheckStatus.Healthy : CheckStatus.Unhealthy;
var data = new Dictionary<string, object>
{
{ "url", response.RequestMessage.RequestUri.ToString() },
@ -83,7 +59,7 @@ namespace Microsoft.Extensions.HealthChecks.Internal
{ "reason", response.ReasonPhrase },
{ "body", await response.Content?.ReadAsStringAsync() }
};
return HealthCheckResult.FromStatus(status, $"UrlCheck({response.RequestMessage.RequestUri}): status code {response.StatusCode} ({(int)response.StatusCode})", data);
return HealthCheckResult.FromStatus(status, $"status code {response.StatusCode} ({(int)response.StatusCode})", data);
}
protected virtual HttpClient GetHttpClient()


+ 22
- 10
src/BuildingBlocks/HealthChecks/src/common/Guard.cs View File

@ -9,37 +9,49 @@ static class Guard
public static void ArgumentNotNull(string argumentName, object value)
{
if (value == null)
{
throw new ArgumentNullException(argumentName);
}
}
public static void ArgumentNotNullOrEmpty<T>(string argumentName, string value)
public static void ArgumentNotNullOrEmpty(string argumentName, string value)
{
if (value == null)
{
throw new ArgumentNullException(argumentName);
}
if (string.IsNullOrEmpty(value))
throw new ArgumentException("Value cannot be an empty string", argumentName);
{
throw new ArgumentException("Value cannot be an empty string.", argumentName);
}
}
// Use IReadOnlyCollection<T> instead of IEnumerable<T> to discourage double enumeration
public static void ArgumentNotNullOrEmpty<T>(string argumentName, IReadOnlyCollection<T> items)
{
if (items == null)
{
throw new ArgumentNullException(argumentName);
}
if (items.Count == 0)
throw new ArgumentException("Collection must contain at least one item", argumentName);
{
throw new ArgumentException("Collection must contain at least one item.", argumentName);
}
}
public static void ArgumentNotNullOrWhitespace(string argumentName, string value)
public static void ArgumentValid(bool valid, string argumentName, string exceptionMessage)
{
if (value == null)
throw new ArgumentNullException(argumentName);
if (string.IsNullOrWhiteSpace(value))
throw new ArgumentException("Value must contain a non-whitespace value", argumentName);
if (!valid)
{
throw new ArgumentException(exceptionMessage, argumentName);
}
}
public static void ArgumentValid(bool valid, string argumentName, string exceptionMessage)
public static void OperationValid(bool valid, string exceptionMessage)
{
if (!valid)
throw new ArgumentException(exceptionMessage, argumentName);
{
throw new InvalidOperationException(exceptionMessage);
}
}
}

+ 1
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs View File

@ -27,8 +27,7 @@ namespace eShopOnContainers
private void InitApp()
{
UseMockServices = Settings.UseMocks;
ViewModelLocator.Initialize();
ViewModelLocator.UpdateDependencies(UseMockServices);
ViewModelLocator.RegisterDependencies(UseMockServices);
}
private Task InitNavigation()


+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Behaviors/EventToCommandBehavior.cs View File

@ -31,7 +31,7 @@ namespace eShopOnContainers.Core.Behaviors
BindableProperty.CreateAttached("EventArgsConverterParameter", typeof(object), typeof(EventToCommandBehavior), null,
BindingMode.OneWay);
private Delegate _handler;
protected Delegate _handler;
private EventInfo _eventInfo;
public string EventName


+ 0
- 3
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Helpers/Settings.cs View File

@ -1,4 +1,3 @@
using eShopOnContainers.Core.ViewModels.Base;
using Plugin.Settings;
using Plugin.Settings.Abstractions;
@ -32,7 +31,6 @@ namespace eShopOnContainers.Core.Helpers
#endregion
public static string AuthAccessToken
{
get
@ -57,7 +55,6 @@ namespace eShopOnContainers.Core.Helpers
}
}
public static bool UseMocks
{
get


+ 5
- 7
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketService.cs View File

@ -16,8 +16,7 @@ namespace eShopOnContainers.Core.Services.Basket
}
public async Task<CustomerBasket> GetBasketAsync(string guidUser, string token)
{
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
builder.Path = guidUser;
@ -30,18 +29,17 @@ namespace eShopOnContainers.Core.Services.Basket
ServicesHelper.FixBasketItemPictureUri(basket?.Items);
return basket;
}
public async Task<CustomerBasket> UpdateBasketAsync(CustomerBasket customerBasket, string token)
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
string uri = builder.ToString();
string uri = builder.ToString();
var result = await _requestProvider.PostAsync(uri, customerBasket, token);
var result = await _requestProvider.PostAsync(uri, customerBasket, token);
return result;
return result;
}
public async Task ClearBasketAsync(string guidUser, string token)


+ 0
- 7
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs View File

@ -61,12 +61,5 @@ namespace eShopOnContainers.Core.Services.Catalog
return MockCatalogType;
}
public async Task<CatalogItem> GetCatalogItemAsync(string id)
{
await Task.Delay(500);
return MockCatalog.FirstOrDefault(c => c.Id == id);
}
}
}

+ 11
- 24
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs View File

@ -20,7 +20,6 @@ namespace eShopOnContainers.Core.Services.Catalog
public async Task<ObservableCollection<CatalogItem>> FilterAsync(int catalogBrandId, int catalogTypeId)
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
builder.Path = string.Format("api/v1/catalog/items/type/{0}/brand/{1}", catalogTypeId, catalogBrandId);
@ -34,12 +33,10 @@ namespace eShopOnContainers.Core.Services.Catalog
return catalog?.Data.ToObservableCollection();
else
return new ObservableCollection<CatalogItem>();
}
public async Task<ObservableCollection<CatalogItem>> GetCatalogAsync()
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
builder.Path = "api/v1/catalog/items";
@ -56,37 +53,28 @@ namespace eShopOnContainers.Core.Services.Catalog
return catalog?.Data.ToObservableCollection();
}
else
return new ObservableCollection<CatalogItem>();
}
public Task<CatalogItem> GetCatalogItemAsync(string id)
{
throw new NotImplementedException();
return new ObservableCollection<CatalogItem>();
}
public async Task<ObservableCollection<CatalogBrand>> GetCatalogBrandAsync()
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
builder.Path = "api/v1/catalog/catalogbrands";
string uri = builder.ToString();
builder.Path = "api/v1/catalog/catalogbrands";
IEnumerable<CatalogBrand> brands =
await _requestProvider.GetAsync<IEnumerable<CatalogBrand>>(uri);
string uri = builder.ToString();
if (brands != null)
return brands?.ToObservableCollection();
else
return new ObservableCollection<CatalogBrand>();
IEnumerable<CatalogBrand> brands =
await _requestProvider.GetAsync<IEnumerable<CatalogBrand>>(uri);
if (brands != null)
return brands?.ToObservableCollection();
else
return new ObservableCollection<CatalogBrand>();
}
public async Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync()
{
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
builder.Path = "api/v1/catalog/catalogtypes";
@ -99,8 +87,7 @@ namespace eShopOnContainers.Core.Services.Catalog
if (types != null)
return types.ToObservableCollection();
else
return new ObservableCollection<CatalogType>();
return new ObservableCollection<CatalogType>();
}
}
}

+ 0
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs View File

@ -10,6 +10,5 @@ namespace eShopOnContainers.Core.Services.Catalog
Task<ObservableCollection<CatalogItem>> FilterAsync(int catalogBrandId, int catalogTypeId);
Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync();
Task<ObservableCollection<CatalogItem>> GetCatalogAsync();
Task<CatalogItem> GetCatalogItemAsync(string id);
}
}

+ 2
- 5
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Identity/IIdentityService.cs View File

@ -1,11 +1,8 @@
using System.Threading.Tasks;
namespace eShopOnContainers.Core.Services.Identity
namespace eShopOnContainers.Core.Services.Identity
{
public interface IIdentityService
{
string CreateAuthorizeRequest();
string CreateAuthorizationRequest();
string CreateLogoutRequest(string token);
string DecodeToken(string token);
}
}

+ 3
- 33
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Identity/IdentityService.cs View File

@ -1,19 +1,15 @@
using IdentityModel.Client;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace eShopOnContainers.Core.Services.Identity
{
public class IdentityService : IIdentityService
{
public string CreateAuthorizeRequest()
public string CreateAuthorizationRequest()
{
// Create URI to authorize endpoint
var authorizeRequest =
new AuthorizeRequest(GlobalSetting.Instance.IdentityEndpoint);
// Create URI to authorization endpoint
var authorizeRequest = new AuthorizeRequest(GlobalSetting.Instance.IdentityEndpoint);
// Dictionary with values for the authorize request
var dic = new Dictionary<string, string>();
@ -29,7 +25,6 @@ namespace eShopOnContainers.Core.Services.Identity
dic.Add("state", currentCSRFToken);
var authorizeUri = authorizeRequest.Create(dic);
return authorizeUri;
}
@ -45,30 +40,5 @@ namespace eShopOnContainers.Core.Services.Identity
token,
GlobalSetting.Instance.LogoutCallback);
}
public string DecodeToken(string token)
{
var parts = token.Split('.');
string partToConvert = parts[1];
partToConvert = partToConvert.Replace('-', '+');
partToConvert = partToConvert.Replace('_', '/');
switch (partToConvert.Length % 4)
{
case 0:
break;
case 2:
partToConvert += "==";
break;
case 3:
partToConvert += "=";
break;
}
var partAsBytes = Convert.FromBase64String(partToConvert);
var partAsUTF8String = Encoding.UTF8.GetString(partAsBytes, 0, partAsBytes.Count());
return JObject.Parse(partAsUTF8String).ToString();
}
}
}

+ 0
- 8
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/RequestProvider/IRequestProvider.cs View File

@ -6,16 +6,8 @@ namespace eShopOnContainers.Core.Services.RequestProvider
{
Task<TResult> GetAsync<TResult>(string uri, string token = "");
Task<TResult> PostAsync<TResult>(string uri, TResult data, string token = "");
Task<TResult> PostAsync<TResult>(string uri, TResult data, string token = "", string header = "");
Task<TResult> PostAsync<TRequest, TResult>(string uri, TRequest data, string token = "");
Task<TResult> PutAsync<TResult>(string uri, TResult data, string token = "");
Task<TResult> PutAsync<TRequest, TResult>(string uri, TRequest data, string token = "");
Task DeleteAsync(string uri, string token = "");
}
}

+ 2
- 46
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/RequestProvider/RequestProvider.cs View File

@ -5,7 +5,6 @@ using Newtonsoft.Json.Serialization;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System;
@ -23,7 +22,6 @@ namespace eShopOnContainers.Core.Services.RequestProvider
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
NullValueHandling = NullValueHandling.Ignore
};
_serializerSettings.Converters.Add(new StringEnumConverter());
}
@ -33,7 +31,6 @@ namespace eShopOnContainers.Core.Services.RequestProvider
HttpResponseMessage response = await httpClient.GetAsync(uri);
await HandleResponse(response);
string serialized = await response.Content.ReadAsStringAsync();
TResult result = await Task.Run(() =>
@ -56,7 +53,6 @@ namespace eShopOnContainers.Core.Services.RequestProvider
HttpResponseMessage response = await httpClient.PostAsync(uri, content);
await HandleResponse(response);
string serialized = await response.Content.ReadAsStringAsync();
TResult result = await Task.Run(() =>
@ -65,61 +61,21 @@ namespace eShopOnContainers.Core.Services.RequestProvider
return result;
}
public Task<TResult> PostAsync<TResult>(string uri, TResult data, string token = "")
{
return PostAsync<TResult, TResult>(uri, data, token);
}
public async Task<TResult> PostAsync<TRequest, TResult>(string uri, TRequest data, string token = "")
{
HttpClient httpClient = CreateHttpClient(token);
string serialized = await Task.Run(() => JsonConvert.SerializeObject(data, _serializerSettings));
var content = new StringContent(serialized, Encoding.UTF8, "application/json");
HttpResponseMessage response = await httpClient.PostAsync(uri, content);
await HandleResponse(response);
string responseData = await response.Content.ReadAsStringAsync();
return await Task.Run(() => JsonConvert.DeserializeObject<TResult>(responseData, _serializerSettings));
}
public Task<TResult> PutAsync<TResult>(string uri, TResult data, string token = "")
{
return PutAsync<TResult, TResult>(uri, data, token);
}
public async Task<TResult> PutAsync<TRequest, TResult>(string uri, TRequest data, string token = "")
{
HttpClient httpClient = CreateHttpClient(token);
string serialized = await Task.Run(() => JsonConvert.SerializeObject(data, _serializerSettings));
HttpResponseMessage response = await httpClient.PutAsync(uri, new StringContent(serialized, Encoding.UTF8, "application/json"));
await HandleResponse(response);
string responseData = await response.Content.ReadAsStringAsync();
return await Task.Run(() => JsonConvert.DeserializeObject<TResult>(responseData, _serializerSettings));
}
public async Task DeleteAsync(string uri, string token = "")
{
HttpClient httpClient = CreateHttpClient(token);
await httpClient.DeleteAsync(uri);
}
private HttpClient CreateHttpClient(string token = "")
{
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (!string.IsNullOrEmpty(token))
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
}
return httpClient;
}
@ -140,8 +96,8 @@ namespace eShopOnContainers.Core.Services.RequestProvider
{
var content = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.Forbidden
|| response.StatusCode == HttpStatusCode.Unauthorized)
if (response.StatusCode == HttpStatusCode.Forbidden ||
response.StatusCode == HttpStatusCode.Unauthorized)
{
throw new ServiceAuthenticationException(content);
}


+ 35
- 35
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/Base/ViewModelLocator.cs View File

@ -1,4 +1,4 @@
using Microsoft.Practices.Unity;
using Autofac;
using eShopOnContainers.Services;
using System;
using System.Globalization;
@ -16,7 +16,7 @@ namespace eShopOnContainers.Core.ViewModels.Base
{
public static class ViewModelLocator
{
private static readonly IUnityContainer _unityContainer = new UnityContainer();
private static IContainer _container;
public static readonly BindableProperty AutoWireViewModelProperty =
BindableProperty.CreateAttached("AutoWireViewModel", typeof(bool), typeof(ViewModelLocator), default(bool), propertyChanged: OnAutoWireViewModelChanged);
@ -33,56 +33,56 @@ namespace eShopOnContainers.Core.ViewModels.Base
public static bool UseMockService { get; set; }
public static void Initialize()
public static void RegisterDependencies(bool useMockServices)
{
// Services
_unityContainer.RegisterType<IDialogService, DialogService>();
_unityContainer.RegisterType<INavigationService, NavigationService>(new ContainerControlledLifetimeManager());
_unityContainer.RegisterType<IOpenUrlService, OpenUrlService>();
_unityContainer.RegisterType<IRequestProvider, RequestProvider>();
_unityContainer.RegisterType<IIdentityService, IdentityService>();
_unityContainer.RegisterType<ICatalogService, CatalogMockService>();
_unityContainer.RegisterType<IBasketService, BasketMockService>();
_unityContainer.RegisterType<IUserService, UserMockService>();
var builder = new ContainerBuilder();
// View models
_unityContainer.RegisterType<BasketViewModel>();
_unityContainer.RegisterType<CatalogViewModel>();
_unityContainer.RegisterType<CheckoutViewModel>();
_unityContainer.RegisterType<LoginViewModel>();
_unityContainer.RegisterType<MainViewModel>();
_unityContainer.RegisterType<OrderDetailViewModel>();
_unityContainer.RegisterType<ProfileViewModel>();
_unityContainer.RegisterType<SettingsViewModel>();
}
builder.RegisterType<BasketViewModel>();
builder.RegisterType<CatalogViewModel>();
builder.RegisterType<CheckoutViewModel>();
builder.RegisterType<LoginViewModel>();
builder.RegisterType<MainViewModel>();
builder.RegisterType<OrderDetailViewModel>();
builder.RegisterType<ProfileViewModel>();
builder.RegisterType<SettingsViewModel>();
// Services
builder.RegisterType<NavigationService>().As<INavigationService>().SingleInstance();
builder.RegisterType<DialogService>().As<IDialogService>();
builder.RegisterType<OpenUrlService>().As<IOpenUrlService>();
builder.RegisterType<IdentityService>().As<IIdentityService>();
builder.RegisterType<RequestProvider>().As<IRequestProvider>();
public static void UpdateDependencies(bool useMockServices)
{
// Change injected dependencies
if (useMockServices)
{
_unityContainer.RegisterInstance<ICatalogService>(new CatalogMockService());
_unityContainer.RegisterInstance<IBasketService>(new BasketMockService());
_unityContainer.RegisterInstance<IOrderService>(new OrderMockService());
_unityContainer.RegisterInstance<IUserService>(new UserMockService());
builder.RegisterInstance(new CatalogMockService()).As<ICatalogService>();
builder.RegisterInstance(new BasketMockService()).As<IBasketService>();
builder.RegisterInstance(new OrderMockService()).As<IOrderService>();
builder.RegisterInstance(new UserMockService()).As<IUserService>();
UseMockService = true;
}
else
{
var requestProvider = Resolve<IRequestProvider>();
_unityContainer.RegisterInstance<ICatalogService>(new CatalogService(requestProvider));
_unityContainer.RegisterInstance<IBasketService>(new BasketService(requestProvider));
_unityContainer.RegisterInstance<IOrderService>(new OrderService(requestProvider));
_unityContainer.RegisterInstance<IUserService>(new UserService(requestProvider));
builder.RegisterType<CatalogService>().As<ICatalogService>().SingleInstance();
builder.RegisterType<BasketService>().As<IBasketService>().SingleInstance();
builder.RegisterType<OrderService>().As<IOrderService>().SingleInstance();
builder.RegisterType<UserService>().As<IUserService>().SingleInstance();
UseMockService = false;
}
if (_container != null)
{
_container.Dispose();
}
_container = builder.Build();
}
public static T Resolve<T>()
{
return _unityContainer.Resolve<T>();
return _container.Resolve<T>();
}
private static void OnAutoWireViewModelChanged(BindableObject bindable, object oldValue, object newValue)
@ -103,7 +103,7 @@ namespace eShopOnContainers.Core.ViewModels.Base
{
return;
}
var viewModel = _unityContainer.Resolve(viewModelType);
var viewModel = _container.Resolve(viewModelType);
view.BindingContext = viewModel;
}
}

+ 0
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs View File

@ -5,8 +5,6 @@ using Xamarin.Forms;
using eShopOnContainers.Core.Models.Catalog;
using eShopOnContainers.Core.Services.Catalog;
using System.Windows.Input;
using eShopOnContainers.Core.Services.Basket;
using eShopOnContainers.Core.Services.User;
namespace eShopOnContainers.Core.ViewModels
{


+ 2
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs View File

@ -188,7 +188,7 @@ namespace eShopOnContainers.Core.ViewModels
await Task.Delay(500);
LoginUrl = _identityService.CreateAuthorizeRequest();
LoginUrl = _identityService.CreateAuthorizationRequest();
IsValid = true;
IsLogin = true;
@ -228,7 +228,7 @@ namespace eShopOnContainers.Core.ViewModels
Settings.AuthAccessToken = string.Empty;
Settings.AuthIdToken = string.Empty;
IsLogin = false;
LoginUrl = _identityService.CreateAuthorizeRequest();
LoginUrl = _identityService.CreateAuthorizationRequest();
}
else if (unescapedUrl.Contains(GlobalSetting.Instance.IdentityCallback))
{


+ 1
- 4
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/OrderDetailViewModel.cs View File

@ -1,8 +1,6 @@
using System.Threading.Tasks;
using eShopOnContainers.Core.Models.Orders;
using eShopOnContainers.Core.ViewModels.Base;
using eShopOnContainers.Core.Services.Catalog;
using eShopOnContainers.Core.Services.Basket;
using eShopOnContainers.Core.Services.Order;
using System;
using eShopOnContainers.Core.Helpers;
@ -11,9 +9,8 @@ namespace eShopOnContainers.Core.ViewModels
{
public class OrderDetailViewModel : ViewModelBase
{
private Order _order;
private IOrderService _ordersService;
private Order _order;
public OrderDetailViewModel(IOrderService ordersService)
{


+ 3
- 5
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/SettingsViewModel.cs View File

@ -71,16 +71,14 @@ namespace eShopOnContainers.Core.ViewModels
private void MockServices()
{
ViewModelLocator.UpdateDependencies(!UseAzureServices);
ViewModelLocator.RegisterDependencies(!UseAzureServices);
UpdateInfo();
}
public override Task InitializeAsync(object navigationData)
{
UpdateInfo();
Endpoint = Settings.UrlBase;
return base.InitializeAsync(navigationData);
}
@ -89,12 +87,12 @@ namespace eShopOnContainers.Core.ViewModels
if (!UseAzureServices)
{
Title = "Use Mock Services";
Description = "Mock Services are simulated objects that mimic the behavior of real services in controlled ways";
Description = "Mock Services are simulated objects that mimic the behavior of real services using a controlled approach.";
}
else
{
Title = "Use Microservices/Containers from eShopOnContainers";
Description = "When enabling the use of microservices/containers the Xamarin.Forms app will try to use real services deployed as Docker containers in the specified base IP that will need to be reachable through the network";
Description = "When enabling the use of microservices/containers, the app will attempt to use real services deployed as Docker containers at the specified base endpoint, which will must be reachable through the network.";
}
}


+ 2
- 80
src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj View File

@ -11,11 +11,11 @@
<RootNamespace>eShopOnContainers.Core</RootNamespace>
<AssemblyName>eShopOnContainers.Core</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -170,85 +170,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="Acr.UserDialogs, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Acr.UserDialogs.6.3.3\lib\portable-win+net45+wp8+win8+wpa81\Acr.UserDialogs.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Acr.UserDialogs.Interface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Acr.UserDialogs.6.3.3\lib\portable-win+net45+wp8+win8+wpa81\Acr.UserDialogs.Interface.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FFImageLoading, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xamarin.FFImageLoading.2.2.6-pre-256\lib\portable-net45+win8+wpa81+wp8\FFImageLoading.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FFImageLoading.Forms, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.2.6-pre-256\lib\portable-net45+win8+wpa81+wp8\FFImageLoading.Forms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FFImageLoading.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xamarin.FFImageLoading.2.2.6-pre-256\lib\portable-net45+win8+wpa81+wp8\FFImageLoading.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="IdentityModel.Portable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\IdentityModel.1.3.1\lib\portable-net45+wp80+win8+wpa81\IdentityModel.Portable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Unity.4.0.1\lib\portable-net45+wp80+win8+wpa81+MonoAndroid10+MonoTouch10\Microsoft.Practices.Unity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.9.0.2-beta1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Plugin.Settings, Version=2.6.0.12, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xam.Plugins.Settings.2.6.0.12-beta\lib\portable-net45+wp80+win8+wpa81\Plugin.Settings.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Plugin.Settings.Abstractions, Version=2.6.0.12, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xam.Plugins.Settings.2.6.0.12-beta\lib\portable-net45+wp80+win8+wpa81\Plugin.Settings.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SlideOverKit, Version=1.0.6135.18790, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\SlideOverKit.2.1.4\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SlideOverKit.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Splat.1.6.2\lib\Portable-net45+win+wpa81+wp80\Splat.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Extensions, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xamarin.Forms.2.3.3.175\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Pages, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xamarin.Forms.Pages.2.3.3.175\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10\Xamarin.Forms.Pages.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xamarin.Forms.2.3.3.175\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Xamarin.Forms.2.3.3.175\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll</HintPath>
<Private>True</Private>
</Reference>
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Controls\AddBasketButton.xaml">


+ 0
- 21
src/Mobile/eShopOnContainers/eShopOnContainers.Core/packages.config View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Acr.UserDialogs" version="6.3.3" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="CommonServiceLocator" version="1.3" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="IdentityModel" version="1.3.1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="modernhttpclient" version="2.4.2" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Newtonsoft.Json" version="9.0.2-beta1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="SlideOverKit" version="2.1.4" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Splat" version="1.6.2" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Unity" version="4.0.1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xam.Plugins.Settings" version="2.6.0.12-beta" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xamarin.FFImageLoading" version="2.2.6-pre-256" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xamarin.FFImageLoading.Forms" version="2.2.6-pre-256" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xamarin.Forms" version="2.3.3.175" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xamarin.Forms.Pages" version="2.3.3.175" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xamarin.Forms.Theme.Base" version="1.0.0.43-pre1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xamarin.Forms.Theme.Light" version="1.0.0.43-pre1" targetFramework="portable45-net45+win8+wp8+wpa81" />
</packages>

+ 25
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/project.json View File

@ -0,0 +1,25 @@
{
"dependencies": {
"Acr.UserDialogs": "6.3.3",
"Autofac": "4.4.0",
"CommonServiceLocator": "1.3",
"IdentityModel": "1.3.1",
"Microsoft.Bcl": "1.1.10",
"Microsoft.Bcl.Build": "1.0.21",
"Microsoft.Net.Http": "2.2.29",
"modernhttpclient": "2.4.2",
"Newtonsoft.Json": "9.0.2-beta1",
"SlideOverKit": "2.1.4",
"Splat": "1.6.2",
"Xam.Plugins.Settings": "2.6.0.12-beta",
"Xamarin.FFImageLoading": "2.2.6-pre-256",
"Xamarin.FFImageLoading.Forms": "2.2.6-pre-256",
"Xamarin.Forms": "2.3.3.175",
"Xamarin.Forms.Pages": "2.3.3.175",
"Xamarin.Forms.Theme.Base": "1.0.0.43-pre1",
"Xamarin.Forms.Theme.Light": "1.0.0.43-pre1"
},
"frameworks": {
".NETPortable,Version=v4.5,Profile=Profile111": {}
}
}

+ 2
- 11
src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj View File

@ -21,10 +21,11 @@
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
<AndroidStoreUncompressedFileExtensions />
<MandroidI18n />
<JavaMaximumHeapSize />
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<JavaOptions />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<AndroidTlsProvider></AndroidTlsProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@ -37,14 +38,8 @@
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<BundleAssemblies>False</BundleAssemblies>
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<Debugger>Xamarin</Debugger>
<AotAssemblies>False</AotAssemblies>
<EnableLLVM>False</EnableLLVM>
<AndroidEnableMultiDex>False</AndroidEnableMultiDex>
<EnableProguard>False</EnableProguard>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -102,10 +97,6 @@
<HintPath>..\..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Unity.4.0.1\lib\portable-net45+wp80+win8+wpa81+MonoAndroid10+MonoTouch10\Microsoft.Practices.Unity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ModernHttpClient, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\modernhttpclient.2.4.2\lib\MonoAndroid\ModernHttpClient.dll</HintPath>
<Private>True</Private>


+ 0
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Droid/packages.config View File

@ -35,7 +35,6 @@
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Xml.XDocument" version="4.0.11" targetFramework="monoandroid70" />
<package id="Unity" version="4.0.1" targetFramework="monoandroid70" />
<package id="Xam.Plugins.Settings" version="2.6.0.12-beta" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid70" />


+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/MainActivity.cs View File

@ -14,7 +14,7 @@ namespace eShopOnContainers.TestRunner.Droid
AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);
// or in any reference assemblies getting the Assembly from any type/class
AddTestAssembly(typeof(UnitTests.DummyTests).Assembly);
AddTestAssembly(typeof(UnitTests.CatalogViewModelTests).Assembly);
base.OnCreate(bundle);
}


+ 1
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj View File

@ -20,6 +20,7 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<AndroidTlsProvider></AndroidTlsProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>


+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Windows/App.xaml.cs View File

@ -12,7 +12,7 @@ namespace eShopOnContainers.TestRunner.Windows
{
// Otherwise you need to ensure that the test assemblies will
// become part of the app bundle
AddTestAssembly(typeof(UnitTests.DummyTests).GetTypeInfo().Assembly);
AddTestAssembly(typeof(UnitTests.CatalogViewModelTests).GetTypeInfo().Assembly);
}
}
}

+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/AppDelegate.cs View File

@ -17,7 +17,7 @@ namespace eShopOnContainers.TestRunner.iOS
// Otherwise you need to ensure that the test assemblies will
// become part of the app bundle
AddTestAssembly(typeof(UnitTests.DummyTests).Assembly);
AddTestAssembly(typeof(UnitTests.CatalogViewModelTests).Assembly);
return base.FinishedLaunching(app, options);
}


+ 6
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj View File

@ -155,6 +155,12 @@
<HintPath>..\..\..\..\packages\xunit.runner.utility.2.2.0-beta4-build3444\lib\netstandard1.1\xunit.runner.utility.dotnet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Plugin.Settings.Abstractions">
<HintPath>..\..\..\..\packages\Xam.Plugins.Settings.2.6.0.12-beta\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Plugin.Settings">
<HintPath>..\..\..\..\packages\Xam.Plugins.Settings.2.6.0.12-beta\lib\Xamarin.iOS10\Plugin.Settings.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="AppDelegate.cs.txt" />


+ 1
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/packages.config View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.3" targetFramework="xamarinios10" />
<package id="Xam.Plugins.Settings" version="2.6.0.12-beta" targetFramework="xamarinios10" />
<package id="Xamarin.Forms" version="2.3.3.175" targetFramework="xamarinios10" />
<package id="xunit" version="2.2.0-beta4-build3444" targetFramework="xamarinios10" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="xamarinios10" />


+ 120
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Behaviors/EventToCommandBehaviorTests.cs View File

@ -0,0 +1,120 @@
using Xunit;
using Xamarin.Forms;
using System;
using System.Globalization;
namespace eShopOnContainers.UnitTests
{
public class EventToCommandBehaviorTests
{
[Fact]
public void InvalidEventNameShouldThrowArgumentExceptionText()
{
var behavior = new MockEventToCommandBehavior
{
EventName = "OnItemTapped"
};
var listView = new ListView();
Assert.Throws<ArgumentException>(() => listView.Behaviors.Add(behavior));
}
[Fact]
public void CommandExecutedWhenEventFiresText()
{
bool executedCommand = false;
var behavior = new MockEventToCommandBehavior
{
EventName = "ItemTapped",
Command = new Command(() =>
{
executedCommand = true;
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, null);
Assert.True(executedCommand);
}
[Fact]
public void CommandCanExecuteTest()
{
var behavior = new MockEventToCommandBehavior
{
EventName = "ItemTapped",
Command = new Command(() => Assert.True(false), () => false)
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, null);
}
[Fact]
public void CommandCanExecuteWithParameterShouldNotExecuteTest()
{
bool shouldExecute = false;
var behavior = new MockEventToCommandBehavior
{
EventName = "ItemTapped",
CommandParameter = shouldExecute,
Command = new Command<string>(o => Assert.True(false), o => o.Equals(true))
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, null);
}
[Fact]
public void CommandWithConverterTest()
{
const string item = "ItemProperty";
bool executedCommand = false;
var behavior = new MockEventToCommandBehavior
{
EventName = "ItemTapped",
EventArgsConverter = new ItemTappedEventArgsConverter(false),
Command = new Command<string>(o =>
{
executedCommand = true;
Assert.NotNull(o);
Assert.Equal(item, o);
})
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item));
Assert.True(executedCommand);
}
private class ItemTappedEventArgsConverter : IValueConverter
{
private readonly bool _returnParameter;
public bool HasConverted { get; private set; }
public ItemTappedEventArgsConverter(bool returnParameter)
{
_returnParameter = returnParameter;
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
HasConverted = true;
return _returnParameter ? parameter : (value as ItemTappedEventArgs)?.Item;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
}

+ 0
- 27
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/DummyTests.cs View File

@ -1,27 +0,0 @@
using System;
using System.Threading.Tasks;
using Xunit;
namespace eShopOnContainers.UnitTests
{
public class DummyTests
{
[Fact]
public void ThisShouldPass_Sync()
{
Assert.True(true);
}
[Fact]
public async Task ThisShouldPass_Async()
{
await Task.Run(() => { Assert.True(true); });
}
[Fact]
public async Task ThisShouldFail_Async()
{
await Task.Run(() => { throw new Exception("Oops!"); });
}
}
}

+ 12
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockEventToCommandBehavior.cs View File

@ -0,0 +1,12 @@
using eShopOnContainers.Core.Behaviors;
namespace eShopOnContainers.UnitTests
{
public class MockEventToCommandBehavior : EventToCommandBehavior
{
public void RaiseEvent(params object[] args)
{
_handler.DynamicInvoke(args);
}
}
}

+ 53
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockViewModel.cs View File

@ -0,0 +1,53 @@
using eShopOnContainers.Core.ViewModels.Base;
using eShopOnContainers.Core.Validations;
namespace eShopOnContainers.UnitTests
{
public class MockViewModel : ViewModelBase
{
private ValidatableObject<string> _forename;
private ValidatableObject<string> _surname;
public ValidatableObject<string> Forename
{
get
{
return _forename;
}
set
{
_forename = value;
RaisePropertyChanged(() => Forename);
}
}
public ValidatableObject<string> Surname
{
get
{
return _surname;
}
set
{
_surname = value;
RaisePropertyChanged(() => Surname);
}
}
public MockViewModel()
{
_forename = new ValidatableObject<string>();
_surname = new ValidatableObject<string>();
_forename.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "Forename is required." });
_surname.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "Surname name is required." });
}
public bool Validate()
{
bool isValidForename = _forename.Validate();
bool isValidSurname = _surname.Validate();
return isValidForename && isValidSurname;
}
}
}

src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/BasketServiceTests.cs → src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Services/BasketServiceTests.cs View File


src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/CatalogServiceTests.cs → src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Services/CatalogServiceTests.cs View File


src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/OrdersServiceTests.cs → src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Services/OrdersServiceTests.cs View File

@ -1,6 +1,5 @@
using eShopOnContainers.Core;
using eShopOnContainers.Core.Services.Order;
using eShopOnContainers.Core.Services.RequestProvider;
using System.Threading.Tasks;
using Xunit;
@ -8,6 +7,15 @@ namespace eShopOnContainers.UnitTests
{
public class OrdersServiceTests
{
[Fact]
public async Task GetFakeOrderTest()
{
var ordersMockService = new OrderMockService();
var order = await ordersMockService.GetOrderAsync(1, GlobalSetting.Instance.AuthToken);
Assert.NotNull(order);
}
[Fact]
public async Task GetFakeOrdersTest()
{
@ -16,15 +24,5 @@ namespace eShopOnContainers.UnitTests
Assert.NotEqual(0, result.Count);
}
[Fact]
public async Task GetOrdersTest()
{
var requestProvider = new RequestProvider();
var ordersService = new OrderService(requestProvider);
var result = await ordersService.GetOrdersAsync(GlobalSetting.Instance.AuthToken);
Assert.NotEqual(0, result.Count);
}
}
}

+ 223
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/ViewModels/CatalogViewModelTests.cs View File

@ -0,0 +1,223 @@
using Xunit;
using eShopOnContainers.Core.ViewModels;
using eShopOnContainers.Core.ViewModels.Base;
using eShopOnContainers.Core.Services.Catalog;
using eShopOnContainers.Core.Models.Catalog;
using System.Threading.Tasks;
using System.Linq;
namespace eShopOnContainers.UnitTests
{
public class CatalogViewModelTests
{
public CatalogViewModelTests()
{
ViewModelLocator.RegisterDependencies(true);
}
[Fact]
public void AddCatalogItemCommandIsNotNullTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.NotNull(catalogViewModel.AddCatalogItemCommand);
}
[Fact]
public void FilterCommandIsNotNullTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.NotNull(catalogViewModel.FilterCommand);
}
[Fact]
public void ClearFilterCommandIsNotNullTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.NotNull(catalogViewModel.ClearFilterCommand);
}
[Fact]
public void ProductsPropertyIsNullWhenViewModelInstantiatedTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.Null(catalogViewModel.Products);
}
[Fact]
public void BrandsPropertyuIsNullWhenViewModelInstantiatedTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.Null(catalogViewModel.Brands);
}
[Fact]
public void BrandPropertyIsNullWhenViewModelInstantiatedTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.Null(catalogViewModel.Brand);
}
[Fact]
public void TypesPropertyIsNullWhenViewModelInstantiatedTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.Null(catalogViewModel.Types);
}
[Fact]
public void TypePropertyIsNullWhenViewModelInstantiatedTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.Null(catalogViewModel.Type);
}
[Fact]
public void IsFilterPropertyIsFalseWhenViewModelInstantiatedTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Assert.False(catalogViewModel.IsFilter);
}
[Fact]
public async Task ProductsPropertyIsNotNullAfterViewModelInitializationTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
await catalogViewModel.InitializeAsync(null);
Assert.NotNull(catalogViewModel.Products);
}
[Fact]
public async Task BrandsPropertyIsNotNullAfterViewModelInitializationTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
await catalogViewModel.InitializeAsync(null);
Assert.NotNull(catalogViewModel.Brands);
}
[Fact]
public async Task TypesPropertyIsNotNullAfterViewModelInitializationTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
await catalogViewModel.InitializeAsync(null);
Assert.NotNull(catalogViewModel.Types);
}
[Fact]
public async Task SettingProductsPropertyShouldRaisePropertyChanged()
{
bool invoked = false;
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
catalogViewModel.PropertyChanged += (sender, e) =>
{
if (e.PropertyName.Equals("Products"))
invoked = true;
};
await catalogViewModel.InitializeAsync(null);
Assert.True(invoked);
}
[Fact]
public async Task SettingBrandsPropertyShouldRaisePropertyChanged()
{
bool invoked = false;
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
catalogViewModel.PropertyChanged += (sender, e) =>
{
if (e.PropertyName.Equals("Brands"))
invoked = true;
};
await catalogViewModel.InitializeAsync(null);
Assert.True(invoked);
}
[Fact]
public async Task SettingTypesPropertyShouldRaisePropertyChanged()
{
bool invoked = false;
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
catalogViewModel.PropertyChanged += (sender, e) =>
{
if (e.PropertyName.Equals("Types"))
invoked = true;
};
await catalogViewModel.InitializeAsync(null);
Assert.True(invoked);
}
[Fact]
public void AddCatalogItemCommandSendsAddProductMessageTest()
{
bool messageReceived = false;
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
Xamarin.Forms.MessagingCenter.Subscribe<CatalogViewModel, CatalogItem>(this, MessageKeys.AddProduct, (sender, arg) =>
{
messageReceived = true;
});
catalogViewModel.AddCatalogItemCommand.Execute(null);
Assert.True(messageReceived);
}
[Fact]
public async Task FilterCommandSendsFilterMessageTest()
{
bool messageReceived = false;
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
await catalogViewModel.InitializeAsync(null);
catalogViewModel.Brand = catalogViewModel.Brands.FirstOrDefault();
catalogViewModel.Type = catalogViewModel.Types.FirstOrDefault();
Xamarin.Forms.MessagingCenter.Subscribe<CatalogViewModel>(this, MessageKeys.Filter, (sender) =>
{
messageReceived = true;
});
catalogViewModel.FilterCommand.Execute(null);
Assert.True(messageReceived);
}
[Fact]
public async Task ClearFilterCommandResetsPropertiesTest()
{
var catalogService = new CatalogMockService();
var catalogViewModel = new CatalogViewModel(catalogService);
await catalogViewModel.InitializeAsync(null);
catalogViewModel.ClearFilterCommand.Execute(null);
Assert.Null(catalogViewModel.Brand);
Assert.Null(catalogViewModel.Type);
Assert.NotNull(catalogViewModel.Products);
}
}
}

+ 54
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/ViewModels/MainViewModelTests.cs View File

@ -0,0 +1,54 @@
using Xunit;
using eShopOnContainers.Core.ViewModels;
using eShopOnContainers.Core.ViewModels.Base;
using eShopOnContainers.Core.Models.Navigation;
using System.Threading.Tasks;
namespace eShopOnContainers.UnitTests
{
public class MainViewModelTests
{
public MainViewModelTests()
{
ViewModelLocator.RegisterDependencies(true);
}
[Fact]
public void SettingsCommandIsNotNullWhenViewModelInstantiatedTest()
{
var mainViewModel = new MainViewModel();
Assert.NotNull(mainViewModel.SettingsCommand);
}
[Fact]
public async Task ViewModelInitializationSendsChangeTabMessageTest()
{
bool messageReceived = false;
var mainViewModel = new MainViewModel();
var tabParam = new TabParameter { TabIndex = 2 };
Xamarin.Forms.MessagingCenter.Subscribe<MainViewModel, int>(this, MessageKeys.ChangeTab, (sender, arg) =>
{
messageReceived = true;
});
await mainViewModel.InitializeAsync(tabParam);
Assert.True(messageReceived);
}
[Fact]
public void IsBusyPropertyIsFalseWhenViewModelInstantiatedTest()
{
var mainViewModel = new MainViewModel();
Assert.False(mainViewModel.IsBusy);
}
[Fact]
public async Task IsBusyPropertyIsTrueAfterViewModelInitializationTest()
{
var mainViewModel = new MainViewModel();
await mainViewModel.InitializeAsync(null);
Assert.True(mainViewModel.IsBusy);
}
}
}

+ 113
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/ViewModels/MockViewModelTests.cs View File

@ -0,0 +1,113 @@
using Xunit;
using eShopOnContainers.Core.ViewModels.Base;
namespace eShopOnContainers.UnitTests
{
public class MockViewModelTests
{
public MockViewModelTests()
{
ViewModelLocator.RegisterDependencies(true);
}
[Fact]
public void CheckValidationFailsWhenPropertiesAreEmptyTest()
{
var mockViewModel = new MockViewModel();
bool isValid = mockViewModel.Validate();
Assert.False(isValid);
Assert.Null(mockViewModel.Forename.Value);
Assert.Null(mockViewModel.Surname.Value);
Assert.False(mockViewModel.Forename.IsValid);
Assert.False(mockViewModel.Surname.IsValid);
Assert.NotEmpty(mockViewModel.Forename.Errors);
Assert.NotEmpty(mockViewModel.Surname.Errors);
}
[Fact]
public void CheckValidationFailsWhenOnlyForenameHasDataTest()
{
var mockViewModel = new MockViewModel();
mockViewModel.Forename.Value = "John";
bool isValid = mockViewModel.Validate();
Assert.False(isValid);
Assert.NotNull(mockViewModel.Forename.Value);
Assert.Null(mockViewModel.Surname.Value);
Assert.True(mockViewModel.Forename.IsValid);
Assert.False(mockViewModel.Surname.IsValid);
Assert.Empty(mockViewModel.Forename.Errors);
Assert.NotEmpty(mockViewModel.Surname.Errors);
}
[Fact]
public void CheckValidationPassesWhenOnlySurnameHasDataTest()
{
var mockViewModel = new MockViewModel();
mockViewModel.Surname.Value = "Smith";
bool isValid = mockViewModel.Validate();
Assert.False(isValid);
Assert.Null(mockViewModel.Forename.Value);
Assert.NotNull(mockViewModel.Surname.Value);
Assert.False(mockViewModel.Forename.IsValid);
Assert.True(mockViewModel.Surname.IsValid);
Assert.NotEmpty(mockViewModel.Forename.Errors);
Assert.Empty(mockViewModel.Surname.Errors);
}
[Fact]
public void CheckValidationPassesWhenBothPropertiesHaveDataTest()
{
var mockViewModel = new MockViewModel();
mockViewModel.Forename.Value = "John";
mockViewModel.Surname.Value = "Smith";
bool isValid = mockViewModel.Validate();
Assert.True(isValid);
Assert.NotNull(mockViewModel.Forename.Value);
Assert.NotNull(mockViewModel.Surname.Value);
Assert.True(mockViewModel.Forename.IsValid);
Assert.True(mockViewModel.Surname.IsValid);
Assert.Empty(mockViewModel.Forename.Errors);
Assert.Empty(mockViewModel.Surname.Errors);
}
[Fact]
public void SettingForenamePropertyShouldRaisePropertyChanged()
{
bool invoked = false;
var mockViewModel = new MockViewModel();
mockViewModel.Forename.PropertyChanged += (sender, e) =>
{
if (e.PropertyName.Equals("Value"))
invoked = true;
};
mockViewModel.Forename.Value = "John";
Assert.True(invoked);
}
[Fact]
public void SettingSurnamePropertyShouldRaisePropertyChanged()
{
bool invoked = false;
var mockViewModel = new MockViewModel();
mockViewModel.Surname.PropertyChanged += (sender, e) =>
{
if (e.PropertyName.Equals("Value"))
invoked = true;
};
mockViewModel.Surname.Value = "Smith";
Assert.True(invoked);
}
}
}

+ 55
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/ViewModels/OrderViewModelTests.cs View File

@ -0,0 +1,55 @@
using Xunit;
using eShopOnContainers.Core;
using eShopOnContainers.Core.ViewModels;
using eShopOnContainers.Core.ViewModels.Base;
using eShopOnContainers.Core.Services.Order;
using System.Threading.Tasks;
namespace eShopOnContainers.UnitTests
{
public class OrderViewModelTests
{
public OrderViewModelTests()
{
ViewModelLocator.RegisterDependencies(true);
}
[Fact]
public void OrderPropertyIsNullWhenViewModelInstantiatedTest()
{
var orderService = new OrderMockService();
var orderViewModel = new OrderDetailViewModel(orderService);
Assert.Null(orderViewModel.Order);
}
[Fact]
public async Task OrderPropertyIsNotNullAfterViewModelInitializationTest()
{
var orderService = new OrderMockService();
var orderViewModel = new OrderDetailViewModel(orderService);
var order = await orderService.GetOrderAsync(1, GlobalSetting.Instance.AuthToken);
await orderViewModel.InitializeAsync(order);
Assert.NotNull(orderViewModel.Order);
}
[Fact]
public async Task SettingOrderPropertyShouldRaisePropertyChanged()
{
bool invoked = false;
var orderService = new OrderMockService();
var orderViewModel = new OrderDetailViewModel(orderService);
orderViewModel.PropertyChanged += (sender, e) =>
{
if (e.PropertyName.Equals("Order"))
invoked = true;
};
var order = await orderService.GetOrderAsync(1, GlobalSetting.Instance.AuthToken);
await orderViewModel.InitializeAsync(order);
Assert.True(invoked);
}
}
}

+ 26
- 4
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/eShopOnContainers.UnitTests.csproj View File

@ -34,11 +34,17 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="BasketServiceTests.cs" />
<Compile Include="CatalogServiceTests.cs" />
<Compile Include="DummyTests.cs" />
<Compile Include="OrdersServiceTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Mocks\MockEventToCommandBehavior.cs" />
<Compile Include="Services\BasketServiceTests.cs" />
<Compile Include="Services\CatalogServiceTests.cs" />
<Compile Include="ViewModels\CatalogViewModelTests.cs" />
<Compile Include="ViewModels\MainViewModelTests.cs" />
<Compile Include="ViewModels\OrderViewModelTests.cs" />
<Compile Include="Services\OrdersServiceTests.cs" />
<Compile Include="Behaviors\EventToCommandBehaviorTests.cs" />
<Compile Include="Mocks\MockViewModel.cs" />
<Compile Include="ViewModels\MockViewModelTests.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
@ -57,6 +63,15 @@
<HintPath>..\..\..\..\packages\xunit.extensibility.execution.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.execution.dotnet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Core">
<HintPath>..\..\..\..\packages\Xamarin.Forms.2.3.4.231\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Platform">
<HintPath>..\..\..\..\packages\Xamarin.Forms.2.3.4.231\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Xaml">
<HintPath>..\..\..\..\packages\Xamarin.Forms.2.3.4.231\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@ -68,6 +83,12 @@
<Name>eShopOnContainers.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Mocks\" />
<Folder Include="Services\" />
<Folder Include="ViewModels\" />
<Folder Include="Behaviors\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@ -76,4 +97,5 @@
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\..\..\..\packages\Xamarin.Forms.2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\..\..\..\packages\Xamarin.Forms.2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" />
</Project>

+ 8
- 7
src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/packages.config View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.2.0-beta4-build3444" targetFramework="portable46-net451+win81" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="portable46-net451+win81" />
<package id="xunit.assert" version="2.2.0-beta4-build3444" targetFramework="portable46-net451+win81" />
<package id="xunit.core" version="2.2.0-beta4-build3444" targetFramework="portable46-net451+win81" />
<package id="xunit.extensibility.core" version="2.2.0-beta4-build3444" targetFramework="portable46-net451+win81" />
<package id="xunit.extensibility.execution" version="2.2.0-beta4-build3444" targetFramework="portable46-net451+win81" />
<package id="xunit.runner.console" version="2.2.0-beta4-build3444" targetFramework="portable46-net451+win81" developmentDependency="true" />
<package id="Xamarin.Forms" version="2.3.4.231" targetFramework="portable46-net451+win81" />
<package id="xunit" version="2.2.0-beta4-build3444" targetFramework="portable-net451+win81" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="portable-net451+win81" requireReinstallation="True" />
<package id="xunit.assert" version="2.2.0-beta4-build3444" targetFramework="portable-net451+win81" requireReinstallation="True" />
<package id="xunit.core" version="2.2.0-beta4-build3444" targetFramework="portable-net451+win81" requireReinstallation="True" />
<package id="xunit.extensibility.core" version="2.2.0-beta4-build3444" targetFramework="portable-net451+win81" requireReinstallation="True" />
<package id="xunit.extensibility.execution" version="2.2.0-beta4-build3444" targetFramework="portable-net451+win81" requireReinstallation="True" />
<package id="xunit.runner.console" version="2.2.0-beta4-build3444" targetFramework="portable-net451+win81" developmentDependency="true" />
</packages>

+ 0
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Windows/project.json View File

@ -5,7 +5,6 @@
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
"Newtonsoft.Json": "9.0.1",
"SlideOverKit": "2.1.4",
"Unity": "4.0.1",
"Xam.Plugins.Settings": "2.6.0.12-beta",
"Xamarin.FFImageLoading": "2.2.6-pre-256",
"Xamarin.FFImageLoading.Forms": "2.2.6-pre-256",


+ 0
- 4
src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj View File

@ -166,10 +166,6 @@
<HintPath>..\..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Unity.4.0.1\lib\portable-net45+wp80+win8+wpa81+MonoAndroid10+MonoTouch10\Microsoft.Practices.Unity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ModernHttpClient, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\modernhttpclient.2.4.2\lib\Xamarin.iOS10\ModernHttpClient.dll</HintPath>
<Private>True</Private>


+ 0
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.iOS/packages.config View File

@ -11,7 +11,6 @@
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="xamarinios10" />
<package id="SlideOverKit" version="2.1.4" targetFramework="xamarinios10" />
<package id="Splat" version="1.6.2" targetFramework="xamarinios10" />
<package id="Unity" version="4.0.1" targetFramework="xamarinios10" />
<package id="WebP.Touch" version="1.0.2" targetFramework="xamarinios10" />
<package id="Xam.Plugins.Settings" version="2.6.0.12-beta" targetFramework="xamarinios10" />
<package id="Xamarin.FFImageLoading" version="2.2.6-pre-256" targetFramework="xamarinios10" />


+ 0
- 1
src/Services/Basket/Basket.API/Basket.API.csproj View File

@ -43,7 +43,6 @@
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.Data\Microsoft.Extensions.HealthChecks.Data.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
</ItemGroup>


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save