[
  {
    "path": ".gitignore",
    "content": "[Bb]ackup*/\n[Oo]bj/\n[Bb]in/\npkg/\nobjd/\nTestResults/\n.nuget/\n*.sln.ide/\n_ReSharper.*/\npackages/\n.vs/\n*.user\n*.suo\n*.cache\n*.docstates\n_ReSharper.*\nnuget.exe\n.settings\n*.sln.ide\n\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to Azure samples\r\n\r\nThank you for your interest in contributing to Azure samples!\r\n\r\n## Ways to contribute\r\n\r\nYou can contribute to [Azure samples](https://azure.microsoft.com/documentation/samples/) in a few different ways:\r\n\r\n- Submit feedback on [this sample page](https://azure.microsoft.com/documentation/samples/service-fabric-dotnet-web-reference-app/) whether it was helpful or not.  \r\n- Submit issues through [issue tracker](https://github.com/Azure-Samples/service-fabric-dotnet-web-reference-app/issues) on GitHub. We are actively monitoring the issues and improving our samples.\r\n- If you wish to make code changes to samples, or contribute something new, please follow the [GitHub Forks / Pull requests model](https://help.github.com/articles/fork-a-repo/): Fork the sample repo, make the change and propose it back by submitting a pull request."
  },
  {
    "path": "Docs/architecture.md",
    "content": "# Application architecture\n\nThe application is composed of individual services to perform the major functions of the application:\n\n- Web Service\n\t- A stateless front-end service that hosts the web UI and HTTP API for interacting with the store.\n- Customer Order Actor\n\t- An actor-based service that handles customer orders. A stateful actor is activated for each new order that's placed. The actor represents the lifetime of the customer order, from placement to fulfillment.\n- Inventory Service\n\t- A stateful service that maintains the store's inventory. This service is partitioned, where each partition of the service holds a subset of the store's entire inventory. With a large number of partitions, this service can scale out to meet data capacity and inventory request throughput.\n- RestockRequest Actor\n\t- A stateful actor that manages the lifetime of a restock request from the inventory service. Each time the inventory runs low on stock for an item, makes a request to refill the inventory. The restock request actor itself would send a request to a supplier for more items, however this is simply simulated within the actor.\n- RestockRequest Manager\n\t- This is a stateful service that manages requests from the inventory service for item restocking. It logs restock requests made by the Inventory Service and activates a RestockRequest Actor to fulfill the requst. It then receives notifications from the actors when a restock request has been fulfilled. These notifications are placed in a ReliableQueue as they come in. The notifications are periodically dequeued and sent back to the Inventory Service.\n\n# Data flow\n\nWhen a user makes a purchase, data flows the through the system as follows:\n\n![Data flow](./media/dataflow.png)\n\n\n\n\n1. Client sends HTTP POST to /api/orders with order in JSON payload: \n\n\t[{\"ItemId\":\"1d6abc91-ebe7-41ff-b868-4086501903fc\",\"Quantity\":1},{\"ItemId\":\"a833f7d0-2f76-4c9f-9353-8c728252da4a\",\"Quantity\":2}]\n\t\n\tResponse from service is a tracking ID: \n\t68bf3f53-dc74-4ef9-8f60-89d68508247b\n \n2. Web Service creates a new Actor (by specifying a new ActorId) to track the order by calling SubmitOrderAsync() on the Customer Order Actor service.\n\n3. Customer Order Actor saves the order in its state, registers a reminder for itself to complete the order, and returns to the caller. Order processing has a number of steps and may need to retry in case of failure, thus the reminder serves as a queued work item within the Actor in order to prioritize saving the order reliably and returning to the caller as quickly as possible.\n\n4. Customer Order Actor processes the order by requesting stock for the order to be removed from the Inventory Service. If there is not enough stock available to fulfill the order, the actor adds the back ordered items to its list of backordered state and registers another reminder on itself to try fulfilling the order again later. If this process completes successfully (either by completing the order or by tracking backorder items), the reminder for this method is removed, which has the effect of removing the queue work item. If at any point the method throws or the service crashes, the reminder will remain and will be executed again automatically to retry fulfilling the order. NOTE: the retry mechanism is not fully implemented yet.\n\n5. Inventory Service checks to see if available stock is below the restock threshold after removing stock as requested by a CustomerOrder Actor. If the stock for a certain item is below the restock threshold and it's not already being reordered, it calls AddRestockRequestAsync on the Restock Request Manager.\n\n6. When the Restock Request Manager receives a restock request, it creates a new Actor to track the request and adds the Actor to its own Reliable Dictionary so that it may query the restock request Actors later. Upon adding the Actor, it subscribes to event notifications from the Actor. This will be used later to notify the Restock Request Manager when the restock request is complete.\n\n7. The Restock Request Actor registers a reminder on itself to go through the restock processing pipeline. This pipeline is normally where restocking logic would live, but currently it is simply faked by progressing through each step of restocking every time the reminder fires. When it reaches the last step in the pipeline, it signals the completed event (for which the Restock Request Manager is listening), and unregisters the reminder when that completes.\n\n8. When the Restock Request Actor completes the restock request, it signals the complete event which sends the completed RestockRequest back to the Restock Request Manager. The Manager queues the completed Restock Request in a Reliable Queue for later processing and unsubscribes from receiving events from the Actor, which is now complete and will eventually be garbage-collected.\n\n9. Restock Request Manager's RunAsync method periodically drains the queue of Restock Requests and sends those Restock Requests to the Inventory Service for restocking.\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
  },
  {
    "path": "README.md",
    "content": "---\nlanguages:\n- csharp\nproducts:\n- azure\n- azure-service-fabric\npage_type: sample\ndescription: \"The web reference application shows how to build an end-to-end Service Fabric application with multiple types of services.\"\n---\n\n# Service Fabric Web Reference Application\n\nThe web reference application shows how to build an end-to-end Service Fabric application with multiple types of services, combining Reliable Services and Reliable Actors to construct a complete solution.\n\n## Scenario\n\nThe context of this sample is a web-based store with a customer order and inventory management back-end. Logical parts of the management back-end are represented by individual services, allowing loose coupling of functionality and independently-upgradeable components:\n\n- Customer Order Service\n- Inventory Service\n- Restocking Service\n- Web front-end Service\n\n\nThe customer order and inventory management system tracks user orders, removes items from the inventory to fulfill orders, and requests restocking of inventory items when an item's stock goes below a certain threshold. If a user requests items that are out of stock, the order is placed on back-order until the inventory is replenished, at which point the order is completed.\n\nUsing Service Fabric's stateful services, each of these services can maintain its own data, rather than relying a shared monolithic data base. This allows each service to scale independently using Service Fabric's stateful partitioning to meet its unique requirements for data capacity and throughput.\n\n## Running this sample\nThe majority of this application is self-contained. The only external dependency is to Azure storage for [backup & restore](https://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-services-backup-restore/) purposes. There are no other dependencies on external services or databases to manage related to request processing or data persistence. This makes running the complete application pretty easy:\n\n1. Open the .sln solution file in Visual Studio 2015.\n2. Edit the Inventory.Service\\PackageRoot\\Config\\Settings.xml file to contain the connection details for your Azure storage account.\n2. Press F5 to run.\n\nThis deploys the entire web store application on your local machine.\n\nThere are two web endpoints to begin interacting with the application:\n\n1. **http://localhost:8505/fabrikam/admin.html** - a very basic admin portal where you can add items into the inventory. When you first launch the application, the inventory is empty.\n2. **http://localhost:8505/fabrikam/** - a basic store front-end. This shows the current inventory and your shopping cart where you can add and purchase items to see the flow of data through the system.\n\n## Deploy this sample to Azure\nThe application can be deployed to Azure by right-clicking the application project in Visual Studio and selecting \"Publish\".\n\n![Publish dialog](./Docs/media/publish.png)\n\nIn the publish dialog box, select the Cloud profile and a connection endpoint. Selecting a connection endpoint from this dialog requires an Azure subscription. If you want to publish to a known cluster without an Azure subscription, you can simply edit the Cloud publish profile XML under PublishProfiles in the application project and specify a cluster connection endpoint there:\n\n``` XML\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<PublishProfile xmlns=\"http://schemas.microsoft.com/2015/05/fabrictools\">\n  <!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.\n       Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.\n\n       For a remote cluster, you would need to specify the appropriate parameters for that specific cluster.\n         For example: <ClusterConnectionParameters ConnectionEndpoint=\"mycluster.westus.cloudapp.azure.com:19000\" /> -->\n\n  <ClusterConnectionParameters ConnectionEndpoint=\"mycluster.westus.cloudapp.azure.com:19000\" />\n  <ApplicationParameterFile Path=\"..\\ApplicationParameters\\Cloud.xml\" />\n</PublishProfile>\n\n```\n\n## Unit Tests\nThis application also contains unit tests to show the recommended pattern  to create tests against a Service Fabric application.\n  Below are the steps  to run or debug a test (using  Visual studio 2015 on a 64 bit windows):\n  - Open the WebReferenceApp solution  in Visual studio 2015\n  - Select menus \"Test\" / \"Test Setting\" / \"Default processor architecture\" -> x64\n  - Rebuild the solution\n  - Select menus \"Test\" / \"Windows\" / \"Test Explorer\" you should see now the text explorer window with the list of available tests\n  - Choose one or more tests (for example \"TestAddStock\" under InventoryServiceTests)\n  - Right click the test of your choice and select run the test, you will see after a while a green check mark of test passed\n  - You can try also to debug the test  to  understand better  its logic\n\n\n## Next steps\n\n- [Learn about the application architecture and data flow.](https://github.com/Azure-Samples/service-fabric-dotnet-web-reference-app/blob/master/Docs/architecture.md \"Learn about the application architecture and data flow.\")\n\n\n## MSFT OSS Code Of Conduct Notice\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n"
  },
  {
    "path": "ReferenceApp/Common/ActorMessageId.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Common\r\n{\r\n    using System;\r\n    using System.Runtime.Serialization;\r\n    using Microsoft.ServiceFabric.Actors;\r\n\r\n    [DataContract]\r\n    public class CustomerOrderActorMessageId : IFormattable, IComparable, IComparable<CustomerOrderActorMessageId>, IEquatable<CustomerOrderActorMessageId>\r\n    {\r\n        public CustomerOrderActorMessageId(ActorId sendingActorId, long messageId)\r\n        {\r\n            this.sendingActorId = sendingActorId;\r\n            this.messageId = messageId;\r\n        }\r\n\r\n        [DataMember]\r\n        public ActorId sendingActorId { get; private set; }\r\n\r\n        [DataMember]\r\n        public long messageId { get; private set; }\r\n\r\n        int IComparable.CompareTo(object obj)\r\n        {\r\n            return this.CompareTo((CustomerOrderActorMessageId) obj);\r\n        }\r\n\r\n        public int CompareTo(CustomerOrderActorMessageId other)\r\n        {\r\n            if (this.sendingActorId.ToString().CompareTo(other.sendingActorId.ToString()) > 1)\r\n            {\r\n                return 1;\r\n            }\r\n            else if (this.sendingActorId.ToString().CompareTo(other.sendingActorId.ToString()) < 1)\r\n            {\r\n                return -1;\r\n            }\r\n            else if (this.messageId > other.messageId)\r\n            {\r\n                return 1;\r\n            }\r\n            else if (this.messageId < other.messageId)\r\n            {\r\n                return -1;\r\n            }\r\n\r\n            return 0;\r\n        }\r\n\r\n        public bool Equals(CustomerOrderActorMessageId other)\r\n        {\r\n            return (this.sendingActorId.Equals(other.sendingActorId) && this.messageId == other.messageId);\r\n        }\r\n\r\n        public string ToString(string format, IFormatProvider formatProvider)\r\n        {\r\n            return string.Format(\"{0}|{1}\", this.sendingActorId.ToString(), this.messageId);\r\n        }\r\n\r\n        public static CustomerOrderActorMessageId GetRandom()\r\n        {\r\n            ActorId id = new ActorId(Guid.NewGuid());\r\n            Random r = new Random();\r\n            return new CustomerOrderActorMessageId(id, r.Next());\r\n        }\r\n\r\n        public static bool operator ==(CustomerOrderActorMessageId item1, CustomerOrderActorMessageId item2)\r\n        {\r\n            return item1.Equals(item2);\r\n        }\r\n\r\n        public static bool operator !=(CustomerOrderActorMessageId item1, CustomerOrderActorMessageId item2)\r\n        {\r\n            return !item1.Equals(item2);\r\n        }\r\n\r\n        public static bool operator >(CustomerOrderActorMessageId item1, CustomerOrderActorMessageId item2)\r\n        {\r\n            int result = item1.CompareTo(item2);\r\n            return (result == 0 | result == -1);\r\n        }\r\n\r\n        public static bool operator <(CustomerOrderActorMessageId item1, CustomerOrderActorMessageId item2)\r\n        {\r\n            int result = item1.CompareTo(item2);\r\n            return (result == 0 | result == 1);\r\n        }\r\n\r\n        public override bool Equals(object obj)\r\n        {\r\n            return (this.CompareTo(obj as CustomerOrderActorMessageId) == 0);\r\n        }\r\n\r\n        public override int GetHashCode()\r\n        {\r\n            return this.ToString().GetHashCode();\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Common/Common.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{9EC0063F-489E-43FE-94B5-BF5F89977CD3}</ProjectGuid>\r\n    <OutputType>Library</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>Common</RootNamespace>\r\n    <AssemblyName>Common</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <DebugType>full</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\r\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <Optimize>true</Optimize>\r\n    <DebugType>pdbonly</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n    <Reference Include=\"System.Xml.Linq\" />\r\n    <Reference Include=\"System.Data.DataSetExtensions\" />\r\n    <Reference Include=\"Microsoft.CSharp\" />\r\n    <Reference Include=\"System.Data\" />\r\n    <Reference Include=\"System.Net.Http\" />\r\n    <Reference Include=\"System.Xml\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"ActorMessageId.cs\" />\r\n    <Compile Include=\"HashUtil.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n    <Compile Include=\"ServiceUriBuilder.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r\n       Other similar extension points exist, see Microsoft.Common.targets.\r\n  <Target Name=\"BeforeBuild\">\r\n  </Target>\r\n  <Target Name=\"AfterBuild\">\r\n  </Target>\r\n  -->\r\n</Project>"
  },
  {
    "path": "ReferenceApp/Common/HashUtil.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Common\r\n{\r\n    using System;\r\n    using System.Security.Cryptography;\r\n    using System.Text;\r\n\r\n    public class HashUtil\r\n    {\r\n        public static long getLongHashCode(string stringInput)\r\n        {\r\n            byte[] byteContents = Encoding.Unicode.GetBytes(stringInput);\r\n            MD5CryptoServiceProvider hash = new MD5CryptoServiceProvider();\r\n            byte[] hashText = hash.ComputeHash(byteContents);\r\n            return BitConverter.ToInt64(hashText, 0) ^ BitConverter.ToInt64(hashText, 7);\r\n        }\r\n\r\n        public static int getIntHashCode(string stringInput)\r\n        {\r\n            return (int) getLongHashCode(stringInput);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Common/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"Common\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"Common\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"9ec0063f-489e-43fe-94b5-bf5f89977cd3\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/Common/ServiceUriBuilder.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Common\r\n{\r\n    using System;\r\n    using System.Fabric;\r\n\r\n    public class ServiceUriBuilder\r\n    {\r\n        public ServiceUriBuilder(string serviceInstance)\r\n        {\r\n            this.ActivationContext = FabricRuntime.GetActivationContext();\r\n            this.ServiceInstance = serviceInstance;\r\n        }\r\n\r\n        public ServiceUriBuilder(ICodePackageActivationContext context, string serviceInstance)\r\n        {\r\n            this.ActivationContext = context;\r\n            this.ServiceInstance = serviceInstance;\r\n        }\r\n\r\n        public ServiceUriBuilder(ICodePackageActivationContext context, string applicationInstance, string serviceInstance)\r\n        {\r\n            this.ActivationContext = context;\r\n            this.ApplicationInstance = applicationInstance;\r\n            this.ServiceInstance = serviceInstance;\r\n        }\r\n\r\n        /// <summary>\r\n        /// The name of the application instance that contains he service.\r\n        /// </summary>\r\n        public string ApplicationInstance { get; set; }\r\n\r\n        /// <summary>\r\n        /// The name of the service instance.\r\n        /// </summary>\r\n        public string ServiceInstance { get; set; }\r\n\r\n        /// <summary>\r\n        /// The local activation context\r\n        /// </summary>\r\n        public ICodePackageActivationContext ActivationContext { get; set; }\r\n\r\n        public Uri ToUri()\r\n        {\r\n            string applicationInstance = this.ApplicationInstance;\r\n\r\n            if (String.IsNullOrEmpty(applicationInstance))\r\n            {\r\n                // the ApplicationName property here automatically prepends \"fabric:/\" for us\r\n                applicationInstance = this.ActivationContext.ApplicationName.Replace(\"fabric:/\", String.Empty);\r\n            }\r\n\r\n            return new Uri(\"fabric:/\" + applicationInstance + \"/\" + this.ServiceInstance);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Common/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/ActorEventSource.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace CustomerOrder.Actor\r\n{\r\n    using System;\r\n    using System.Diagnostics.Tracing;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Actors.Runtime;\r\n\r\n    [EventSource(Name = \"MyCompany-Web_UIApplication-CustomerOrder\")]\r\n    internal sealed class ActorEventSource : EventSource\r\n    {\r\n        private const int MessageEventId = 1;\r\n\r\n        // For very high-frequency events it might be advantageous to raise events using WriteEventCore API.\r\n        // This results in more efficient parameter handling, but requires explicit allocation of EventData structure and unsafe code.\r\n        // To enable this code path, define UNSAFE conditional compilation symbol and turn on unsafe code support in project properties.\r\n        private const int ActorMessageEventId = 2;\r\n\r\n        private const int ActorHostInitializationFailedEventId = 3;\r\n        public static readonly ActorEventSource Current = new ActorEventSource();\r\n\r\n        static ActorEventSource()\r\n        {\r\n            // A workaround for the problem where ETW activities do not get tracked until Tasks infrastructure is initialized.\r\n            // This problem will be fixed in .NET Framework 4.6.2.\r\n            Task.Run(() => { }).Wait();\r\n        }\r\n\r\n        // Instance constructor is private to enforce singleton semantics\r\n        private ActorEventSource() : base()\r\n        {\r\n        }\r\n\r\n        // Define an instance method for each event you want to record and apply an [Event] attribute to it.\r\n        // The method name is the name of the event.\r\n        // Pass any parameters you want to record with the event (only primitive integer types, DateTime, Guid & string are allowed).\r\n        // Each event method implementation should check whether the event source is enabled, and if it is, call WriteEvent() method to raise the event.\r\n        // The number and types of arguments passed to every event method must exactly match what is passed to WriteEvent().\r\n        // Put [NonEvent] attribute on all methods that do not define an event.\r\n        // For more information see https://msdn.microsoft.com/en-us/library/system.diagnostics.tracing.eventsource.aspx\r\n\r\n        [NonEvent]\r\n        public void Message(string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                this.Message(finalMessage);\r\n            }\r\n        }\r\n\r\n        [Event(MessageEventId, Level = EventLevel.Informational, Message = \"{0}\")]\r\n        public void Message(string message)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                this.WriteEvent(MessageEventId, message);\r\n            }\r\n        }\r\n\r\n        [NonEvent]\r\n        public void ActorMessage(Actor actor, string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled()\r\n                && actor.Id != null\r\n                && actor.ActorService != null\r\n                && actor.ActorService.Context != null\r\n                && actor.ActorService.Context.CodePackageActivationContext != null)\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                this.ActorMessage(\r\n                    actor.GetType().ToString(),\r\n                    actor.Id.ToString(),\r\n                    actor.ActorService.Context.CodePackageActivationContext.ApplicationTypeName,\r\n                    actor.ActorService.Context.CodePackageActivationContext.ApplicationName,\r\n                    actor.ActorService.Context.ServiceTypeName,\r\n                    actor.ActorService.Context.ServiceName.ToString(),\r\n                    actor.ActorService.Context.PartitionId,\r\n                    actor.ActorService.Context.ReplicaId,\r\n                    actor.ActorService.Context.NodeContext.NodeName,\r\n                    finalMessage);\r\n            }\r\n        }\r\n\r\n        [Event(ActorHostInitializationFailedEventId, Level = EventLevel.Error, Message = \"Actor host initialization failed\",\r\n            Keywords = Keywords.HostInitialization)]\r\n        public void ActorHostInitializationFailed(string exception)\r\n        {\r\n            this.WriteEvent(ActorHostInitializationFailedEventId, exception);\r\n        }\r\n\r\n        [Event(ActorMessageEventId, Level = EventLevel.Informational, Message = \"{9}\")]\r\n        private\r\n        void ActorMessage(\r\n            string actorType,\r\n            string actorId,\r\n            string applicationTypeName,\r\n            string applicationName,\r\n            string serviceTypeName,\r\n            string serviceName,\r\n            Guid partitionId,\r\n            long replicaOrInstanceId,\r\n            string nodeName,\r\n            string message)\r\n        {\r\n            this.WriteEvent(\r\n                ActorMessageEventId,\r\n                actorType,\r\n                actorId,\r\n                applicationTypeName,\r\n                applicationName,\r\n                serviceTypeName,\r\n                serviceName,\r\n                partitionId,\r\n                replicaOrInstanceId,\r\n                nodeName,\r\n                message);\r\n        }\r\n\r\n        // Event keywords can be used to categorize events. \r\n        // Each keyword is a bit flag. A single event can be associated with multiple keywords (via EventAttribute.Keywords property).\r\n        // Keywords must be defined as a public class named 'Keywords' inside EventSource that uses them.\r\n        public static class Keywords\r\n        {\r\n            public const EventKeywords HostInitialization = (EventKeywords) 0x1L;\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/App.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <startup>\r\n    <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.5.2\" />\r\n  </startup>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/CustomerOrder.Actor.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{5F0C7805-C91D-47E9-AEDE-946CADEA1C8F}</ProjectGuid>\r\n    <OutputType>Exe</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>CustomerOrder.Actor</RootNamespace>\r\n    <AssemblyName>CustomerOrder.Actor</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n    <IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <UpdateServiceFabricManifestEnabled>true</UpdateServiceFabricManifestEnabled>\r\n    <ServicePackagePath>PackageRoot</ServicePackagePath>\r\n    <ServicePackagePrefix>$(MSBuildProjectName)</ServicePackagePrefix>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x64' \">\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <DebugType>full</DebugType>\r\n    <Optimize>false</Optimize>\r\n    <OutputPath>bin\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|x64' \">\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <DebugType>pdbonly</DebugType>\r\n    <Optimize>true</Optimize>\r\n    <OutputPath>bin\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"CustomerOrderReminderNames.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n    <Compile Include=\"CustomerOrderActor.cs\" />\r\n    <Compile Include=\"Program.cs\" />\r\n    <Compile Include=\"ActorEventSource.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"PackageRoot\\ServiceManifest.xml\" />\r\n    <None Include=\"PackageRoot\\Config\\Settings.xml\" />\r\n    <None Include=\"App.config\">\r\n      <SubType>Designer</SubType>\r\n    </None>\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\CustomerOrder.Domain\\CustomerOrder.Domain.csproj\">\r\n      <Project>{1E7E813F-43D3-4D0B-8546-5E1023873F28}</Project>\r\n      <Name>CustomerOrder.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\">\r\n      <Project>{7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae}</Project>\r\n      <Name>Inventory.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Mocks\\Mocks.csproj\">\r\n      <Project>{00E00484-BD00-40CD-B2CC-1CFA8E893972}</Project>\r\n      <Name>Mocks</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n</Project>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/CustomerOrderActor.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace CustomerOrder.Actor\r\n{\r\n    using Common;\r\n    using CustomerOrder.Domain;\r\n    using Inventory.Domain;\r\n    using Microsoft.ServiceFabric.Actors;\r\n    using Microsoft.ServiceFabric.Actors.Runtime;\r\n    using Microsoft.ServiceFabric.Data;\r\n    using Microsoft.ServiceFabric.Services.Remoting.Client;\r\n    using Mocks;\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Fabric;\r\n    using System.Linq;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n\r\n    internal class CustomerOrderActor : Actor, ICustomerOrderActor, IRemindable\r\n    {\r\n        private const string InventoryServiceName = \"InventoryService\";\r\n        private const string OrderItemListPropertyName = \"OrderList\";\r\n        private const string OrderStatusPropertyName = \"CustomerOrderStatus\";\r\n        private const string RequestIdPropertyName = \"RequestId\";\r\n        private IServiceProxyFactory ServiceProxyFactory;\r\n        private ServiceUriBuilder builder;\r\n        private CancellationTokenSource tokenSource = null;\r\n\r\n        public CustomerOrderActor(ActorService actorService, ActorId actorId)\r\n            : base (actorService, actorId)\r\n        { }\r\n\r\n        /// <summary>\r\n        /// This method accepts a list of CustomerOrderItems, representing a customer order, and sets the actor's state\r\n        /// to reflect the status and contents of the order. Then, the order is fulfilled with a private FulfillOrder call\r\n        /// that abstracts away the entire backorder process from the user. \r\n        /// </summary>\r\n        /// <param name=\"orderList\"></param>\r\n        /// <returns></returns>\r\n        public async Task SubmitOrderAsync(IEnumerable<CustomerOrderItem> orderList)\r\n        {\r\n            try\r\n            {\r\n                await this.StateManager.SetStateAsync<List<CustomerOrderItem>>(OrderItemListPropertyName, new List<CustomerOrderItem>(orderList));\r\n                await this.StateManager.SetStateAsync<CustomerOrderStatus>(OrderStatusPropertyName, CustomerOrderStatus.Submitted);\r\n\r\n                await this.RegisterReminderAsync(\r\n                    CustomerOrderReminderNames.FulfillOrderReminder,\r\n                    null,\r\n                    TimeSpan.FromSeconds(10),\r\n                    TimeSpan.FromSeconds(10));\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ActorEventSource.Current.Message(e.ToString());\r\n            }\r\n\r\n            ActorEventSource.Current.Message(\"Order submitted with {0} items\", orderList.Count());\r\n\r\n            return;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Returns the status of the Customer Order. \r\n        /// </summary>\r\n        /// <returns></returns>\r\n        public async Task<string> GetOrderStatusAsStringAsync()\r\n        {\r\n            return (await this.GetOrderStatusAsync()).ToString();\r\n        }\r\n\r\n        public async Task ReceiveReminderAsync(string reminderName, byte[] context, TimeSpan dueTime, TimeSpan period)\r\n        {\r\n            switch (reminderName)\r\n            {\r\n                case CustomerOrderReminderNames.FulfillOrderReminder:\r\n\r\n                    await this.FulfillOrderAsync();\r\n\r\n                    CustomerOrderStatus orderStatus = await this.GetOrderStatusAsync();\r\n\r\n                    if (orderStatus == CustomerOrderStatus.Shipped || orderStatus == CustomerOrderStatus.Canceled)\r\n                    {\r\n                        //Remove fulfill order reminder so Actor can be gargabe collected.\r\n                        IActorReminder orderReminder = this.GetReminder(CustomerOrderReminderNames.FulfillOrderReminder);\r\n                        await this.UnregisterReminderAsync(orderReminder);\r\n                    }\r\n\r\n                    break;\r\n\r\n                default:\r\n                    // We should never arrive here normally. The system won't call reminders that don't exist. \r\n                    // But for our own sake in case we add a new reminder somewhere and forget to handle it, this will remind us.\r\n                    throw new InvalidOperationException(\"Unknown reminder: \" + reminderName);\r\n            }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Initializes CustomerOrderActor state. Because an order actor will only be activated\r\n        /// once in this scenario and never used again, when we initiate the actor's state we\r\n        /// change the order's status to \"Confirmed,\" and do not need to check if the actor's \r\n        /// state was already set to this. \r\n        /// </summary>\r\n        /// \r\n        protected override async Task OnActivateAsync()\r\n        {\r\n            await InternalActivateAsync(this.ActorService.Context.CodePackageActivationContext, new ServiceProxyFactory());\r\n\r\n            CustomerOrderStatus orderStatusResult = await this.GetOrderStatusAsync();\r\n\r\n            if (orderStatusResult == CustomerOrderStatus.Unknown)\r\n            {\r\n                await this.StateManager.SetStateAsync<List<CustomerOrderItem>>(OrderItemListPropertyName, new List<CustomerOrderItem>());\r\n                await this.StateManager.SetStateAsync<long>(RequestIdPropertyName, 0);\r\n                await this.SetOrderStatusAsync(CustomerOrderStatus.New);\r\n            }\r\n\r\n            return;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Adding this method to support DI/Testing \r\n        /// We need to do some work to create the actor object and make sure it is constructed completely\r\n        /// In local testing we can inject the components we need, but in a real cluster\r\n        /// those items are not established until the actor object is activated. Thus we need to \r\n        /// have this method so that the tests can have the same init path as the actor would in prod\r\n        /// </summary>\r\n        /// <returns></returns>\r\n        public async Task InternalActivateAsync(ICodePackageActivationContext context, IServiceProxyFactory proxyFactory)\r\n        {\r\n            this.tokenSource = new CancellationTokenSource();\r\n            this.builder = new ServiceUriBuilder(context, InventoryServiceName);\r\n            this.ServiceProxyFactory = proxyFactory;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Deactivates the actor object\r\n        /// </summary>\r\n        /// <returns></returns>\r\n        protected override Task OnDeactivateAsync()\r\n        {\r\n            this.tokenSource.Cancel();\r\n            this.tokenSource.Dispose();\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        /// <summary>\r\n        /// This method takes in a list of CustomerOrderItem objects. Using a Service Proxy to access the Inventory Service,\r\n        /// the method iterates onces through the order and tries to remove the quantity specified in the order from inventory. \r\n        /// If the inventory has insufficient stock to remove the requested amount for a particular item, the entire order is \r\n        /// marked as backordered and the item in question is added to a \"backordered\" item list, which is fulfilled in a separate \r\n        /// method. \r\n        /// \r\n        /// In its current form, this application addresses the question of race conditions to remove the same item by making a rule\r\n        /// that no order ever fails. While an item that is displayed in the store may not be available any longer by the time an order is placed,\r\n        /// the automatic restock policy instituted in the Inventory Service means that our FulfillOrder method and its sub-methods can continue to \r\n        /// query the Inventory Service on repeat (with a timer in between each cycle) until the order is fulfilled. \r\n        /// \r\n        /// </summary>\r\n        /// <returns>The number of items put on backorder after fulfilling the order.</returns>\r\n        internal async Task FulfillOrderAsync()\r\n        {\r\n\r\n            await this.SetOrderStatusAsync(CustomerOrderStatus.InProcess);\r\n\r\n            IList<CustomerOrderItem> orderedItems = await this.StateManager.GetStateAsync<IList<CustomerOrderItem>>(OrderItemListPropertyName);\r\n\r\n            ActorEventSource.Current.ActorMessage(this, \"Fullfilling customer order. ID: {0}. Items: {1}\", this.Id.GetGuidId(), orderedItems.Count);\r\n\r\n            foreach (CustomerOrderItem tempitem in orderedItems)\r\n            {\r\n                ActorEventSource.Current.Message(\"OrderContains:{0}\", tempitem);\r\n            }\r\n\r\n            //We loop through the customer order list. \r\n            //For every item that cannot be fulfilled, we add to backordered. \r\n            foreach (CustomerOrderItem item in orderedItems.Where(x => x.FulfillmentRemaining > 0))\r\n            {\r\n                IInventoryService inventoryService = this.ServiceProxyFactory.CreateServiceProxy<IInventoryService>(this.builder.ToUri(), item.ItemId.GetPartitionKey());\r\n\r\n                //First, check the item is listed in inventory.  \r\n                //This will avoid infinite backorder status.\r\n                if ((await inventoryService.IsItemInInventoryAsync(item.ItemId, this.tokenSource.Token)) == false)\r\n                {\r\n                    await this.SetOrderStatusAsync(CustomerOrderStatus.Canceled);\r\n                    return;\r\n                }\r\n\r\n                int numberItemsRemoved =\r\n                    await\r\n                        inventoryService.RemoveStockAsync(\r\n                            item.ItemId,\r\n                            item.Quantity,\r\n                            new CustomerOrderActorMessageId(\r\n                                new ActorId(this.Id.GetGuidId()),\r\n                                await this.StateManager.GetStateAsync<long>(RequestIdPropertyName)));\r\n\r\n                item.FulfillmentRemaining -= numberItemsRemoved;\r\n            }\r\n\r\n            IList<CustomerOrderItem> items = await this.StateManager.GetStateAsync<IList<CustomerOrderItem>>(OrderItemListPropertyName);\r\n            bool backordered = false;\r\n\r\n            // Set the status appropriately\r\n            foreach (CustomerOrderItem item in items)\r\n            {\r\n                if (item.FulfillmentRemaining > 0)\r\n                {\r\n                    backordered = true;\r\n                    break;\r\n                }\r\n            }\r\n\r\n            if (backordered)\r\n            {\r\n                await this.SetOrderStatusAsync(CustomerOrderStatus.Backordered);\r\n            }\r\n            else\r\n            {\r\n                await this.SetOrderStatusAsync(CustomerOrderStatus.Shipped);\r\n            }\r\n\r\n            ActorEventSource.Current.ActorMessage(\r\n                this,\r\n                \"{0}; Fulfilled: {1}. Backordered: {2}\",\r\n                await this.GetOrderStatusAsStringAsync(),\r\n                items.Count(x => x.FulfillmentRemaining == 0),\r\n                items.Count(x => x.FulfillmentRemaining > 0));\r\n\r\n            long messageRequestId = await this.StateManager.GetStateAsync<long>(RequestIdPropertyName);\r\n            await this.StateManager.SetStateAsync<long>(RequestIdPropertyName, ++messageRequestId);\r\n        }\r\n\r\n        private async Task<CustomerOrderStatus> GetOrderStatusAsync()\r\n        {\r\n            ConditionalValue<CustomerOrderStatus> orderStatusResult = await this.StateManager.TryGetStateAsync<CustomerOrderStatus>(OrderStatusPropertyName);\r\n            if (orderStatusResult.HasValue)\r\n            {\r\n                return orderStatusResult.Value;\r\n            }\r\n            else\r\n            {\r\n                return CustomerOrderStatus.Unknown;\r\n            }\r\n        }\r\n\r\n        private async Task SetOrderStatusAsync(CustomerOrderStatus orderStatus)\r\n        {\r\n            await this.StateManager.SetStateAsync<CustomerOrderStatus>(OrderStatusPropertyName, orderStatus);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/CustomerOrderReminderNames.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace CustomerOrder.Actor\r\n{\r\n    internal static class CustomerOrderReminderNames\r\n    {\r\n        public const string FulfillOrderReminder = \"FulfillOrderReminder\";\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/PackageRoot/Config/Settings.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Settings xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\r\n  <Section Name=\"CustomerOrderActorServiceReplicatorConfig\">\r\n    <Parameter Name=\"ReplicatorEndpoint\" Value=\"CustomerOrderActorServiceReplicatorEndpoint\" />\r\n    <Parameter Name=\"BatchAcknowledgementInterval\" Value=\"0.005\" />\r\n  </Section>\r\n  <Section Name=\"CustomerOrderActorServiceReplicatorSecurityConfig\">\r\n    <Parameter Name=\"CredentialType\" Value=\"None\" />\r\n  </Section>\r\n</Settings>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/PackageRoot/ServiceManifest.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<ServiceManifest xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Name=\"CustomerOrder.ActorPkg\" Version=\"1.0.0\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\r\n  <ServiceTypes>\r\n    <StatefulServiceType ServiceTypeName=\"CustomerOrderActorServiceType\">\r\n      <Extensions>\r\n        <Extension Name=\"__GeneratedServiceType__\" GeneratedId=\"36545b1e-9aa7-417b-a8aa-b7e28fd47353|None\">\r\n          <GeneratedNames xmlns=\"http://schemas.microsoft.com/2015/03/fabact-no-schema\">\r\n            <DefaultService Name=\"CustomerOrderActorService\" />\r\n            <ServiceEndpoint Name=\"CustomerOrderActorServiceEndpoint\" />\r\n            <ReplicatorEndpoint Name=\"CustomerOrderActorServiceReplicatorEndpoint\" />\r\n            <ReplicatorConfigSection Name=\"CustomerOrderActorServiceReplicatorConfig\" />\r\n            <ReplicatorSecurityConfigSection Name=\"CustomerOrderActorServiceReplicatorSecurityConfig\" />\r\n            <StoreConfigSection Name=\"CustomerOrderActorServiceLocalStoreConfig\" />\r\n          </GeneratedNames>\r\n        </Extension>\r\n      </Extensions>\r\n    </StatefulServiceType>\r\n  </ServiceTypes>\r\n  <CodePackage Name=\"Code\" Version=\"1.0.0\">\r\n    <EntryPoint>\r\n      <ExeHost>\r\n        <Program>CustomerOrder.Actor.exe</Program>\r\n      </ExeHost>\r\n    </EntryPoint>\r\n  </CodePackage>\r\n  <ConfigPackage Name=\"Config\" Version=\"1.0.0\" />\r\n  <Resources>\r\n    <Endpoints>\r\n      <Endpoint Name=\"CustomerOrderActorServiceEndpoint\" />\r\n      <Endpoint Name=\"CustomerOrderActorServiceReplicatorEndpoint\" />\r\n    </Endpoints>\r\n  </Resources>\r\n</ServiceManifest>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/Program.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace CustomerOrder.Actor\r\n{\r\n    using System;\r\n    using System.Threading;\r\n    using Microsoft.ServiceFabric.Actors.Runtime;\r\n\r\n    public class Program\r\n    {\r\n        public static void Main(string[] args)\r\n        {\r\n            try\r\n            {\r\n                ActorRuntime.RegisterActorAsync<CustomerOrderActor>();\r\n                Thread.Sleep(Timeout.Infinite);\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ActorEventSource.Current.ActorHostInitializationFailed(e.ToString());\r\n                throw;\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.CompilerServices;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"CustomerOrder\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"CustomerOrder\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"5f0c7805-c91d-47e9-aede-946cadea1c8f\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]\r\n[assembly: InternalsVisibleTo(\"CustomerOrder.UnitTests\")]"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Actor/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Domain/CustomerOrder.Domain.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{1E7E813F-43D3-4D0B-8546-5E1023873F28}</ProjectGuid>\r\n    <OutputType>Library</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>CustomerOrder.Domain</RootNamespace>\r\n    <AssemblyName>CustomerOrder.Domain</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <DebugType>full</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\r\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <Optimize>true</Optimize>\r\n    <DebugType>pdbonly</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"CustomerOrderItem.cs\" />\r\n    <Compile Include=\"CustomerOrderStatus.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n    <Compile Include=\"ICustomerOrderActor.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\">\r\n      <Project>{7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae}</Project>\r\n      <Name>Inventory.Domain</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"app.config\" />\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n</Project>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Domain/CustomerOrderItem.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace CustomerOrder.Domain\r\n{\r\n    using System;\r\n    using System.Runtime.Serialization;\r\n    using Inventory.Domain;\r\n\r\n    [DataContract]\r\n    public sealed class CustomerOrderItem\r\n    {\r\n        public CustomerOrderItem(InventoryItemId itemId, int quantity)\r\n        {\r\n            this.ItemId = itemId;\r\n            this.Quantity = quantity;\r\n            this.FulfillmentRemaining = quantity;\r\n        }\r\n\r\n        [DataMember]\r\n        public InventoryItemId ItemId { get; set; }\r\n\r\n        [DataMember]\r\n        public int Quantity { get; set; }\r\n\r\n        [DataMember]\r\n        public int FulfillmentRemaining { get; set; }\r\n\r\n        public override string ToString()\r\n        {\r\n            return String.Format(\"ID: {0}, Quantity: {1}, Fulfillment Remaing: {2}\", this.ItemId, this.Quantity, this.FulfillmentRemaining);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Domain/CustomerOrderStatus.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace CustomerOrder.Domain\r\n{\r\n    public enum CustomerOrderStatus\r\n    {\r\n        Unknown,\r\n        New,\r\n        Submitted,\r\n        InProcess,\r\n        Backordered,\r\n        Shipped,\r\n        Canceled,\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Domain/ICustomerOrderActor.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace CustomerOrder.Domain\r\n{\r\n    using System.Collections.Generic;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Actors;\r\n\r\n    public interface ICustomerOrderActor : IActor\r\n    {\r\n        Task<string> GetOrderStatusAsStringAsync();\r\n\r\n        Task SubmitOrderAsync(IEnumerable<CustomerOrderItem> orderList);\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Domain/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"CustomerOrder.Interfaces\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"CustomerOrder.Interfaces\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"1e7e813f-43d3-4d0b-8546-5e1023873f28\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Domain/app.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.Domain/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.UnitTests/CustomerOrder.UnitTests.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\r\n    <ProjectGuid>{226B8D34-99CF-4172-87DC-E20B39030CC0}</ProjectGuid>\r\n    <OutputType>Library</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>CustomerOrder.UnitTests</RootNamespace>\r\n    <AssemblyName>CustomerOrder.UnitTests</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\r\n    <VisualStudioVersion Condition=\"'$(VisualStudioVersion)' == ''\">10.0</VisualStudioVersion>\r\n    <VSToolsPath Condition=\"'$(VSToolsPath)' == ''\">$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)</VSToolsPath>\r\n    <ReferencePath>$(ProgramFiles)\\Common Files\\microsoft shared\\VSTT\\$(VisualStudioVersion)\\UITestExtensionPackages</ReferencePath>\r\n    <IsCodedUITest>False</IsCodedUITest>\r\n    <TestProjectType>UnitTest</TestProjectType>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <DebugType>full</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\r\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <Optimize>true</Optimize>\r\n    <DebugType>pdbonly</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <Choose>\r\n    <When Condition=\"('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'\">\r\n      <ItemGroup>\r\n        <Reference Include=\"Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\" />\r\n      </ItemGroup>\r\n    </When>\r\n    <Otherwise />\r\n  </Choose>\r\n  <ItemGroup>\r\n    <Compile Include=\"CustomerOrderActorTests.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\CustomerOrder.Actor\\CustomerOrder.Actor.csproj\">\r\n      <Project>{5f0c7805-c91d-47e9-aede-946cadea1c8f}</Project>\r\n      <Name>CustomerOrder.Actor</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\CustomerOrder.Domain\\CustomerOrder.Domain.csproj\">\r\n      <Project>{1e7e813f-43d3-4d0b-8546-5e1023873f28}</Project>\r\n      <Name>CustomerOrder.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\">\r\n      <Project>{7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae}</Project>\r\n      <Name>Inventory.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Mocks\\Mocks.csproj\">\r\n      <Project>{00e00484-bd00-40cd-b2cc-1cfa8e893972}</Project>\r\n      <Name>Mocks</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"app.config\" />\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n      <Private>False</Private>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Numerics\" />\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n  </ItemGroup>\r\n  <Choose>\r\n    <When Condition=\"'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'\">\r\n      <ItemGroup>\r\n        <Reference Include=\"Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n          <Private>False</Private>\r\n        </Reference>\r\n        <Reference Include=\"Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n          <Private>False</Private>\r\n        </Reference>\r\n        <Reference Include=\"Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n          <Private>False</Private>\r\n        </Reference>\r\n        <Reference Include=\"Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n          <Private>False</Private>\r\n        </Reference>\r\n      </ItemGroup>\r\n    </When>\r\n  </Choose>\r\n  <Import Project=\"$(VSToolsPath)\\TeamTest\\Microsoft.TestTools.targets\" Condition=\"Exists('$(VSToolsPath)\\TeamTest\\Microsoft.TestTools.targets')\" />\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r\n       Other similar extension points exist, see Microsoft.Common.targets.\r\n  <Target Name=\"BeforeBuild\">\r\n  </Target>\r\n  <Target Name=\"AfterBuild\">\r\n  </Target>\r\n  -->\r\n</Project>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.UnitTests/CustomerOrderActorTests.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace CustomerOrder.UnitTests\r\n{\r\n    using CustomerOrder.Actor;\r\n    using CustomerOrder.Domain;\r\n    using Inventory.Domain;\r\n    using Microsoft.ServiceFabric.Actors;\r\n    using Microsoft.ServiceFabric.Actors.Runtime;\r\n    using Microsoft.VisualStudio.TestTools.UnitTesting;\r\n    using Mocks;\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Fabric;\r\n    using System.Numerics;\r\n    using System.Reflection;\r\n    using System.Threading.Tasks;\r\n\r\n    [TestClass]\r\n    public class CustomerOrderActorTests\r\n    {\r\n        private const string OrderItemListPropertyName = \"OrderList\";\r\n        private const string OrderStatusPropertyName = \"CustomerOrderStatus\";\r\n        private const string RequestIdPropertyName = \"RequestId\";\r\n        private const string InventoryServiceName = \"InventoryService\";\r\n\r\n        private static ICodePackageActivationContext codePackageContext = new MockCodePackageActivationContext(\r\n            \"fabric:/someapp\",\r\n            \"SomeAppType\",\r\n            \"Code\",\r\n            \"1.0.0.0\",\r\n            Guid.NewGuid().ToString(),\r\n            @\"C:\\Log\",\r\n            @\"C:\\Temp\",\r\n            @\"C:\\Work\",\r\n            \"ServiceManifest\",\r\n            \"1.0.0.0\"\r\n            );\r\n\r\n        private static StatefulServiceContext statefulServiceContext = new StatefulServiceContext(\r\n            new NodeContext(\"Test\", new NodeId(new BigInteger(0), new BigInteger(0)), new BigInteger(0), \"TestType\", \"localhost\"),\r\n            codePackageContext,\r\n            \"\",\r\n            new Uri(\"fabric:/testapp/testservice\"),\r\n            new byte[0],\r\n            Guid.NewGuid(),\r\n            0);\r\n\r\n        /// <summary>\r\n        /// Tests FulfillOrder ships an order when all items are available from the InventoryService.\r\n        /// </summary>\r\n        /// <returns></returns>\r\n        [TestMethod]\r\n        public async Task TestFulfillOrderSimple()\r\n        {\r\n            // The default mock inventory service behavior is to always complete an order.\r\n\r\n            MockInventoryService inventoryService = new MockInventoryService();\r\n\r\n            MockServiceProxyFactory serviceProxyFactory = new MockServiceProxyFactory();\r\n            serviceProxyFactory.AssociateMockServiceAndName(new Uri(\"fabric:/someapp/\" + InventoryServiceName), inventoryService);\r\n\r\n            CustomerOrderActor target = await CreateCustomerOrderActor(serviceProxyFactory);\r\n\r\n            await target.StateManager.SetStateAsync<CustomerOrderStatus>(RequestIdPropertyName, CustomerOrderStatus.Submitted);\r\n            await target.StateManager.SetStateAsync<long>(RequestIdPropertyName, 0);\r\n            await target.StateManager.SetStateAsync<List<CustomerOrderItem>>(OrderItemListPropertyName, new List<CustomerOrderItem>()\r\n            {\r\n                new CustomerOrderItem(new InventoryItemId(), 4)\r\n            });\r\n\r\n            await target.FulfillOrderAsync();\r\n\r\n            Assert.AreEqual<CustomerOrderStatus>(CustomerOrderStatus.Shipped, await target.StateManager.GetStateAsync<CustomerOrderStatus>(OrderStatusPropertyName));\r\n        }\r\n\r\n        /// <summary>\r\n        /// Tests FulfillOrder does not ship when not all items could be fulfilled by InventoryService.\r\n        /// </summary>\r\n        /// <returns></returns>\r\n        [TestMethod]\r\n        public async Task TestFulfillOrderWithBackorder()\r\n        {\r\n            // instruct the mock inventory service to always return less quantity than requested \r\n            // so that FulfillOrder always ends up in backordered status.            \r\n\r\n            MockInventoryService inventoryService = new MockInventoryService()\r\n            {\r\n                RemoveStockAsyncFunc = (itemId, quantity, cmid) => Task.FromResult(quantity - 1)\r\n            };\r\n\r\n            MockServiceProxy serviceProxy = new MockServiceProxy();\r\n            serviceProxy.Supports<IInventoryService>(serviceUri => inventoryService);\r\n\r\n            MockServiceProxyFactory serviceProxyFactory = new MockServiceProxyFactory();\r\n            serviceProxyFactory.AssociateMockServiceAndName(new Uri(\"fabric:/someapp/\" + InventoryServiceName), inventoryService);\r\n\r\n            CustomerOrderActor target = await CreateCustomerOrderActor(serviceProxyFactory);\r\n\r\n            await target.StateManager.SetStateAsync<CustomerOrderStatus>(RequestIdPropertyName, CustomerOrderStatus.Submitted);\r\n            await target.StateManager.SetStateAsync<long>(RequestIdPropertyName, 0);\r\n            await target.StateManager.SetStateAsync<List<CustomerOrderItem>>(OrderItemListPropertyName, new List<CustomerOrderItem>()\r\n            {\r\n                new CustomerOrderItem(new InventoryItemId(), 4)\r\n            });\r\n\r\n            await target.FulfillOrderAsync();\r\n\r\n            Assert.AreEqual<CustomerOrderStatus>(CustomerOrderStatus.Backordered, await target.StateManager.GetStateAsync<CustomerOrderStatus>(OrderStatusPropertyName));\r\n        }\r\n\r\n        /// <summary>\r\n        /// Tests FulfillOrder completes a shipment after multiple iterations when a limited quantity is available from InventoryService.\r\n        /// </summary>\r\n        /// <returns></returns>\r\n        [TestMethod]\r\n        public async Task TestFulfillOrderToCompletion()\r\n        {\r\n            int itemCount = 5;\r\n\r\n            // instruct the mock inventory service to only fulfill one item each time\r\n            // so that FulfillOrder has to make multiple iterations to complete an order\r\n            MockInventoryService inventoryService = new MockInventoryService()\r\n            {\r\n                RemoveStockAsyncFunc = (itemId, quantity, cmid) => Task.FromResult(1)\r\n            };\r\n\r\n            MockServiceProxy serviceProxy = new MockServiceProxy();\r\n            serviceProxy.Supports<IInventoryService>(serviceUri => inventoryService);\r\n\r\n            MockServiceProxyFactory serviceProxyFactory = new MockServiceProxyFactory();\r\n            serviceProxyFactory.AssociateMockServiceAndName(new Uri(\"fabric:/someapp/\" + InventoryServiceName), inventoryService);\r\n\r\n            CustomerOrderActor target = await CreateCustomerOrderActor(serviceProxyFactory);\r\n\r\n            await target.StateManager.SetStateAsync<CustomerOrderStatus>(RequestIdPropertyName, CustomerOrderStatus.Submitted);\r\n            await target.StateManager.SetStateAsync<long>(RequestIdPropertyName, 0);\r\n            await target.StateManager.SetStateAsync<List<CustomerOrderItem>>(OrderItemListPropertyName, new List<CustomerOrderItem>()\r\n            {\r\n                new CustomerOrderItem(new InventoryItemId(), 5)\r\n            });\r\n\r\n            for (int i = 0; i < itemCount - 1; ++i)\r\n            {\r\n                await target.FulfillOrderAsync();\r\n                Assert.AreEqual<CustomerOrderStatus>(CustomerOrderStatus.Backordered, await target.StateManager.GetStateAsync<CustomerOrderStatus>(OrderStatusPropertyName));\r\n            }\r\n\r\n            await target.FulfillOrderAsync();\r\n            Assert.AreEqual<CustomerOrderStatus>(CustomerOrderStatus.Shipped, await target.StateManager.GetStateAsync<CustomerOrderStatus>(OrderStatusPropertyName));\r\n        }\r\n\r\n        [TestMethod]\r\n        public async Task TestFulfillOrderCancelled()\r\n        {\r\n            // instruct the mock inventory service to return 0 for all items to simulate items that don't exist.\r\n            // and have it return false when asked if an item exists to make sure FulfillOrder doesn't get into\r\n            // an infinite backorder loop.\r\n            MockInventoryService inventoryService = new MockInventoryService()\r\n            {\r\n                IsItemInInventoryAsyncFunc = itemId => Task.FromResult(false),\r\n                RemoveStockAsyncFunc = (itemId, quantity, cmid) => Task.FromResult(0)\r\n            };\r\n\r\n            MockServiceProxy serviceProxy = new MockServiceProxy();\r\n            serviceProxy.Supports<IInventoryService>(serviceUri => inventoryService);\r\n\r\n            MockServiceProxyFactory serviceProxyFactory = new MockServiceProxyFactory();\r\n            serviceProxyFactory.AssociateMockServiceAndName(new Uri(\"fabric:/someapp/\" + InventoryServiceName), inventoryService);\r\n\r\n            CustomerOrderActor target = await CreateCustomerOrderActor(serviceProxyFactory);\r\n\r\n            await target.StateManager.SetStateAsync<CustomerOrderStatus>(RequestIdPropertyName, CustomerOrderStatus.Submitted);\r\n            await target.StateManager.SetStateAsync<long>(RequestIdPropertyName, 0);\r\n            await target.StateManager.SetStateAsync<List<CustomerOrderItem>>(OrderItemListPropertyName, new List<CustomerOrderItem>()\r\n            {\r\n                new CustomerOrderItem(new InventoryItemId(), 5)\r\n            });\r\n\r\n            await target.FulfillOrderAsync();\r\n\r\n            CustomerOrderStatus status = await target.StateManager.GetStateAsync<CustomerOrderStatus>(OrderStatusPropertyName);\r\n\r\n            Assert.AreEqual<CustomerOrderStatus>(CustomerOrderStatus.Canceled, status);\r\n        }\r\n\r\n        private static async Task<CustomerOrderActor> CreateCustomerOrderActor(MockServiceProxyFactory serviceProxyFactory)\r\n        {\r\n            try\r\n            {\r\n                CustomerOrderActor target = new CustomerOrderActor(\r\n                    new ActorService(\r\n                        context: statefulServiceContext,\r\n                        actorTypeInfo: ActorTypeInformation.Get(typeof(CustomerOrderActor)),\r\n                        stateManagerFactory: (actorBase, stateProvider) => new MockActorStateManager()),\r\n                    new ActorId(Guid.NewGuid()));\r\n\r\n                await target.InternalActivateAsync(codePackageContext, serviceProxyFactory);\r\n\r\n                return target;\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                throw;\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/CustomerOrder.UnitTests/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\n// ------------------------------------------------------------\n\nusing System.Reflection;\nusing System.Runtime.InteropServices;\n\n// General Information about an assembly is controlled through the following \n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n\n[assembly: AssemblyTitle(\"CustomerOrder.UnitTests\")]\n[assembly: AssemblyDescription(\"\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyCompany(\"\")]\n[assembly: AssemblyProduct(\"CustomerOrder.UnitTests\")]\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n\n// Setting ComVisible to false makes the types in this assembly not visible \n// to COM components.  If you need to access a type in this assembly from \n// COM, set the ComVisible attribute to true on that type.\n\n[assembly: ComVisible(false)]\n\n// The following GUID is for the ID of the typelib if this project is exposed to COM\n\n[assembly: Guid(\"226b8d34-99cf-4172-87dc-e20b39030cc0\")]\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version \n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers \n// by using the '*' as shown below:\n// [assembly: AssemblyVersion(\"1.0.*\")]\n\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/CustomerOrder.UnitTests/app.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>"
  },
  {
    "path": "ReferenceApp/CustomerOrder.UnitTests/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/Inventory.Domain/IInventoryService.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Domain\r\n{\r\n    using System.Collections.Generic;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n    using Common;\r\n    using Microsoft.ServiceFabric.Services.Remoting;\r\n\r\n    public interface IInventoryService : IService\r\n    {\r\n        Task<int> AddStockAsync(InventoryItemId itemId, int quantity);\r\n        Task<int> RemoveStockAsync(InventoryItemId itemId, int quantity, CustomerOrderActorMessageId messageId);\r\n        Task<bool> IsItemInInventoryAsync(InventoryItemId itemId, CancellationToken cancellationToken);\r\n        Task<IEnumerable<InventoryItemView>> GetCustomerInventoryAsync(CancellationToken cancellationToken);\r\n        Task<bool> CreateInventoryItemAsync(InventoryItem item);\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Domain/Inventory.Domain.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{7E9C2DFD-71A5-496D-AA4D-5EC53EAEB9AE}</ProjectGuid>\r\n    <OutputType>Library</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>Inventory.Domain</RootNamespace>\r\n    <AssemblyName>Inventory.Domain</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <DebugType>full</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\r\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <Optimize>true</Optimize>\r\n    <DebugType>pdbonly</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n    <Reference Include=\"System.Xml.Linq\" />\r\n    <Reference Include=\"System.Data.DataSetExtensions\" />\r\n    <Reference Include=\"Microsoft.CSharp\" />\r\n    <Reference Include=\"System.Data\" />\r\n    <Reference Include=\"System.Net.Http\" />\r\n    <Reference Include=\"System.Xml\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"IInventoryService.cs\" />\r\n    <Compile Include=\"InventoryItem.cs\" />\r\n    <Compile Include=\"InventoryItemId.cs\" />\r\n    <Compile Include=\"InventoryItemView.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r\n       Other similar extension points exist, see Microsoft.Common.targets.\r\n  <Target Name=\"BeforeBuild\">\r\n  </Target>\r\n  <Target Name=\"AfterBuild\">\r\n  </Target>\r\n  -->\r\n</Project>"
  },
  {
    "path": "ReferenceApp/Inventory.Domain/InventoryItem.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Domain\r\n{\r\n    using System;\r\n\r\n    [Serializable]\r\n    public sealed class InventoryItem\r\n    {\r\n        public InventoryItem(\r\n            string description, decimal price, int availableStock, int restockThreshold, int maxStockThreshold, InventoryItemId id = null,\r\n            bool onReorder = false)\r\n        {\r\n            this.Id = id ?? new InventoryItemId();\r\n            this.Description = description;\r\n            this.Price = price;\r\n            this.AvailableStock = availableStock;\r\n            this.RestockThreshold = restockThreshold;\r\n            this.MaxStockThreshold = maxStockThreshold;\r\n            this.OnReorder = onReorder;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Unique identifier for each item style\r\n        /// </summary>\r\n        public InventoryItemId Id { get; }\r\n\r\n        /// <summary>\r\n        /// Quantity in stock\r\n        /// </summary>\r\n        public int AvailableStock { get; private set; }\r\n\r\n        /// <summary>\r\n        /// Price\r\n        /// </summary>\r\n        public decimal Price { get; }\r\n\r\n        /// <summary>\r\n        /// Brief description of product for display on website\r\n        /// </summary>\r\n        public string Description { get; }\r\n\r\n        /// <summary>\r\n        /// Available stock at which we should reorder\r\n        /// </summary>\r\n        public int RestockThreshold { get; }\r\n\r\n        /// <summary>\r\n        /// Maximum number of units that can be in-stock at any time (due to physicial/logistical constraints in warehouses)\r\n        /// </summary>\r\n        public int MaxStockThreshold { get; }\r\n\r\n        /// <summary>\r\n        /// True if item is on reorder\r\n        /// </summary>\r\n        public bool OnReorder { get; set; }\r\n\r\n        /// <summary>\r\n        /// Returns an InventoryItemView object, which contains only external, customer-facing data about an item in inventory.\r\n        /// </summary>\r\n        /// <param name=\"item\"></param>\r\n        public static implicit operator InventoryItemView(InventoryItem item)\r\n        {\r\n            return new InventoryItemView\r\n            {\r\n                Id = item.Id,\r\n                Price = item.Price,\r\n                Description = item.Description,\r\n                CustomerAvailableStock = item.AvailableStock - item.RestockThreshold //Business logic: constraint to reduce overordering.\r\n            };\r\n        }\r\n\r\n        public override string ToString()\r\n        {\r\n            return string.Format(\r\n                \"Item {0}: {1} at a price of {2} with {3} available items at a restock threshold of {4} and with max stocking threshold of {5}.\",\r\n                this.Id,\r\n                this.Description,\r\n                this.Price,\r\n                this.AvailableStock.ToString(),\r\n                this.RestockThreshold.ToString(),\r\n                this.MaxStockThreshold.ToString());\r\n        }\r\n\r\n        /// <summary>\r\n        /// Increments the quantity of a particular item in inventory.\r\n        /// <param name=\"quantity\"></param>\r\n        /// <returns>int: Returns the quantity that has been added to stock</returns>\r\n        /// </summary>\r\n        public int AddStock(int quantity)\r\n        {\r\n            int original = this.AvailableStock;\r\n\r\n            // The quantity that the client is trying to add to stock is greater than what can be physically accommodated in a Fabrikam Warehouse\r\n            if ((this.AvailableStock + quantity) > this.MaxStockThreshold)\r\n            {\r\n                // For now, this method only adds new units up maximum stock threshold. In an expanded version of this application, we\r\n                //could include tracking for the remaining units and store information about overstock elsewhere. \r\n                this.AvailableStock += (this.MaxStockThreshold - this.AvailableStock);\r\n            }\r\n            else\r\n            {\r\n                this.AvailableStock += quantity;\r\n            }\r\n\r\n            this.OnReorder = false;\r\n\r\n            return this.AvailableStock - original;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Decrements the quantity of a particular item in inventory and ensures the restockThreshold hasn't\r\n        /// been breached. If so, a RestockRequest is generated in CheckThreshold. \r\n        /// \r\n        /// If there is sufficient stock of an item, then the integer returned at the end of this call should be the same as quantityDesired. \r\n        /// In the event that there is not sufficient stock available, the method will remove whatever stock is available and return that quantity to the client.\r\n        /// In this case, it is the responsibility of the client to determine if the amount that is returned is the same as quantityDesired.\r\n        /// It is invalid to pass in a negative number. \r\n        /// </summary>\r\n        /// <param name=\"quantityDesired\"></param>\r\n        /// <returns>int: Returns the number actually removed from stock. </returns>\r\n        /// \r\n        public int RemoveStock(int quantityDesired)\r\n        {\r\n            int removed = Math.Min(quantityDesired, this.AvailableStock); //Assumes quantityDesired is a positive integer\r\n\r\n            this.AvailableStock -= removed;\r\n\r\n            return removed;\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Domain/InventoryItemId.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Domain\r\n{\r\n    using System;\r\n    using System.Runtime.Serialization;\r\n    using Common;\r\n    using Microsoft.ServiceFabric.Services.Client;\r\n\r\n    [DataContract]\r\n    public class InventoryItemId : IFormattable, IComparable, IComparable<InventoryItemId>, IEquatable<InventoryItemId>\r\n    {\r\n        [DataMember] private Guid id;\r\n\r\n        public InventoryItemId()\r\n        {\r\n            this.id = Guid.NewGuid();\r\n        }\r\n\r\n        public int CompareTo(object obj)\r\n        {\r\n            return this.id.CompareTo(((InventoryItemId) obj).id);\r\n        }\r\n\r\n        public int CompareTo(InventoryItemId other)\r\n        {\r\n            return this.id.CompareTo(other.id);\r\n        }\r\n\r\n        public bool Equals(InventoryItemId other)\r\n        {\r\n            return this.id.Equals(other.id);\r\n        }\r\n\r\n        public string ToString(string format, IFormatProvider formatProvider)\r\n        {\r\n            return this.id.ToString(format, formatProvider);\r\n        }\r\n\r\n        public ServicePartitionKey GetPartitionKey()\r\n        {\r\n            return new ServicePartitionKey(HashUtil.getLongHashCode(this.id.ToString()));\r\n        }\r\n\r\n        public static bool operator ==(InventoryItemId item1, InventoryItemId item2)\r\n        {\r\n            return item1.Equals(item2);\r\n        }\r\n\r\n        public static bool operator !=(InventoryItemId item1, InventoryItemId item2)\r\n        {\r\n            return !item1.Equals(item2);\r\n        }\r\n\r\n        public override bool Equals(object obj)\r\n        {\r\n            return (obj is InventoryItemId) ? this.id.Equals(((InventoryItemId) obj).id) : false;\r\n        }\r\n\r\n        public override int GetHashCode()\r\n        {\r\n            return this.id.GetHashCode();\r\n        }\r\n\r\n        public override string ToString()\r\n        {\r\n            return this.id.ToString();\r\n        }\r\n\r\n        public string ToString(string format)\r\n        {\r\n            return this.id.ToString(format);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Domain/InventoryItemView.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Domain\r\n{\r\n    using System.Runtime.Serialization;\r\n\r\n    //Guid will always be key to this value pair\r\n    [DataContract]\r\n    public sealed class InventoryItemView\r\n    {\r\n        [DataMember]\r\n        public InventoryItemId Id { get; set; }\r\n\r\n        [DataMember]\r\n        public string Description { get; set; }\r\n\r\n        [DataMember]\r\n        public decimal Price { get; set; }\r\n\r\n        [DataMember]\r\n        public int CustomerAvailableStock { get; set; }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Domain/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"InventoryService.Domain\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"InventoryService.Domain\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/Inventory.Domain/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/Inventory.Service/App.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <startup>\r\n    <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.5.2\" />\r\n  </startup>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Services\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Internal\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Data\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.Azure.KeyVault.Core\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-2.0.0.0\" newVersion=\"2.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Newtonsoft.Json\" publicKeyToken=\"30ad4fe6b2a6aeed\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-10.0.0.0\" newVersion=\"10.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>\r\n"
  },
  {
    "path": "ReferenceApp/Inventory.Service/AzureBackupStore.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Service\r\n{\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Fabric.Description;\r\n    using System.IO;\r\n    using System.IO.Compression;\r\n    using System.Linq;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Data;\r\n    using Microsoft.WindowsAzure.Storage.Auth;\r\n    using Microsoft.WindowsAzure.Storage.Blob;\r\n\r\n    public class AzureBlobBackupManager : IBackupStore\r\n    {\r\n        private readonly CloudBlobClient cloudBlobClient;\r\n        private CloudBlobContainer backupBlobContainer;\r\n        private int MaxBackupsToKeep;\r\n\r\n        private string PartitionTempDirectory;\r\n        private string partitionId;\r\n\r\n        private long backupFrequencyInSeconds;\r\n        private long keyMin;\r\n        private long keyMax;\r\n\r\n        public AzureBlobBackupManager(ConfigurationSection configSection, string partitionId, long keymin, long keymax, string codePackageTempDirectory)\r\n        {\r\n            this.keyMin = keymin;\r\n            this.keyMax = keymax;\r\n\r\n            string backupAccountName = configSection.Parameters[\"BackupAccountName\"].Value;\r\n            string backupAccountKey = configSection.Parameters[\"PrimaryKeyForBackupTestAccount\"].Value;\r\n            string blobEndpointAddress = configSection.Parameters[\"BlobServiceEndpointAddress\"].Value;\r\n\r\n            this.backupFrequencyInSeconds = long.Parse(configSection.Parameters[\"BackupFrequencyInSeconds\"].Value);\r\n            this.MaxBackupsToKeep = int.Parse(configSection.Parameters[\"MaxBackupsToKeep\"].Value);\r\n            this.partitionId = partitionId;\r\n            this.PartitionTempDirectory = Path.Combine(codePackageTempDirectory, partitionId);\r\n\r\n            StorageCredentials storageCredentials = new StorageCredentials(backupAccountName, backupAccountKey);\r\n            this.cloudBlobClient = new CloudBlobClient(new Uri(blobEndpointAddress), storageCredentials);\r\n            this.backupBlobContainer = this.cloudBlobClient.GetContainerReference(this.partitionId);\r\n            this.backupBlobContainer.CreateIfNotExists();\r\n        }\r\n\r\n        long IBackupStore.backupFrequencyInSeconds\r\n        {\r\n            get { return this.backupFrequencyInSeconds; }\r\n        }\r\n\r\n        public async Task ArchiveBackupAsync(BackupInfo backupInfo, CancellationToken cancellationToken)\r\n        {\r\n            ServiceEventSource.Current.Message(\"AzureBlobBackupManager: Archive Called.\");\r\n\r\n            string fullArchiveDirectory = Path.Combine(this.PartitionTempDirectory, Guid.NewGuid().ToString(\"N\"));\r\n\r\n            DirectoryInfo fullArchiveDirectoryInfo = new DirectoryInfo(fullArchiveDirectory);\r\n            fullArchiveDirectoryInfo.Create();\r\n\r\n            string blobName = string.Format(\"{0}_{1}_{2}_{3}\", Guid.NewGuid().ToString(\"N\"), this.keyMin, this.keyMax, \"Backup.zip\");\r\n            string fullArchivePath = Path.Combine(fullArchiveDirectory, \"Backup.zip\");\r\n\r\n            ZipFile.CreateFromDirectory(backupInfo.Directory, fullArchivePath, CompressionLevel.Fastest, false);\r\n\r\n            DirectoryInfo backupDirectory = new DirectoryInfo(backupInfo.Directory);\r\n            backupDirectory.Delete(true);\r\n\r\n            CloudBlockBlob blob = this.backupBlobContainer.GetBlockBlobReference(blobName);\r\n            await blob.UploadFromFileAsync(fullArchivePath,  CancellationToken.None);\r\n\r\n            DirectoryInfo tempDirectory = new DirectoryInfo(fullArchiveDirectory);\r\n            tempDirectory.Delete(true);\r\n\r\n            ServiceEventSource.Current.Message(\"AzureBlobBackupManager: UploadBackupFolderAsync: success.\");\r\n        }\r\n\r\n        public async Task<string> RestoreLatestBackupToTempLocation(CancellationToken cancellationToken)\r\n        {\r\n            ServiceEventSource.Current.Message(\"AzureBlobBackupManager: Download backup async called.\");\r\n\r\n            CloudBlockBlob lastBackupBlob = (await this.GetBackupBlobs(true)).First();\r\n\r\n            ServiceEventSource.Current.Message(\"AzureBlobBackupManager: Downloading {0}\", lastBackupBlob.Name);\r\n\r\n            string downloadId = Guid.NewGuid().ToString(\"N\");\r\n\r\n            string zipPath = Path.Combine(this.PartitionTempDirectory, string.Format(\"{0}_Backup.zip\", downloadId));\r\n\r\n            lastBackupBlob.DownloadToFile(zipPath, FileMode.CreateNew);\r\n\r\n            string restorePath = Path.Combine(this.PartitionTempDirectory, downloadId);\r\n\r\n            ZipFile.ExtractToDirectory(zipPath, restorePath);\r\n\r\n            FileInfo zipInfo = new FileInfo(zipPath);\r\n            zipInfo.Delete();\r\n\r\n            ServiceEventSource.Current.Message(\"AzureBlobBackupManager: Downloaded {0} in to {1}\", lastBackupBlob.Name, restorePath);\r\n\r\n            return restorePath;\r\n        }\r\n\r\n        public async Task DeleteBackupsAsync(CancellationToken cancellationToken)\r\n        {\r\n            if (this.backupBlobContainer.Exists())\r\n            {\r\n                ServiceEventSource.Current.Message(\"AzureBlobBackupManager: Deleting old backups\");\r\n\r\n                IEnumerable<CloudBlockBlob> oldBackups = (await this.GetBackupBlobs(true)).Skip(this.MaxBackupsToKeep);\r\n\r\n                foreach (CloudBlockBlob backup in oldBackups)\r\n                {\r\n                    ServiceEventSource.Current.Message(\"AzureBlobBackupManager: Deleting {0}\", backup.Name);\r\n                    await backup.DeleteAsync(cancellationToken);\r\n                }\r\n            }\r\n        }\r\n\r\n        private async Task<IEnumerable<CloudBlockBlob>> GetBackupBlobs(bool sorted)\r\n        {\r\n            IEnumerable<IListBlobItem> blobs = this.backupBlobContainer.ListBlobs();\r\n\r\n            ServiceEventSource.Current.Message(\"AzureBlobBackupManager: Got {0} blobs\", blobs.Count());\r\n\r\n            List<CloudBlockBlob> itemizedBlobs = new List<CloudBlockBlob>();\r\n\r\n            foreach (CloudBlockBlob cbb in blobs)\r\n            {\r\n                await cbb.FetchAttributesAsync();\r\n                itemizedBlobs.Add(cbb);\r\n            }\r\n\r\n            if (sorted)\r\n            {\r\n                return itemizedBlobs.OrderByDescending(x => x.Properties.LastModified);\r\n            }\r\n            else\r\n            {\r\n                return itemizedBlobs;\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Service/IBackupStore.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Service\r\n{\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Data;\r\n\r\n    public interface IBackupStore\r\n    {\r\n        long backupFrequencyInSeconds { get; }\r\n\r\n        Task ArchiveBackupAsync(BackupInfo backupInfo, CancellationToken cancellationToken);\r\n\r\n        Task<string> RestoreLatestBackupToTempLocation(CancellationToken cancellationToken);\r\n\r\n        Task DeleteBackupsAsync(CancellationToken cancellationToken);\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Service/Inventory.Service.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{714B1C61-FFA8-4A5E-8DD2-D0A290677293}</ProjectGuid>\r\n    <OutputType>Exe</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>Inventory.Service</RootNamespace>\r\n    <AssemblyName>Inventory.Service</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\r\n    <TargetFrameworkProfile />\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n    <IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x64' \">\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <DebugType>full</DebugType>\r\n    <Optimize>false</Optimize>\r\n    <OutputPath>bin\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|x64' \">\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <DebugType>pdbonly</DebugType>\r\n    <Optimize>true</Optimize>\r\n    <OutputPath>bin\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <AdditionalFileItemNames>$(AdditionalFileItemNames);None</AdditionalFileItemNames>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.Azure.KeyVault.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.Azure.KeyVault.Core.2.0.4\\lib\\net45\\Microsoft.Azure.KeyVault.Core.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.Data.Edm, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.Data.Edm.5.8.2\\lib\\net40\\Microsoft.Data.Edm.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.Data.OData, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.Data.OData.5.8.2\\lib\\net40\\Microsoft.Data.OData.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.Data.Services.Client, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.Data.Services.Client.5.8.2\\lib\\net40\\Microsoft.Data.Services.Client.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.WindowsAzure.Storage, Version=8.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\WindowsAzure.Storage.8.1.1\\lib\\net45\\Microsoft.WindowsAzure.Storage.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Newtonsoft.Json.10.0.2\\lib\\net45\\Newtonsoft.Json.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.configuration\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Data\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.IO.Compression\" />\r\n    <Reference Include=\"System.IO.Compression.FileSystem\" />\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n    <Reference Include=\"System.Spatial, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\System.Spatial.5.8.2\\lib\\net40\\System.Spatial.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"LocalBackupStore.cs\" />\r\n    <Compile Include=\"AzureBackupStore.cs\" />\r\n    <Compile Include=\"IBackupStore.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n    <Compile Include=\"InventoryService.cs\" />\r\n    <Compile Include=\"Program.cs\" />\r\n    <Compile Include=\"ServiceEventSource.cs\" />\r\n    <Compile Include=\"StatefulServiceParameters.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"PackageRoot\\Config\\Settings.xml\" />\r\n    <None Include=\"PackageRoot\\ServiceManifest.xml\" />\r\n    <None Include=\"App.config\">\r\n      <SubType>Designer</SubType>\r\n    </None>\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\">\r\n      <Project>{7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae}</Project>\r\n      <Name>Inventory.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\RestockRequest.Domain\\RestockRequest.Domain.csproj\">\r\n      <Project>{a44fc2c5-6781-447e-80f5-7265b960b36a}</Project>\r\n      <Name>RestockRequest.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\RestockRequestManager.Domain\\RestockRequestManager.Domain.csproj\">\r\n      <Project>{4162f266-d657-4143-aa62-626c10d23561}</Project>\r\n      <Name>RestockRequestManager.Domain</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \n       Other similar extension points exist, see Microsoft.Common.targets.\n  <Target Name=\"BeforeBuild\">\n  </Target>\n  <Target Name=\"AfterBuild\">\n  </Target>\n  -->\r\n</Project>"
  },
  {
    "path": "ReferenceApp/Inventory.Service/InventoryService.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Service\r\n{\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Fabric;\r\n    using System.Fabric.Description;\r\n    using System.IO;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n    using Common;\r\n    using Inventory.Domain;\r\n    using Microsoft.ServiceFabric.Data;\r\n    using Microsoft.ServiceFabric.Data.Collections;\r\n    using Microsoft.ServiceFabric.Services.Client;\r\n    using Microsoft.ServiceFabric.Services.Communication.Runtime;\r\n    using Microsoft.ServiceFabric.Services.Remoting.Client;\r\n    using Microsoft.ServiceFabric.Services.Remoting.Runtime;\r\n    using Microsoft.ServiceFabric.Services.Runtime;\r\n    using RestockRequest.Domain;\r\n    using RestockRequestManager.Domain;\r\n\r\n    internal class InventoryService : StatefulService, IInventoryService\r\n    {\r\n        internal const string InventoryServiceType = \"InventoryServiceType\";\r\n        private const string InventoryItemDictionaryName = \"inventoryItems\";\r\n        private const string ActorMessageDictionaryName = \"incomingMessages\";\r\n        private const string RestockRequestManagerServiceName = \"RestockRequestManager\";\r\n        private const string RequestHistoryDictionaryName = \"RequestHistory\";\r\n        private const string BackupCountDictionaryName = \"BackupCountingDictionary\";\r\n\r\n        //private IReliableStateManager stateManager;\r\n        private IBackupStore backupManager;\r\n\r\n        //Set local or cloud backup, or none. Disabled is the default. Overridden by config.\r\n        private BackupManagerType backupStorageType;\r\n\r\n\r\n        /// <summary>\r\n        /// This constructor is used in unit tests to inject a different state manager for unit testing.\r\n        /// </summary>\r\n        /// <param name=\"stateManager\"></param>\r\n        public InventoryService(StatefulServiceContext serviceContext) : this(serviceContext, (new ReliableStateManager(serviceContext)))\r\n        {\r\n        }\r\n\r\n        public InventoryService(StatefulServiceContext context, IReliableStateManagerReplica stateManagerReplica) : base(context, stateManagerReplica)\r\n        {\r\n        }\r\n\r\n        /// <summary>\r\n        /// Used internally to generate inventory items and adds them to the ReliableDict we have.\r\n        /// </summary>\r\n        /// <param name=\"item\"></param>\r\n        /// <returns></returns>\r\n        public async Task<bool> CreateInventoryItemAsync(InventoryItem item)\r\n        {\r\n            IReliableDictionary<InventoryItemId, InventoryItem> inventoryItems =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<InventoryItemId, InventoryItem>>(InventoryItemDictionaryName);\r\n\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                await inventoryItems.AddAsync(tx, item.Id, item);\r\n                await tx.CommitAsync();\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Created inventory item: {0}\", item);\r\n            }\r\n\r\n            return true;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Tries to add the given quantity to the inventory item with the given ID without going over the maximum quantity allowed for an item.\r\n        /// </summary>\r\n        /// <param name=\"itemId\"></param>\r\n        /// <param name=\"quantity\"></param>\r\n        /// <returns>The quantity actually added to the item.</returns>\r\n        public async Task<int> AddStockAsync(InventoryItemId itemId, int quantity)\r\n        {\r\n            IReliableDictionary<InventoryItemId, InventoryItem> inventoryItems =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<InventoryItemId, InventoryItem>>(InventoryItemDictionaryName);\r\n\r\n            int quantityAdded = 0;\r\n\r\n            ServiceEventSource.Current.ServiceMessage(this, \"Received add stock request. Item: {0}. Quantity: {1}.\", itemId, quantity);\r\n\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                // Try to get the InventoryItem for the ID in the request.\r\n                ConditionalValue<InventoryItem> item = await inventoryItems.TryGetValueAsync(tx, itemId);\r\n\r\n                // We can only update the stock for InventoryItems in the system - we are not adding new items here.\r\n                if (item.HasValue)\r\n                {\r\n                    // Update the stock quantity of the item.\r\n                    // This only updates the copy of the Inventory Item that's in local memory here;\r\n                    // It's not yet saved in the dictionary.\r\n                    quantityAdded = item.Value.AddStock(quantity);\r\n\r\n                    // We have to store the item back in the dictionary in order to actually save it.\r\n                    // This will then replicate the updated item for\r\n                    await inventoryItems.SetAsync(tx, item.Value.Id, item.Value);\r\n                }\r\n\r\n                // nothing will happen unless we commit the transaction!\r\n                await tx.CommitAsync();\r\n\r\n                ServiceEventSource.Current.ServiceMessage(\r\n                    this,\r\n                    \"Add stock complete. Item: {0}. Added: {1}. Total: {2}\",\r\n                    item.Value.Id,\r\n                    quantityAdded,\r\n                    item.Value.AvailableStock);\r\n            }\r\n\r\n\r\n            return quantityAdded;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Removes the given quantity of stock from an in item in the inventory.\r\n        /// </summary>\r\n        /// <param name=\"request\"></param>\r\n        /// <returns>int: Returns the quantity removed from stock.</returns>\r\n        public async Task<int> RemoveStockAsync(InventoryItemId itemId, int quantity, CustomerOrderActorMessageId amId)\r\n        {\r\n            ServiceEventSource.Current.ServiceMessage(this, \"inside remove stock {0}|{1}\", amId.GetHashCode(), amId.GetHashCode());\r\n\r\n            IReliableDictionary<InventoryItemId, InventoryItem> inventoryItems =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<InventoryItemId, InventoryItem>>(InventoryItemDictionaryName);\r\n\r\n            IReliableDictionary<CustomerOrderActorMessageId, DateTime> recentRequests =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<CustomerOrderActorMessageId, DateTime>>(ActorMessageDictionaryName);\r\n\r\n            IReliableDictionary<CustomerOrderActorMessageId, Tuple<InventoryItemId, int>> requestHistory =\r\n                await\r\n                    this.StateManager.GetOrAddAsync<IReliableDictionary<CustomerOrderActorMessageId, Tuple<InventoryItemId, int>>>(RequestHistoryDictionaryName);\r\n\r\n            int removed = 0;\r\n\r\n            ServiceEventSource.Current.ServiceMessage(this, \"Received remove stock request. Item: {0}. Quantity: {1}.\", itemId, quantity);\r\n\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                //first let's see if this is a duplicate request\r\n                ConditionalValue<DateTime> previousRequest = await recentRequests.TryGetValueAsync(tx, amId);\r\n                if (!previousRequest.HasValue)\r\n                {\r\n                    //first time we've seen the request or it was a dupe from so long ago we have forgotten\r\n\r\n                    // Try to get the InventoryItem for the ID in the request.\r\n                    ConditionalValue<InventoryItem> item = await inventoryItems.TryGetValueAsync(tx, itemId);\r\n\r\n                    // We can only remove stock for InventoryItems in the system.\r\n                    if (item.HasValue)\r\n                    {\r\n                        // Update the stock quantity of the item.\r\n                        // This only updates the copy of the Inventory Item that's in local memory here;\r\n                        // It's not yet saved in the dictionary.\r\n                        removed = item.Value.RemoveStock(quantity);\r\n\r\n                        // We have to store the item back in the dictionary in order to actually save it.\r\n                        // This will then replicate the updated item\r\n                        await inventoryItems.SetAsync(tx, itemId, item.Value);\r\n\r\n                        //we also have to make a note that we have returned this result, so that we can protect\r\n                        //ourselves from stale or duplicate requests that come back later\r\n                        await requestHistory.SetAsync(tx, amId, new Tuple<InventoryItemId, int>(itemId, removed));\r\n\r\n                        ServiceEventSource.Current.ServiceMessage(\r\n                            this,\r\n                            \"Removed stock complete. Item: {0}. Removed: {1}. Remaining: {2}\",\r\n                            item.Value.Id,\r\n                            removed,\r\n                            item.Value.AvailableStock);\r\n                    }\r\n                }\r\n                else\r\n                {\r\n                    //this is a duplicate request. We need to send back the result we already came up with and hope they get it this time\r\n                    //find the previous result and send it back\r\n                    ConditionalValue<Tuple<InventoryItemId, int>> previousResponse = await requestHistory.TryGetValueAsync(tx, amId);\r\n\r\n                    if (previousResponse.HasValue)\r\n                    {\r\n                        removed = previousResponse.Value.Item2;\r\n                        ServiceEventSource.Current.ServiceMessage(\r\n                            this,\r\n                            \"Retrieved previous response for request {0}, from {1}, for Item {2} and quantity {3}\",\r\n                            amId,\r\n                            previousRequest.Value,\r\n                            previousResponse.Value.Item1,\r\n                            previousResponse.Value.Item2);\r\n                    }\r\n                    else\r\n                    {\r\n                        //we've seen the request before but we don't have a record for what we responded, inconsistent state\r\n                        ServiceEventSource.Current.ServiceMessage(\r\n                            this,\r\n                            \"Inconsistent State: recieved duplicate request {0} but don't have matching response in history\",\r\n                            amId);\r\n                        this.Partition.ReportFault(System.Fabric.FaultType.Transient);\r\n                    }\r\n\r\n\r\n                    //note about duplicate Requests: technically if a duplicate request comes in and we have \r\n                    //sufficient invintory to return more now that we did previously, we could return more of the order and decrement \r\n                    //the difference to reduce the total number of round trips. This optimization is not currently implemented\r\n                }\r\n\r\n\r\n                //always update the datetime for the given request\r\n                await recentRequests.SetAsync(tx, amId, DateTime.UtcNow);\r\n\r\n                // nothing will happen unless we commit the transaction!\r\n                ServiceEventSource.Current.Message(\"Committing Changes in Inventory Service\");\r\n                await tx.CommitAsync();\r\n                ServiceEventSource.Current.Message(\"Inventory Service Changes Committed\");\r\n            }\r\n\r\n            ServiceEventSource.Current.Message(\"Removed {0} of item {1}\", removed, itemId);\r\n            return removed;\r\n        }\r\n\r\n        public async Task<bool> IsItemInInventoryAsync(InventoryItemId itemId, CancellationToken ct)\r\n        {\r\n            ServiceEventSource.Current.Message(\"checking item {0} to see if it is in inventory\", itemId);\r\n            IReliableDictionary<InventoryItemId, InventoryItem> inventoryItems =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<InventoryItemId, InventoryItem>>(InventoryItemDictionaryName);\r\n\r\n            await this.PrintInventoryItemsAsync(inventoryItems, ct);\r\n\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                ConditionalValue<InventoryItem> item = await inventoryItems.TryGetValueAsync(tx, itemId);\r\n                return item.HasValue;\r\n            }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Retrieves a customer-specific view (defined in the InventoryItemView class in the Fabrikam Common namespace)\r\n        /// of all items in the IReliableDictionary in InventoryService. Only items with a CustomerAvailableStock greater than\r\n        /// zero are returned as a business logic constraint to reduce overordering. \r\n        /// </summary>\r\n        /// <returns>IEnumerable of InventoryItemView</returns>\r\n        public async Task<IEnumerable<InventoryItemView>> GetCustomerInventoryAsync(CancellationToken ct)\r\n        {\r\n            IReliableDictionary<InventoryItemId, InventoryItem> inventoryItems =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<InventoryItemId, InventoryItem>>(InventoryItemDictionaryName);\r\n\r\n            ServiceEventSource.Current.Message(\"Called GetCustomerInventory to return InventoryItemView\");\r\n\r\n            await this.PrintInventoryItemsAsync(inventoryItems, ct);\r\n\r\n            IList<InventoryItemView> results = new List<InventoryItemView>();\r\n\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                ServiceEventSource.Current.Message(\"Generating item views for {0} items\", await inventoryItems.GetCountAsync(tx));\r\n\r\n                IAsyncEnumerator<KeyValuePair<InventoryItemId, InventoryItem>> enumerator =\r\n                    (await inventoryItems.CreateEnumerableAsync(tx)).GetAsyncEnumerator();\r\n\r\n                while (await enumerator.MoveNextAsync(ct))\r\n                {\r\n                    if (enumerator.Current.Value.AvailableStock > 0)\r\n                    {\r\n                        results.Add(enumerator.Current.Value);\r\n                    }\r\n                }\r\n            }\r\n\r\n\r\n            return results;\r\n        }\r\n\r\n        /// <summary>\r\n        /// NOTE: This should not be used in published MVP code. \r\n        /// This function allows us to remove inventory items from inventory.\r\n        /// </summary>\r\n        /// <param name=\"itemId\"></param>\r\n        /// <returns></returns>\r\n        public async Task DeleteInventoryItemAsync(InventoryItemId itemId)\r\n        {\r\n            IReliableDictionary<InventoryItemId, InventoryItem> inventoryItems =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<InventoryItemId, InventoryItem>>(InventoryItemDictionaryName);\r\n\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                await inventoryItems.TryRemoveAsync(tx, itemId);\r\n                await tx.CommitAsync();\r\n            }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Creates a new communication listener\r\n        /// </summary>\r\n        /// <returns></returns>\r\n        protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()\r\n        {\r\n            return new[]\r\n            {\r\n                new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context))\r\n            };\r\n        }\r\n\r\n        //Dataloss testing can be triggered via powershell. To do so, run the following commands as a script\r\n        //Connect-ServiceFabricCluster\r\n        //$s = \"fabric:/WebReferenceApplication/InventoryService\"\r\n        //$p = Get-ServiceFabricApplication | Get-ServiceFabricService -ServiceName $s | Get-ServiceFabricPartition | Select -First 1\r\n        //$p | Invoke-ServiceFabricPartitionDataLoss -DataLossMode FullDataLoss -ServiceName $s\r\n\r\n        protected override async Task<bool> OnDataLossAsync(RestoreContext restoreCtx, CancellationToken cancellationToken)\r\n        {\r\n            ServiceEventSource.Current.ServiceMessage(this, \"OnDataLoss Invoked!\");\r\n            this.SetupBackupManager();\r\n\r\n            try\r\n            {\r\n                string backupFolder;\r\n\r\n                if (this.backupStorageType == BackupManagerType.None)\r\n                {\r\n                    //since we have no backup configured, we return false to indicate\r\n                    //that state has not changed. This replica will become the basis\r\n                    //for future replica builds\r\n                    return false;\r\n                }\r\n                else\r\n                {\r\n                    backupFolder = await this.backupManager.RestoreLatestBackupToTempLocation(cancellationToken);\r\n                }\r\n\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Restoration Folder Path \" + backupFolder);\r\n\r\n                RestoreDescription restoreRescription = new RestoreDescription(backupFolder, RestorePolicy.Force);\r\n\r\n                await restoreCtx.RestoreAsync(restoreRescription, cancellationToken);\r\n\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Restore completed\");\r\n\r\n                DirectoryInfo tempRestoreDirectory = new DirectoryInfo(backupFolder);\r\n                tempRestoreDirectory.Delete(true);\r\n\r\n                return true;\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Restoration failed: \" + \"{0} {1}\" + e.GetType() + e.Message);\r\n\r\n                throw;\r\n            }\r\n        }\r\n\r\n\r\n        protected override Task RunAsync(CancellationToken cancellationToken)\r\n        {\r\n            try\r\n            {\r\n                ServiceEventSource.Current.ServiceMessage(this, \"inside RunAsync for Inventory Service\");\r\n\r\n                return Task.WhenAll(\r\n                    this.PeriodicInventoryCheck(cancellationToken),\r\n                    this.PeriodicOldMessageTrimming(cancellationToken),\r\n                    this.PeriodicTakeBackupAsync(cancellationToken));\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ServiceEventSource.Current.ServiceMessage(this, \"RunAsync Failed, {0}\", e);\r\n                throw;\r\n            }\r\n        }\r\n\r\n\r\n        private async Task<bool> BackupCallbackAsync(BackupInfo backupInfo, CancellationToken cancellationToken)\r\n        {\r\n            ServiceEventSource.Current.ServiceMessage(this, \"Inside backup callback for replica {0}|{1}\", this.Context.PartitionId, this.Context.ReplicaId);\r\n            long totalBackupCount;\r\n\r\n            IReliableDictionary<string, long> backupCountDictionary =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<string, long>>(BackupCountDictionaryName);\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                ConditionalValue<long> value = await backupCountDictionary.TryGetValueAsync(tx, \"backupCount\");\r\n\r\n                if (!value.HasValue)\r\n                {\r\n                    totalBackupCount = 0;\r\n                }\r\n                else\r\n                {\r\n                    totalBackupCount = value.Value;\r\n                }\r\n\r\n                await backupCountDictionary.SetAsync(tx, \"backupCount\", ++totalBackupCount);\r\n\r\n                await tx.CommitAsync();\r\n            }\r\n\r\n            ServiceEventSource.Current.Message(\"Backup count dictionary updated, total backup count is {0}\", totalBackupCount);\r\n\r\n            try\r\n            {\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Archiving backup\");\r\n                await this.backupManager.ArchiveBackupAsync(backupInfo, cancellationToken);\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Backup archived\");\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Archive of backup failed: Source: {0} Exception: {1}\", backupInfo.Directory, e.Message);\r\n            }\r\n\r\n            await this.backupManager.DeleteBackupsAsync(cancellationToken);\r\n\r\n            ServiceEventSource.Current.Message(\"Backups deleted\");\r\n\r\n            return true;\r\n        }\r\n\r\n        private async Task PrintInventoryItemsAsync(IReliableDictionary<InventoryItemId, InventoryItem> inventoryItems, CancellationToken cancellationToken)\r\n        {\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                ServiceEventSource.Current.Message(\"Printing Inventory for {0} items:\", await inventoryItems.GetCountAsync(tx));\r\n\r\n                IAsyncEnumerator<KeyValuePair<InventoryItemId, InventoryItem>> enumerator =\r\n                    (await inventoryItems.CreateEnumerableAsync(tx)).GetAsyncEnumerator();\r\n\r\n                while (await enumerator.MoveNextAsync(cancellationToken))\r\n                {\r\n                    ServiceEventSource.Current.Message(\"ID:{0}|Item:{1}\", enumerator.Current.Key, enumerator.Current.Value);\r\n                }\r\n            }\r\n        }\r\n\r\n        private async Task PeriodicOldMessageTrimming(CancellationToken cancellationToken)\r\n        {\r\n            IReliableDictionary<CustomerOrderActorMessageId, DateTime> recentRequests =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<CustomerOrderActorMessageId, DateTime>>(ActorMessageDictionaryName);\r\n\r\n            IReliableDictionary<CustomerOrderActorMessageId, Tuple<InventoryItemId, int>> requestHistory =\r\n                await\r\n                    this.StateManager.GetOrAddAsync<IReliableDictionary<CustomerOrderActorMessageId, Tuple<InventoryItemId, int>>>(RequestHistoryDictionaryName);\r\n\r\n            while (!cancellationToken.IsCancellationRequested)\r\n            {\r\n                using (ITransaction tx = this.StateManager.CreateTransaction())\r\n                {\r\n                    IAsyncEnumerator<KeyValuePair<CustomerOrderActorMessageId, DateTime>> enumerator =\r\n                        (await recentRequests.CreateEnumerableAsync(tx)).GetAsyncEnumerator();\r\n\r\n                    while (await enumerator.MoveNextAsync(cancellationToken))\r\n                    {\r\n                        //if we have a record of a message that is older than 2 hours from current time, then remove that record\r\n                        //from both of the stale message tracking dictionaries.\r\n                        if (enumerator.Current.Value < (DateTime.UtcNow.AddHours(-2)))\r\n                        {\r\n                            await recentRequests.TryRemoveAsync(tx, enumerator.Current.Key);\r\n                            await requestHistory.TryRemoveAsync(tx, enumerator.Current.Key);\r\n                        }\r\n                    }\r\n\r\n                    await tx.CommitAsync();\r\n                }\r\n\r\n                //sleep for 5 minutes then scan again\r\n                await Task.Delay(TimeSpan.FromMinutes(5), cancellationToken);\r\n            }\r\n        }\r\n\r\n        private async Task PeriodicInventoryCheck(CancellationToken cancellationToken)\r\n        {\r\n            IReliableDictionary<InventoryItemId, InventoryItem> inventoryItems =\r\n                await this.StateManager.GetOrAddAsync<IReliableDictionary<InventoryItemId, InventoryItem>>(InventoryItemDictionaryName);\r\n\r\n            while (true)\r\n            {\r\n                cancellationToken.ThrowIfCancellationRequested();\r\n\r\n                IList<InventoryItem> items = new List<InventoryItem>();\r\n\r\n                using (ITransaction tx = this.StateManager.CreateTransaction())\r\n                {\r\n                    ServiceEventSource.Current.ServiceMessage(this, \"Checking inventory stock for {0} items.\", await inventoryItems.GetCountAsync(tx));\r\n\r\n                    IAsyncEnumerator<KeyValuePair<InventoryItemId, InventoryItem>> enumerator =\r\n                        (await inventoryItems.CreateEnumerableAsync(tx)).GetAsyncEnumerator();\r\n\r\n                    while (await enumerator.MoveNextAsync(cancellationToken))\r\n                    {\r\n                        InventoryItem item = enumerator.Current.Value;\r\n\r\n                        //Check if stock is below restockThreshold and if the item is not already on reorder\r\n                        if ((item.AvailableStock <= item.RestockThreshold) && !item.OnReorder)\r\n                        {\r\n                            items.Add(enumerator.Current.Value);\r\n                        }\r\n                    }\r\n                }\r\n\r\n                foreach (InventoryItem item in items)\r\n                {\r\n                    cancellationToken.ThrowIfCancellationRequested();\r\n\r\n                    try\r\n                    {\r\n                        ServiceUriBuilder builder = new ServiceUriBuilder(RestockRequestManagerServiceName);\r\n\r\n                        IRestockRequestManager restockRequestManagerClient = ServiceProxy.Create<IRestockRequestManager>(\r\n                            builder.ToUri(),\r\n                            new ServicePartitionKey());\r\n\r\n                        // we reduce the quantity passed in to RestockRequest to ensure we don't overorder   \r\n                        RestockRequest newRequest = new RestockRequest(item.Id, (item.MaxStockThreshold - item.AvailableStock));\r\n\r\n                        InventoryItem updatedItem = new InventoryItem(\r\n                            item.Description,\r\n                            item.Price,\r\n                            item.AvailableStock,\r\n                            item.RestockThreshold,\r\n                            item.MaxStockThreshold,\r\n                            item.Id,\r\n                            true);\r\n\r\n                        // TODO: this call needs to be idempotent in case we fail to update the InventoryItem after this completes.\r\n                        await restockRequestManagerClient.AddRestockRequestAsync(newRequest);\r\n\r\n                        // Write operations take an exclusive lock on an item, which means we can't do anything else with that item while the transaction is open.\r\n                        // If something blocks before the transaction is committed, the open transaction on the item will prevent all operations on it, including reads.\r\n                        // Once the transaction commits, the lock is released and other operations on the item can proceed.\r\n                        // Operations on the transaction all have timeouts to prevent deadlocking an item, \r\n                        // but we should do as little work inside the transaction as possible that is not related to the transaction itself.\r\n                        using (ITransaction tx = this.StateManager.CreateTransaction())\r\n                        {\r\n                            await inventoryItems.TryUpdateAsync(tx, item.Id, updatedItem, item);\r\n\r\n                            await tx.CommitAsync();\r\n                        }\r\n\r\n                        ServiceEventSource.Current.ServiceMessage(\r\n                            this,\r\n                            \"Restock order placed. Item ID: {0}. Quantity: {1}\",\r\n                            newRequest.ItemId,\r\n                            newRequest.Quantity);\r\n                    }\r\n                    catch (Exception e)\r\n                    {\r\n                        ServiceEventSource.Current.ServiceMessage(this, \"Failed to place restock order for item {0}. {1}\", item.Id, e.ToString());\r\n                    }\r\n                }\r\n\r\n                await Task.Delay(TimeSpan.FromSeconds(30), cancellationToken);\r\n            }\r\n        }\r\n\r\n        private async Task PeriodicTakeBackupAsync(CancellationToken cancellationToken)\r\n        {\r\n            long backupsTaken = 0;\r\n            this.SetupBackupManager();\r\n\r\n            while (true)\r\n            {\r\n                cancellationToken.ThrowIfCancellationRequested();\r\n                if (this.backupStorageType == BackupManagerType.None)\r\n                {\r\n                    break;\r\n                }\r\n                else\r\n                {\r\n                    await Task.Delay(TimeSpan.FromSeconds(this.backupManager.backupFrequencyInSeconds));\r\n\r\n\r\n                    BackupDescription backupDescription = new BackupDescription(BackupOption.Full, this.BackupCallbackAsync);\r\n\r\n                    await this.BackupAsync(backupDescription, TimeSpan.FromHours(1), cancellationToken);\r\n\r\n                    backupsTaken++;\r\n\r\n                    ServiceEventSource.Current.ServiceMessage(this, \"Backup {0} taken\", backupsTaken);\r\n                }\r\n            }\r\n        }\r\n\r\n        private void SetupBackupManager()\r\n        {\r\n            string partitionId = this.Context.PartitionId.ToString(\"N\");\r\n            long minKey = ((Int64RangePartitionInformation) this.Partition.PartitionInfo).LowKey;\r\n            long maxKey = ((Int64RangePartitionInformation) this.Partition.PartitionInfo).HighKey;\r\n\r\n            if (this.Context.CodePackageActivationContext != null)\r\n            {\r\n                ICodePackageActivationContext codePackageContext = this.Context.CodePackageActivationContext;\r\n                ConfigurationPackage configPackage = codePackageContext.GetConfigurationPackageObject(\"Config\");\r\n                ConfigurationSection configSection = configPackage.Settings.Sections[\"Inventory.Service.Settings\"];\r\n\r\n                string backupSettingValue = configSection.Parameters[\"BackupMode\"].Value;\r\n\r\n                if (string.Equals(backupSettingValue, \"none\", StringComparison.InvariantCultureIgnoreCase))\r\n                {\r\n                    this.backupStorageType = BackupManagerType.None;\r\n                }\r\n                else if (string.Equals(backupSettingValue, \"azure\", StringComparison.InvariantCultureIgnoreCase))\r\n                {\r\n                    this.backupStorageType = BackupManagerType.Azure;\r\n\r\n                    ConfigurationSection azureBackupConfigSection = configPackage.Settings.Sections[\"Inventory.Service.BackupSettings.Azure\"];\r\n\r\n                    this.backupManager = new AzureBlobBackupManager(azureBackupConfigSection, partitionId, minKey, maxKey, codePackageContext.TempDirectory);\r\n                }\r\n                else if (string.Equals(backupSettingValue, \"local\", StringComparison.InvariantCultureIgnoreCase))\r\n                {\r\n                    this.backupStorageType = BackupManagerType.Local;\r\n\r\n                    ConfigurationSection localBackupConfigSection = configPackage.Settings.Sections[\"Inventory.Service.BackupSettings.Local\"];\r\n\r\n                    this.backupManager = new DiskBackupManager(localBackupConfigSection, partitionId, minKey, maxKey, codePackageContext.TempDirectory);\r\n                }\r\n                else\r\n                {\r\n                    throw new ArgumentException(\"Unknown backup type\");\r\n                }\r\n\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Backup Manager Set Up\");\r\n            }\r\n        }\r\n\r\n        private enum BackupManagerType\r\n        {\r\n            Azure,\r\n            Local,\r\n            None\r\n        };\r\n    }\r\n}\r\n"
  },
  {
    "path": "ReferenceApp/Inventory.Service/LocalBackupStore.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Service\r\n{\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Fabric.Description;\r\n    using System.IO;\r\n    using System.IO.Compression;\r\n    using System.Linq;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Data;\r\n\r\n    public class DiskBackupManager : IBackupStore\r\n    {\r\n        private string PartitionArchiveFolder;\r\n        private string PartitionTempDirectory;\r\n        private long backupFrequencyInSeconds;\r\n        private int MaxBackupsToKeep;\r\n        private long keyMin;\r\n        private long keyMax;\r\n\r\n        public DiskBackupManager(ConfigurationSection configSection, string partitionId, long keymin, long keymax, string codePackageTempDirectory)\r\n        {\r\n            this.keyMin = keymin;\r\n            this.keyMax = keymax;\r\n\r\n            string BackupArchivalPath = configSection.Parameters[\"BackupArchivalPath\"].Value;\r\n            this.backupFrequencyInSeconds = long.Parse(configSection.Parameters[\"BackupFrequencyInSeconds\"].Value);\r\n            this.MaxBackupsToKeep = int.Parse(configSection.Parameters[\"MaxBackupsToKeep\"].Value);\r\n\r\n            this.PartitionArchiveFolder = Path.Combine(BackupArchivalPath, \"Backups\", partitionId);\r\n            this.PartitionTempDirectory = Path.Combine(codePackageTempDirectory, partitionId);\r\n\r\n            ServiceEventSource.Current.Message(\r\n                \"DiskBackupManager constructed IntervalinSec:{0}, archivePath:{1}, tempPath:{2}, backupsToKeep:{3}\",\r\n                this.backupFrequencyInSeconds,\r\n                this.PartitionArchiveFolder,\r\n                this.PartitionTempDirectory,\r\n                this.MaxBackupsToKeep);\r\n        }\r\n\r\n        long IBackupStore.backupFrequencyInSeconds\r\n        {\r\n            get { return this.backupFrequencyInSeconds; }\r\n        }\r\n\r\n        public Task ArchiveBackupAsync(BackupInfo backupInfo, CancellationToken cancellationToken)\r\n        {\r\n            string fullArchiveDirectory = Path.Combine(\r\n                this.PartitionArchiveFolder,\r\n                string.Format(\"{0}_{1}_{2}\", Guid.NewGuid().ToString(\"N\"), this.keyMin, this.keyMax));\r\n\r\n            DirectoryInfo dirInfo = new DirectoryInfo(fullArchiveDirectory);\r\n            dirInfo.Create();\r\n\r\n            string fullArchivePath = Path.Combine(fullArchiveDirectory, \"Backup.zip\");\r\n\r\n            ZipFile.CreateFromDirectory(backupInfo.Directory, fullArchivePath, CompressionLevel.Fastest, false);\r\n\r\n            DirectoryInfo backupDirectory = new DirectoryInfo(backupInfo.Directory);\r\n            backupDirectory.Delete(true);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task<string> RestoreLatestBackupToTempLocation(CancellationToken cancellationToken)\r\n        {\r\n            ServiceEventSource.Current.Message(\"Restoring backup to temp source:{0} destination:{1}\", this.PartitionArchiveFolder, this.PartitionTempDirectory);\r\n\r\n            DirectoryInfo dirInfo = new DirectoryInfo(this.PartitionArchiveFolder);\r\n\r\n            string backupZip = dirInfo.GetDirectories().OrderByDescending(x => x.LastWriteTime).First().FullName;\r\n\r\n            string zipPath = Path.Combine(backupZip, \"Backup.zip\");\r\n\r\n            ServiceEventSource.Current.Message(\"latest zip backup is {0}\", zipPath);\r\n\r\n            DirectoryInfo directoryInfo = new DirectoryInfo(this.PartitionTempDirectory);\r\n            if (directoryInfo.Exists)\r\n            {\r\n                directoryInfo.Delete(true);\r\n            }\r\n\r\n            directoryInfo.Create();\r\n\r\n            ZipFile.ExtractToDirectory(zipPath, this.PartitionTempDirectory);\r\n\r\n            ServiceEventSource.Current.Message(\"Zip backup {0} extracted to {1}\", zipPath, this.PartitionTempDirectory);\r\n\r\n            return Task.FromResult<string>(this.PartitionTempDirectory);\r\n        }\r\n\r\n        public async Task DeleteBackupsAsync(CancellationToken cancellationToken)\r\n        {\r\n            await Task.Run(\r\n                () =>\r\n                {\r\n                    ServiceEventSource.Current.Message(\"deleting old backups\");\r\n\r\n                    if (!Directory.Exists(this.PartitionArchiveFolder))\r\n                    {\r\n                        //Nothing to delete; Backups may not even have been created for the partition\r\n                        return;\r\n                    }\r\n\r\n                    DirectoryInfo dirInfo = new DirectoryInfo(this.PartitionArchiveFolder);\r\n\r\n                    IEnumerable<DirectoryInfo> oldBackups = dirInfo.GetDirectories().OrderByDescending(x => x.LastWriteTime).Skip(this.MaxBackupsToKeep);\r\n\r\n                    foreach (DirectoryInfo oldBackup in oldBackups)\r\n                    {\r\n                        ServiceEventSource.Current.Message(\"Deleting old backup {0}\", oldBackup.FullName);\r\n                        oldBackup.Delete(true);\r\n                    }\r\n\r\n                    ServiceEventSource.Current.Message(\"Old backups deleted\");\r\n\r\n                    return;\r\n                },\r\n                cancellationToken);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Service/PackageRoot/Config/Settings.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<Settings xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\n  <!-- This is used by the StateManager's replicator. -->\n  <Section Name=\"ReplicatorConfig\">\n    <Parameter Name=\"ReplicatorEndpoint\" Value=\"ReplicatorEndpoint\" />\n  </Section>\n  <Section Name=\"Inventory.Service.Settings\">\n    <Parameter Name=\"BackupMode\" Value=\"none\" />\n  </Section>\n  <Section Name=\"Inventory.Service.BackupSettings.Azure\">\n    <Parameter Name=\"BackupAccountName\" Value=\"\" />\n    <Parameter Name=\"PrimaryKeyForBackupTestAccount\" Value=\"\" />\n    <Parameter Name=\"BlobServiceEndpointAddress\" Value=\"\" />\n    <Parameter Name=\"BackupFrequencyInSeconds\" Value=\"30\" />\n    <Parameter Name=\"MaxBackupsToKeep\" Value=\"5\" />\n  </Section>\n  <Section Name=\"Inventory.Service.BackupSettings.Local\">\n    <Parameter Name=\"BackupArchivalPath\" Value=\"C:\\temp\" />\n    <Parameter Name=\"BackupFrequencyInSeconds\" Value=\"10\" />\n    <Parameter Name=\"MaxBackupsToKeep\" Value=\"5\" />\n  </Section>\n\n</Settings>\n"
  },
  {
    "path": "ReferenceApp/Inventory.Service/PackageRoot/ServiceManifest.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ServiceManifest Name=\"Inventory.ServicePkg\"\n                 Version=\"1.0.0\"\n                 xmlns=\"http://schemas.microsoft.com/2011/01/fabric\"\n                 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n                 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n  <ServiceTypes>\n    <!-- This is the name of your ServiceType. \n         This name must match the string used in RegisterServiceType call in Program.cs. -->\n    <StatefulServiceType ServiceTypeName=\"InventoryServiceType\" HasPersistedState=\"true\" />\n  </ServiceTypes>\n\n  <!-- Code package is your service executable. -->\n  <CodePackage Name=\"Code\" Version=\"1.0.0\">\n    <EntryPoint>\n      <ExeHost>\n        <Program>Inventory.Service.exe</Program>\n      </ExeHost>\n    </EntryPoint>\n  </CodePackage>\n\n  <!-- Config package is the contents of the Config directoy under PackageRoot that contains an \n       independently-updateable and versioned set of custom configuration settings for your service. -->\n  <ConfigPackage Name=\"Config\" Version=\"1.0.0\" />\n\n  <Resources>\n    <Endpoints>\n      <!-- This endpoint is used by the communication listener to obtain the port on which to \n           listen. Please note that if your service is partitioned, this port is shared with \n           replicas of different partitions that are placed in your code. -->\n      <Endpoint Name=\"ServiceEndpoint\" />\n\n      <!-- This endpoint is used by the replicator for replicating the state of your service.\n           This endpoint is configured through a ReplicatorSettings config section in the Settings.xml\n           file under the ConfigPackage. -->\n      <Endpoint Name=\"ReplicatorEndpoint\" />\n    </Endpoints>\n  </Resources>\n</ServiceManifest>\n"
  },
  {
    "path": "ReferenceApp/Inventory.Service/Program.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Service\r\n{\r\n    using System;\r\n    using System.Diagnostics;\r\n    using System.Threading;\r\n    using Microsoft.ServiceFabric.Services.Runtime;\r\n\r\n    public class Program\r\n    {\r\n        public static void Main(string[] args)\r\n        {\r\n            try\r\n            {\r\n                ServiceRuntime.RegisterServiceAsync(InventoryService.InventoryServiceType, (context) => new InventoryService(context)).GetAwaiter().GetResult();\r\n\r\n                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(InventoryService).Name);\r\n\r\n                Thread.Sleep(Timeout.Infinite);\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());\r\n                throw;\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Service/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.CompilerServices;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"InventoryService\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"InventoryService\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"714b1c61-ffa8-4a5e-8dd2-d0a290677293\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]\r\n[assembly: InternalsVisibleTo(\"Inventory.UnitTests\")]"
  },
  {
    "path": "ReferenceApp/Inventory.Service/ServiceEventSource.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Service\r\n{\r\n    using System;\r\n    using System.Diagnostics.Tracing;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Services.Runtime;\r\n\r\n    [EventSource(Name = \"MyCompany-Web_UIApplication-InventoryService\")]\r\n    internal sealed class ServiceEventSource : EventSource\r\n    {\r\n        private const int MessageEventId = 1;\r\n\r\n        // For very high-frequency events it might be advantageous to raise events using WriteEventCore API.\r\n        // This results in more efficient parameter handling, but requires explicit allocation of EventData structure and unsafe code.\r\n        // To enable this code path, define UNSAFE conditional compilation symbol and turn on unsafe code support in project properties.\r\n        private const int ServiceMessageEventId = 2;\r\n\r\n        private const int ServiceTypeRegisteredEventId = 3;\r\n\r\n        private const int ServiceHostInitializationFailedEventId = 4;\r\n\r\n        // A pair of events sharing the same name prefix with a \"Start\"/\"Stop\" suffix implicitly marks boundaries of an event tracing activity.\r\n        // These activities can be automatically picked up by debugging and profiling tools, which can compute their execution time, child activities,\r\n        // and other statistics.\r\n        private const int ServiceRequestStartEventId = 5;\r\n\r\n        private const int ServiceRequestStopEventId = 6;\r\n\r\n        private const int ServiceRequestFailedEventId = 7;\r\n        public static readonly ServiceEventSource Current = new ServiceEventSource();\r\n\r\n        static ServiceEventSource()\r\n        {\r\n            // A workaround for the problem where ETW activities do not get tracked until Tasks infrastructure is initialized.\r\n            // This problem will be fixed in .NET Framework 4.6.2.\r\n            Task.Run(() => { }).Wait();\r\n        }\r\n\r\n        // Instance constructor is private to enforce singleton semantics\r\n        private ServiceEventSource() : base()\r\n        {\r\n        }\r\n\r\n        // Define an instance method for each event you want to record and apply an [Event] attribute to it.\r\n        // The method name is the name of the event.\r\n        // Pass any parameters you want to record with the event (only primitive integer types, DateTime, Guid & string are allowed).\r\n        // Each event method implementation should check whether the event source is enabled, and if it is, call WriteEvent() method to raise the event.\r\n        // The number and types of arguments passed to every event method must exactly match what is passed to WriteEvent().\r\n        // Put [NonEvent] attribute on all methods that do not define an event.\r\n        // For more information see https://msdn.microsoft.com/en-us/library/system.diagnostics.tracing.eventsource.aspx\r\n\r\n        [NonEvent]\r\n        public void Message(string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                this.Message(finalMessage);\r\n            }\r\n        }\r\n\r\n        [Event(MessageEventId, Level = EventLevel.Informational, Message = \"{0}\")]\r\n        public void Message(string message)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                this.WriteEvent(MessageEventId, message);\r\n            }\r\n        }\r\n\r\n        [NonEvent]\r\n        public void ServiceMessage(StatefulService service, string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                this.ServiceMessage(\r\n                    service.Context.ServiceName.ToString(),\r\n                    service.Context.ServiceTypeName,\r\n                    service.Context.ReplicaId,\r\n                    service.Context.PartitionId,\r\n                    service.Context.CodePackageActivationContext.ApplicationName,\r\n                    service.Context.CodePackageActivationContext.ApplicationTypeName,\r\n                    service.Context.NodeContext.NodeName,\r\n                    finalMessage);\r\n            }\r\n        }\r\n\r\n        [Event(ServiceTypeRegisteredEventId, Level = EventLevel.Informational, Message = \"Service host process {0} registered service type {1}\",\r\n            Keywords = Keywords.ServiceInitialization)]\r\n        public void ServiceTypeRegistered(int hostProcessId, string serviceType)\r\n        {\r\n            this.WriteEvent(ServiceTypeRegisteredEventId, hostProcessId, serviceType);\r\n        }\r\n\r\n        [Event(ServiceHostInitializationFailedEventId, Level = EventLevel.Error, Message = \"Service host initialization failed\",\r\n            Keywords = Keywords.ServiceInitialization)]\r\n        public void ServiceHostInitializationFailed(string exception)\r\n        {\r\n            this.WriteEvent(ServiceHostInitializationFailedEventId, exception);\r\n        }\r\n\r\n        [Event(ServiceRequestStartEventId, Level = EventLevel.Informational, Message = \"Service request '{0}' started\", Keywords = Keywords.Requests)]\r\n        public void ServiceRequestStart(string requestTypeName)\r\n        {\r\n            this.WriteEvent(ServiceRequestStartEventId, requestTypeName);\r\n        }\r\n\r\n        [Event(ServiceRequestStopEventId, Level = EventLevel.Informational, Message = \"Service request '{0}' finished\", Keywords = Keywords.Requests)]\r\n        public void ServiceRequestStop(string requestTypeName)\r\n        {\r\n            this.WriteEvent(ServiceRequestStopEventId, requestTypeName);\r\n        }\r\n\r\n        [Event(ServiceRequestFailedEventId, Level = EventLevel.Error, Message = \"Service request '{0}' failed\", Keywords = Keywords.Requests)]\r\n        public void ServiceRequestFailed(string requestTypeName, string exception)\r\n        {\r\n            this.WriteEvent(ServiceRequestFailedEventId, exception);\r\n        }\r\n\r\n        [Event(ServiceMessageEventId, Level = EventLevel.Informational, Message = \"{7}\")]\r\n        private void ServiceMessage(\r\n            string serviceName,\r\n            string serviceTypeName,\r\n            long replicaOrInstanceId,\r\n            Guid partitionId,\r\n            string applicationName,\r\n            string applicationTypeName,\r\n            string nodeName,\r\n            string message)\r\n        {\r\n            this.WriteEvent(\r\n                ServiceMessageEventId,\r\n                serviceName,\r\n                serviceTypeName,\r\n                replicaOrInstanceId,\r\n                partitionId,\r\n                applicationName,\r\n                applicationTypeName,\r\n                nodeName,\r\n                message);\r\n        }\r\n\r\n        // Event keywords can be used to categorize events. \r\n        // Each keyword is a bit flag. A single event can be associated with multiple keywords (via EventAttribute.Keywords property).\r\n        // Keywords must be defined as a public class named 'Keywords' inside EventSource that uses them.\r\n        public static class Keywords\r\n        {\r\n            public const EventKeywords Requests = (EventKeywords) 0x1L;\r\n            public const EventKeywords ServiceInitialization = (EventKeywords) 0x2L;\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Service/StatefulServiceParameters.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.Service\r\n{\r\n    using System;\r\n    using System.Fabric;\r\n\r\n    internal class StatefulServiceParameters\r\n    {\r\n        public StatefulServiceParameters(\r\n            CodePackageActivationContext codePackageActivationContext, byte[] initializationData, Guid partitionId, Uri serviceName, string serviceTypeName,\r\n            long replicaId)\r\n        {\r\n            this.CodePackageActivationContext = codePackageActivationContext;\r\n            this.InitializationData = initializationData;\r\n            this.PartitionId = partitionId;\r\n            this.ServiceName = serviceName;\r\n            this.ServiceTypeName = serviceTypeName;\r\n            this.ReplicaId = replicaId;\r\n        }\r\n\r\n        public CodePackageActivationContext CodePackageActivationContext { get; }\r\n\r\n        public byte[] InitializationData { get; }\r\n\r\n        public Guid PartitionId { get; }\r\n\r\n        public long ReplicaId { get; }\r\n\r\n        public Uri ServiceName { get; }\r\n\r\n        public string ServiceTypeName { get; }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.Service/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.Azure.KeyVault.Core\" version=\"2.0.4\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.Data.Edm\" version=\"5.8.2\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.Data.OData\" version=\"5.8.2\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.Data.Services.Client\" version=\"5.8.2\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Newtonsoft.Json\" version=\"10.0.2\" targetFramework=\"net452\" />\r\n  <package id=\"System.ComponentModel.EventBasedAsync\" version=\"4.3.0\" targetFramework=\"net452\" />\r\n  <package id=\"System.Dynamic.Runtime\" version=\"4.3.0\" targetFramework=\"net452\" />\r\n  <package id=\"System.Linq.Queryable\" version=\"4.3.0\" targetFramework=\"net452\" />\r\n  <package id=\"System.Net.Requests\" version=\"4.3.0\" targetFramework=\"net452\" />\r\n  <package id=\"System.Spatial\" version=\"5.8.2\" targetFramework=\"net452\" />\r\n  <package id=\"WindowsAzure.Storage\" version=\"8.1.1\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/Inventory.UnitTests/Inventory.UnitTests.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\r\n    <ProjectGuid>{71E58E09-BEE4-4B19-BCF7-4C9BD71514FB}</ProjectGuid>\r\n    <OutputType>Library</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>Inventory.UnitTests</RootNamespace>\r\n    <AssemblyName>Inventory.UnitTests</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\r\n    <VisualStudioVersion Condition=\"'$(VisualStudioVersion)' == ''\">10.0</VisualStudioVersion>\r\n    <VSToolsPath Condition=\"'$(VSToolsPath)' == ''\">$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)</VSToolsPath>\r\n    <ReferencePath>$(ProgramFiles)\\Common Files\\microsoft shared\\VSTT\\$(VisualStudioVersion)\\UITestExtensionPackages</ReferencePath>\r\n    <IsCodedUITest>False</IsCodedUITest>\r\n    <TestProjectType>UnitTest</TestProjectType>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <DebugType>full</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\r\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <Optimize>true</Optimize>\r\n    <DebugType>pdbonly</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Numerics\" />\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n  </ItemGroup>\r\n  <Choose>\r\n    <When Condition=\"('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'\">\r\n      <ItemGroup>\r\n        <Reference Include=\"Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\" />\r\n      </ItemGroup>\r\n    </When>\r\n    <Otherwise>\r\n      <ItemGroup>\r\n        <Reference Include=\"Microsoft.VisualStudio.QualityTools.UnitTestFramework\" />\r\n      </ItemGroup>\r\n    </Otherwise>\r\n  </Choose>\r\n  <ItemGroup>\r\n    <Compile Include=\"InventoryServiceTests.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9EC0063F-489E-43FE-94B5-BF5F89977CD3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\">\r\n      <Project>{7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae}</Project>\r\n      <Name>Inventory.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Service\\Inventory.Service.csproj\">\r\n      <Project>{714b1c61-ffa8-4a5e-8dd2-d0a290677293}</Project>\r\n      <Name>Inventory.Service</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Mocks\\Mocks.csproj\">\r\n      <Project>{00e00484-bd00-40cd-b2cc-1cfa8e893972}</Project>\r\n      <Name>Mocks</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\RestockRequest.Domain\\RestockRequest.Domain.csproj\">\r\n      <Project>{a44fc2c5-6781-447e-80f5-7265b960b36a}</Project>\r\n      <Name>RestockRequest.Domain</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"app.config\" />\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <Choose>\r\n    <When Condition=\"'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'\">\r\n      <ItemGroup>\r\n        <Reference Include=\"Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n          <Private>False</Private>\r\n        </Reference>\r\n        <Reference Include=\"Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n          <Private>False</Private>\r\n        </Reference>\r\n        <Reference Include=\"Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n          <Private>False</Private>\r\n        </Reference>\r\n        <Reference Include=\"Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\r\n          <Private>False</Private>\r\n        </Reference>\r\n      </ItemGroup>\r\n    </When>\r\n  </Choose>\r\n  <Import Project=\"$(VSToolsPath)\\TeamTest\\Microsoft.TestTools.targets\" Condition=\"Exists('$(VSToolsPath)\\TeamTest\\Microsoft.TestTools.targets')\" />\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r\n       Other similar extension points exist, see Microsoft.Common.targets.\r\n  <Target Name=\"BeforeBuild\">\r\n  </Target>\r\n  <Target Name=\"AfterBuild\">\r\n  </Target>\r\n  -->\r\n</Project>"
  },
  {
    "path": "ReferenceApp/Inventory.UnitTests/InventoryServiceTests.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Inventory.UnitTests\r\n{\r\n    using Common;\r\n    using Inventory.Domain;\r\n    using Inventory.Service;\r\n    using Microsoft.VisualStudio.TestTools.UnitTesting;\r\n    using Mocks;\r\n    using System;\r\n    using System.Fabric;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n\r\n    [TestClass]\r\n    public class InventoryServiceTests\r\n    {\r\n\r\n        private static ICodePackageActivationContext codePackageContext = new MockCodePackageActivationContext(\r\n            \"fabric:/someapp\",\r\n            \"SomeAppType\",\r\n            \"Code\",\r\n            \"1.0.0.0\",\r\n            Guid.NewGuid().ToString(),\r\n            @\"C:\\Log\",\r\n            @\"C:\\Temp\",\r\n            @\"C:\\Work\",\r\n            \"ServiceManifest\",\r\n            \"1.0.0.0\"\r\n            );\r\n\r\n\r\n        StatefulServiceContext statefulServiceContext = new StatefulServiceContext(\r\n            new NodeContext(\"Node0\", new NodeId(0, 1), 0, \"NodeType1\", \"TEST.MACHINE\"),\r\n            codePackageContext,\r\n            InventoryService.InventoryServiceType,\r\n            new Uri(\"fabric:/someapp/someservice\"),\r\n            null,\r\n            Guid.NewGuid(),\r\n            long.MaxValue\r\n            );\r\n\r\n\r\n\r\n        [TestMethod]\r\n        public async Task TestCreateAndIsItemInInventoryAsync()\r\n        {\r\n            MockReliableStateManager stateManager = new MockReliableStateManager();\r\n\r\n            InventoryService target = new InventoryService(statefulServiceContext, stateManager);\r\n\r\n            InventoryItem expected = new InventoryItem(\"test\", 1, 10, 1, 10);\r\n\r\n            await target.CreateInventoryItemAsync(expected);\r\n            bool resultTrue = await target.IsItemInInventoryAsync(expected.Id, CancellationToken.None);\r\n            bool resultFalse = await target.IsItemInInventoryAsync(new InventoryItemId(), CancellationToken.None);\r\n\r\n            Assert.IsTrue(resultTrue);\r\n            Assert.IsFalse(resultFalse);\r\n        }\r\n\r\n        [TestMethod]\r\n        public async Task TestAddStock()\r\n        {\r\n            int expectedQuantity = 10;\r\n            int quantityToAdd = 3;\r\n            MockReliableStateManager stateManager = new MockReliableStateManager();\r\n            InventoryService target = new InventoryService(statefulServiceContext, stateManager);\r\n\r\n            InventoryItem item = new InventoryItem(\"test\", 1, expectedQuantity - quantityToAdd, 1, expectedQuantity);\r\n\r\n            RestockRequest.Domain.RestockRequest request = new RestockRequest.Domain.RestockRequest(item.Id, quantityToAdd);\r\n\r\n            await target.CreateInventoryItemAsync(item);\r\n            int actualAdded = await target.AddStockAsync(request.ItemId, quantityToAdd);\r\n\r\n            Assert.AreEqual(quantityToAdd, actualAdded);\r\n            Assert.AreEqual(item.AvailableStock, expectedQuantity);\r\n        }\r\n\r\n        [TestMethod]\r\n        public async Task TestRemoveStock()\r\n        {\r\n            int expectedQuantity = 5;\r\n            int quantityToRemove = 3;\r\n            MockReliableStateManager stateManager = new MockReliableStateManager();\r\n            InventoryService target = new InventoryService(statefulServiceContext, stateManager);\r\n\r\n            InventoryItem item = new InventoryItem(\"test\", 1, expectedQuantity + quantityToRemove, 1, expectedQuantity);\r\n\r\n            await target.CreateInventoryItemAsync(item);\r\n            int actualRemoved = await target.RemoveStockAsync(item.Id, quantityToRemove, CustomerOrderActorMessageId.GetRandom());\r\n\r\n            Assert.AreEqual(quantityToRemove, actualRemoved);\r\n            Assert.AreEqual(expectedQuantity, item.AvailableStock);\r\n        }\r\n\r\n        [TestMethod]\r\n        public async Task TestRemoveStockWithDuplicateRequest()\r\n        {\r\n            int totalStartingStock = 8;\r\n            int expectedQuantity = 5;\r\n            int quantityToRemove = 3;\r\n            MockReliableStateManager stateManager = new MockReliableStateManager();\r\n            InventoryService target = new InventoryService(statefulServiceContext, stateManager);\r\n\r\n            InventoryItem item = new InventoryItem(\"test\", 1, totalStartingStock, 1, expectedQuantity);\r\n\r\n            await target.CreateInventoryItemAsync(item);\r\n\r\n            CustomerOrderActorMessageId cmid = CustomerOrderActorMessageId.GetRandom();\r\n\r\n            int actualRemoved = await target.RemoveStockAsync(item.Id, quantityToRemove, cmid);\r\n\r\n            Assert.AreEqual(quantityToRemove, actualRemoved);\r\n            Assert.AreEqual(expectedQuantity, item.AvailableStock);\r\n\r\n            //save the current availablestock so we can check to be sure it doesn't change\r\n            int priorAvailableStock = item.AvailableStock;\r\n\r\n            //but now lets say that the reciever didn't get the response and so sends the exact same request again\r\n            int actualRemoved2 = await target.RemoveStockAsync(item.Id, quantityToRemove, cmid);\r\n\r\n            //in this case the response for the amount removed should be the same\r\n            Assert.AreEqual(actualRemoved, actualRemoved2);\r\n\r\n            //also, since the request was a duplicate the remaining invintory should be the same as it was before. \r\n            Assert.AreEqual(item.AvailableStock, priorAvailableStock);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Inventory.UnitTests/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\n// ------------------------------------------------------------\n\nusing System.Reflection;\nusing System.Runtime.InteropServices;\n\n// General Information about an assembly is controlled through the following \n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n\n[assembly: AssemblyTitle(\"Inventory.UnitTests\")]\n[assembly: AssemblyDescription(\"\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyCompany(\"\")]\n[assembly: AssemblyProduct(\"Inventory.UnitTests\")]\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n\n// Setting ComVisible to false makes the types in this assembly not visible \n// to COM components.  If you need to access a type in this assembly from \n// COM, set the ComVisible attribute to true on that type.\n\n[assembly: ComVisible(false)]\n\n// The following GUID is for the ID of the typelib if this project is exposed to COM\n\n[assembly: Guid(\"71e58e09-bee4-4b19-bcf7-4c9bd71514fb\")]\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version \n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers \n// by using the '*' as shown below:\n// [assembly: AssemblyVersion(\"1.0.*\")]\n\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/Inventory.UnitTests/app.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Data\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Internal\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Services\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.Azure.KeyVault.Core\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-2.0.0.0\" newVersion=\"2.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Newtonsoft.Json\" publicKeyToken=\"30ad4fe6b2a6aeed\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-10.0.0.0\" newVersion=\"10.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>"
  },
  {
    "path": "ReferenceApp/Inventory.UnitTests/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/Mocks/MockActorStateManager.cs",
    "content": "﻿// ------------------------------------------------------------\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\n// ------------------------------------------------------------\n\nnamespace Mocks\n{\n    using Microsoft.ServiceFabric.Actors.Runtime;\n    using Microsoft.ServiceFabric.Data;\n    using Microsoft.ServiceFabric.Data.Collections;\n    using Microsoft.ServiceFabric.Data.Notifications;\n    using System;\n    using System.Collections.Concurrent;\n    using System.Collections.Generic;\n    using System.Fabric;\n    using System.Threading;\n    using System.Threading.Tasks;\n\n    public class MockActorStateManager : IActorStateManager\n    {\n        private ConcurrentDictionary<string, object> store = new ConcurrentDictionary<string, object>();\n\n        public Task<T> AddOrUpdateStateAsync<T>(string stateName, T addValue, Func<string, T, T> updateValueFactory, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\n\n        public Task AddStateAsync<T>(string stateName, T value, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\n\n        public Task<bool> ContainsStateAsync(string stateName, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\n\n        public Task<T> GetOrAddStateAsync<T>(string stateName, T value, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\n\n        public Task<T> GetStateAsync<T>(string stateName, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            object result;\n            this.store.TryGetValue(stateName, out result);\n            return Task.FromResult((T)result);\n        }\n\n        public Task<IEnumerable<string>> GetStateNamesAsync(CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\n\n        public Task RemoveStateAsync(string stateName, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\n\n        public Task SetStateAsync<T>(string stateName, T value, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            this.store.AddOrUpdate(stateName, value, (key, oldvalue) => value);\n            return Task.FromResult(true);\n        }\n\n        public Task<bool> TryAddStateAsync<T>(string stateName, T value, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\n\n        public Task<ConditionalValue<T>> TryGetStateAsync<T>(string stateName, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            object item;\n            bool result = this.store.TryGetValue(stateName, out item);\n            return Task.FromResult(new ConditionalValue<T>(result, (T)item));\n        }\n\n        public Task<bool> TryRemoveStateAsync(string stateName, CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\n\n        public Task ClearCacheAsync(CancellationToken cancellationToken = default(CancellationToken))\n        {\n            throw new NotImplementedException();\n        }\r\n\r\n        public Task SaveStateAsync(CancellationToken cancellationToken = default(CancellationToken))\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n    }\n}"
  },
  {
    "path": "ReferenceApp/Mocks/MockAsyncEnumerable.cs",
    "content": "﻿namespace Mocks\r\n{\r\n    using Microsoft.ServiceFabric.Data;\r\n    using System.Collections.Generic;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n\r\n    /// <summary>\r\n    /// Simple wrapper for a synchronous IEnumerable of T.\r\n    /// </summary>\r\n    /// <typeparam name=\"T\"></typeparam>\r\n    internal class MockAsyncEnumerable<T> : IAsyncEnumerable<T>\r\n    {\r\n        private IEnumerable<T> enumerable;\r\n\r\n        public MockAsyncEnumerable(IEnumerable<T> enumerable)\r\n        {\r\n            this.enumerable = enumerable;\r\n        }\r\n\r\n        public IAsyncEnumerator<T> GetAsyncEnumerator()\r\n        {\r\n            return new MockAsyncEnumerator<T>(this.enumerable.GetEnumerator());\r\n        }\r\n    }\r\n\r\n    /// <summary>\r\n    /// Simply wrapper for a synchronous IEnumerator of T.\r\n    /// </summary>\r\n    /// <typeparam name=\"T\"></typeparam>\r\n    internal class MockAsyncEnumerator<T> : IAsyncEnumerator<T>\r\n    {\r\n        private readonly IEnumerator<T> enumerator;\r\n\r\n        public MockAsyncEnumerator(IEnumerator<T> enumerator)\r\n        {\r\n            this.enumerator = enumerator;\r\n        }\r\n\r\n\r\n        public T Current\r\n        {\r\n            get\r\n            {\r\n                return this.enumerator.Current;\r\n            }\r\n        }\r\n\r\n        public void Dispose()\r\n        {\r\n            this.enumerator.Dispose();\r\n        }\r\n\r\n        public Task<bool> MoveNextAsync(CancellationToken cancellationToken)\r\n        {\r\n            return Task.FromResult(this.enumerator.MoveNext());\r\n        }\r\n\r\n        public void Reset()\r\n        {\r\n            this.enumerator.Reset();\r\n        }\r\n    }\r\n\r\n}\r\n"
  },
  {
    "path": "ReferenceApp/Mocks/MockCodePackageActivationContext.cs",
    "content": "﻿namespace Mocks\r\n{\r\n\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Collections.ObjectModel;\r\n    using System.Fabric;\r\n    using System.Fabric.Description;\r\n    using System.Fabric.Health;\r\n    public class MockCodePackageActivationContext : ICodePackageActivationContext\r\n    {\r\n        public string ApplicationName { get; private set; }\r\n\r\n        public string ApplicationTypeName { get; private set; }\r\n\r\n        public string CodePackageName { get; private set; }\r\n\r\n        public string CodePackageVersion { get; private set; }\r\n\r\n        public string ContextId { get; private set; }\r\n\r\n        public string LogDirectory { get; private set; }\r\n\r\n        public string TempDirectory { get; private set; }\r\n\r\n        public string WorkDirectory { get; private set; }\r\n        private string ServiceManifetName { get; set; }\r\n\r\n        private string ServiceManifestVersion { get; set; }\r\n\r\n\r\n        public event EventHandler<PackageAddedEventArgs<CodePackage>> CodePackageAddedEvent;\r\n        public event EventHandler<PackageModifiedEventArgs<CodePackage>> CodePackageModifiedEvent;\r\n        public event EventHandler<PackageRemovedEventArgs<CodePackage>> CodePackageRemovedEvent;\r\n        public event EventHandler<PackageAddedEventArgs<ConfigurationPackage>> ConfigurationPackageAddedEvent;\r\n        public event EventHandler<PackageModifiedEventArgs<ConfigurationPackage>> ConfigurationPackageModifiedEvent;\r\n        public event EventHandler<PackageRemovedEventArgs<ConfigurationPackage>> ConfigurationPackageRemovedEvent;\r\n        public event EventHandler<PackageAddedEventArgs<DataPackage>> DataPackageAddedEvent;\r\n        public event EventHandler<PackageModifiedEventArgs<DataPackage>> DataPackageModifiedEvent;\r\n        public event EventHandler<PackageRemovedEventArgs<DataPackage>> DataPackageRemovedEvent;\r\n\r\n        public ApplicationPrincipalsDescription GetApplicationPrincipals()\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public IList<string> GetCodePackageNames()\r\n        {\r\n            return new List<string>() { this.CodePackageName };\r\n        }\r\n\r\n        public CodePackage GetCodePackageObject(string packageName)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public IList<string> GetConfigurationPackageNames()\r\n        {\r\n            return new List<string>() { \"\" };\r\n        }\r\n\r\n        public ConfigurationPackage GetConfigurationPackageObject(string packageName)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public IList<string> GetDataPackageNames()\r\n        {\r\n            return new List<string>() { \"\" };\r\n        }\r\n\r\n        public DataPackage GetDataPackageObject(string packageName)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public EndpointResourceDescription GetEndpoint(string endpointName)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public KeyedCollection<string, EndpointResourceDescription> GetEndpoints()\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public KeyedCollection<string, ServiceGroupTypeDescription> GetServiceGroupTypes()\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public string GetServiceManifestName()\r\n        {\r\n            return this.ServiceManifetName;\r\n        }\r\n\r\n        public string GetServiceManifestVersion()\r\n        {\r\n            return this.ServiceManifestVersion;\r\n        }\r\n\r\n        public KeyedCollection<string, ServiceTypeDescription> GetServiceTypes()\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public void ReportApplicationHealth(HealthInformation healthInformation)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public void ReportDeployedServicePackageHealth(HealthInformation healthInformation)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public void ReportDeployedApplicationHealth(HealthInformation healthInformation)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n\r\n\r\n        public MockCodePackageActivationContext(\r\n            string ApplicationName,\r\n            string ApplicationTypeName,\r\n            string CodePackageName,\r\n            string CodePackageVersion,\r\n            string Context,\r\n            string LogDirectory,\r\n            string TempDirectory,\r\n            string WorkDirectory,\r\n            string ServiceManifestName,\r\n            string ServiceManifestVersion)\r\n        {\r\n\r\n            this.ApplicationName = ApplicationName;\r\n            this.ApplicationTypeName = ApplicationTypeName;\r\n            this.CodePackageName = CodePackageName;\r\n            this.CodePackageVersion = CodePackageVersion;\r\n            this.ContextId = Context;\r\n            this.LogDirectory = LogDirectory;\r\n            this.TempDirectory = TempDirectory;\r\n            this.WorkDirectory = WorkDirectory;\r\n        }\r\n\r\n\r\n        #region IDisposable Support\r\n        private bool disposedValue = false; // To detect redundant calls\r\n\r\n        protected virtual void Dispose(bool disposing)\r\n        {\r\n            if (!disposedValue)\r\n            {\r\n                if (disposing)\r\n                {\r\n                    // TODO: dispose managed state (managed objects).\r\n                }\r\n\r\n                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.\r\n                // TODO: set large fields to null.\r\n\r\n                disposedValue = true;\r\n            }\r\n        }\r\n\r\n        // This code added to correctly implement the disposable pattern.\r\n        public void Dispose()\r\n        {\r\n            // Do not change this code. Put cleanup code in Dispose(bool disposing) above.\r\n            Dispose(true);\r\n            // TODO: uncomment the following line if the finalizer is overridden above.\r\n            // GC.SuppressFinalize(this);\r\n        }\r\n        #endregion\r\n    }\r\n}\r\n"
  },
  {
    "path": "ReferenceApp/Mocks/MockInventoryService.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Mocks\r\n{\r\n    using Common;\r\n    using Inventory.Domain;\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n\r\n    public class MockInventoryService : IInventoryService\r\n    {\r\n        public MockInventoryService()\r\n        {\r\n            this.AddStockAsyncFunc = (itemId, quantity) => Task.FromResult(quantity);\r\n            this.RemoveStockAsyncFunc = (itemId, quantity, amId) => Task.FromResult(quantity);\r\n            this.IsItemInInventoryAsyncFunc = (itemId) => Task.FromResult(true);\r\n            this.GetCustomerInventoryAsyncFunc = () => Task.FromResult<IEnumerable<InventoryItemView>>(new List<InventoryItemView>() { new InventoryItemView() });\r\n            this.CreateInventoryItemAsyncFunc = item => Task.FromResult(true);\r\n        }\r\n\r\n        public Func<InventoryItemId, int, Task<int>> AddStockAsyncFunc { get; set; }\r\n\r\n        public Func<InventoryItem, Task<bool>> CreateInventoryItemAsyncFunc { get; set; }\r\n\r\n        public Func<Task<IEnumerable<InventoryItemView>>> GetCustomerInventoryAsyncFunc { get; set; }\r\n\r\n        public Func<InventoryItemId, Task<bool>> IsItemInInventoryAsyncFunc { get; set; }\r\n\r\n        public Func<InventoryItemId, int, CustomerOrderActorMessageId, Task<int>> RemoveStockAsyncFunc { get; set; }\r\n\r\n        public Task<int> AddStockAsync(InventoryItemId itemId, int quantity)\r\n        {\r\n            return this.AddStockAsyncFunc(itemId, quantity);\r\n        }\r\n\r\n        public Task<bool> CreateInventoryItemAsync(InventoryItem item)\r\n        {\r\n            return this.CreateInventoryItemAsyncFunc(item);\r\n        }\r\n\r\n        public Task<IEnumerable<InventoryItemView>> GetCustomerInventoryAsync()\r\n        {\r\n            return this.GetCustomerInventoryAsyncFunc();\r\n        }\r\n\r\n        public Task<IEnumerable<InventoryItemView>> GetCustomerInventoryAsync(CancellationToken cancellationToken)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public Task<bool> IsItemInInventoryAsync(InventoryItemId itemId)\r\n        {\r\n            return this.IsItemInInventoryAsyncFunc(itemId);\r\n        }\r\n\r\n        public Task<bool> IsItemInInventoryAsync(InventoryItemId itemId, CancellationToken cancellationToken)\r\n        {\r\n            return this.IsItemInInventoryAsyncFunc(itemId);\r\n        }\r\n\r\n        public Task<int> RemoveStockAsync(InventoryItemId itemId, int quantity, CustomerOrderActorMessageId amId)\r\n        {\r\n            return this.RemoveStockAsyncFunc(itemId, quantity, amId);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Mocks/MockReliableDictionary.cs",
    "content": "﻿// ------------------------------------------------------------\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\n// ------------------------------------------------------------\n\nnamespace Mocks\n{\n    using Microsoft.ServiceFabric.Data;\n    using Microsoft.ServiceFabric.Data.Collections;\r\n    using Microsoft.ServiceFabric.Data.Notifications;\r\n    using System;\n    using System.Collections.Concurrent;\n    using System.Collections.Generic;\n    using System.Linq;\n    using System.Threading;\n    using System.Threading.Tasks;\n\r\n    public class MockReliableDictionary<TKey, TValue> : IReliableDictionary<TKey, TValue>\n        where TKey : IComparable<TKey>, IEquatable<TKey>\n    {\n        private ConcurrentDictionary<TKey, TValue> dictionary = new ConcurrentDictionary<TKey, TValue>();\r\n\r\n        public event EventHandler<NotifyDictionaryChangedEventArgs<TKey, TValue>> DictionaryChanged;\r\n\r\n        public Uri Name { get; set; }\r\n\r\n        public Func<IReliableDictionary<TKey, TValue>, NotifyDictionaryRebuildEventArgs<TKey, TValue>, Task> RebuildNotificationAsyncCallback\r\n        {\r\n            set\r\n            {\r\n                throw new NotImplementedException();\r\n            }\r\n        }\r\n\r\n        public Task AddAsync(ITransaction tx, TKey key, TValue value)\n        {\n            if (!this.dictionary.TryAdd(key, value))\n            {\n                throw new InvalidOperationException(\"key already exists: \" + key.ToString());\n            }\n\n\n            return Task.FromResult(true);\n        }\n\n        public Task AddAsync(ITransaction tx, TKey key, TValue value, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            if (!this.dictionary.TryAdd(key, value))\n            {\n                throw new InvalidOperationException(\"key already exists: \" + key.ToString());\n            }\n\n            return Task.FromResult(true);\n        }\n\n        public Task<TValue> AddOrUpdateAsync(ITransaction tx, TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)\n        {\n            return Task.FromResult(this.dictionary.AddOrUpdate(key, addValueFactory, updateValueFactory));\n        }\n\n        public Task<TValue> AddOrUpdateAsync(ITransaction tx, TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)\n        {\n            return Task.FromResult(this.dictionary.AddOrUpdate(key, addValue, updateValueFactory));\n        }\n\n        public Task<TValue> AddOrUpdateAsync(\n            ITransaction tx, TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory, TimeSpan timeout,\n            CancellationToken cancellationToken)\n        {\n            return Task.FromResult(this.dictionary.AddOrUpdate(key, addValueFactory, updateValueFactory));\n        }\n\n        public Task<TValue> AddOrUpdateAsync(\n            ITransaction tx, TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            return Task.FromResult(this.dictionary.AddOrUpdate(key, addValue, updateValueFactory));\n        }\n\n        public Task ClearAsync()\n        {\n            this.dictionary.Clear();\n\n            return Task.FromResult(true);\n        }\n\n        public Task ClearAsync(TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            this.dictionary.Clear();\n\n            return Task.FromResult(true);\n        }\n\n        public Task<bool> ContainsKeyAsync(ITransaction tx, TKey key)\n        {\n            return Task.FromResult(this.dictionary.ContainsKey(key));\n        }\n\n        public Task<bool> ContainsKeyAsync(ITransaction tx, TKey key, LockMode lockMode)\n        {\n            return Task.FromResult(this.dictionary.ContainsKey(key));\n        }\n\n        public Task<bool> ContainsKeyAsync(ITransaction tx, TKey key, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            return Task.FromResult(this.dictionary.ContainsKey(key));\n        }\n\n        public Task<bool> ContainsKeyAsync(ITransaction tx, TKey key, LockMode lockMode, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            return Task.FromResult(this.dictionary.ContainsKey(key));\n        }\n\n        public Task<ConditionalValue<TValue>> TryGetValueAsync(ITransaction tx, TKey key)\n        {\n            TValue value;\n            bool result = this.dictionary.TryGetValue(key, out value);\n\n            return Task.FromResult(new ConditionalValue<TValue>(result, value));\n        }\n\n        public Task<ConditionalValue<TValue>> TryGetValueAsync(ITransaction tx, TKey key, LockMode lockMode)\n        {\n            TValue value;\n            bool result = this.dictionary.TryGetValue(key, out value);\n\n            return Task.FromResult(new ConditionalValue<TValue>(result, value));\n        }\n\n        public Task<ConditionalValue<TValue>> TryGetValueAsync(ITransaction tx, TKey key, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            TValue value;\n            bool result = this.dictionary.TryGetValue(key, out value);\n\n            return Task.FromResult(new ConditionalValue<TValue>(result, value));\n        }\n\n        public Task<ConditionalValue<TValue>> TryGetValueAsync(\n            ITransaction tx, TKey key, LockMode lockMode, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            TValue value;\n            bool result = this.dictionary.TryGetValue(key, out value);\n\n            return Task.FromResult(new ConditionalValue<TValue>(result, value));\n        }\n\n        public Task SetAsync(ITransaction tx, TKey key, TValue value)\n        {\n            this.dictionary[key] = value;\n\n            return Task.FromResult(true);\n        }\n\n        public Task SetAsync(ITransaction tx, TKey key, TValue value, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            this.dictionary[key] = value;\n\n            return Task.FromResult(true);\n        }\n\n        public Task<TValue> GetOrAddAsync(ITransaction tx, TKey key, Func<TKey, TValue> valueFactory)\n        {\n            return Task.FromResult(this.dictionary.GetOrAdd(key, valueFactory));\n        }\n\n        public Task<TValue> GetOrAddAsync(ITransaction tx, TKey key, TValue value)\n        {\n            return Task.FromResult(this.dictionary.GetOrAdd(key, value));\n        }\n\n        public Task<TValue> GetOrAddAsync(ITransaction tx, TKey key, Func<TKey, TValue> valueFactory, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            return Task.FromResult(this.dictionary.GetOrAdd(key, valueFactory));\n        }\n\n        public Task<TValue> GetOrAddAsync(ITransaction tx, TKey key, TValue value, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            return Task.FromResult(this.dictionary.GetOrAdd(key, value));\n        }\n\n        public Task<bool> TryAddAsync(ITransaction tx, TKey key, TValue value)\n        {\n            return Task.FromResult(this.dictionary.TryAdd(key, value));\n        }\n\n        public Task<bool> TryAddAsync(ITransaction tx, TKey key, TValue value, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            return Task.FromResult(this.dictionary.TryAdd(key, value));\n        }\n\n        public Task<ConditionalValue<TValue>> TryRemoveAsync(ITransaction tx, TKey key)\n        {\n            TValue outValue;\n            return Task.FromResult(new ConditionalValue<TValue>(this.dictionary.TryRemove(key, out outValue), outValue));\n        }\n\n        public Task<ConditionalValue<TValue>> TryRemoveAsync(ITransaction tx, TKey key, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            return this.TryRemoveAsync(tx, key);\n        }\n\n        public Task<bool> TryUpdateAsync(ITransaction tx, TKey key, TValue newValue, TValue comparisonValue)\n        {\n            return Task.FromResult(this.dictionary.TryUpdate(key, newValue, comparisonValue));\n        }\n\n        public Task<bool> TryUpdateAsync(\n            ITransaction tx, TKey key, TValue newValue, TValue comparisonValue, TimeSpan timeout, CancellationToken cancellationToken)\n        {\n            return Task.FromResult(this.dictionary.TryUpdate(key, newValue, comparisonValue));\n        }\n\n        public Task<long> GetCountAsync()\n        {\n            return Task.FromResult((long)this.dictionary.Count);\n        }\r\n\r\n        public Task<IAsyncEnumerable<KeyValuePair<TKey, TValue>>> CreateEnumerableAsync(ITransaction txn)\r\n        {\r\n            return Task.FromResult<IAsyncEnumerable<KeyValuePair<TKey, TValue>>>(new MockAsyncEnumerable<KeyValuePair<TKey, TValue>>(this.dictionary));\r\n        }\r\n\r\n        public Task<IAsyncEnumerable<KeyValuePair<TKey, TValue>>> CreateEnumerableAsync(ITransaction txn, EnumerationMode enumerationMode)\r\n        {\r\n            return Task.FromResult<IAsyncEnumerable<KeyValuePair<TKey, TValue>>>(new MockAsyncEnumerable<KeyValuePair<TKey, TValue>>(\r\n                enumerationMode == EnumerationMode.Unordered\r\n                    ? (IEnumerable<KeyValuePair<TKey, TValue>>)this.dictionary\r\n                    : this.dictionary.OrderBy(x => x.Key)));\r\n        }\r\n\r\n        public Task<IAsyncEnumerable<KeyValuePair<TKey, TValue>>> CreateEnumerableAsync(ITransaction txn, Func<TKey, bool> filter, EnumerationMode enumerationMode)\r\n        {\r\n            return Task.FromResult<IAsyncEnumerable<KeyValuePair<TKey, TValue>>>(new MockAsyncEnumerable<KeyValuePair<TKey, TValue>>(\r\n                enumerationMode == EnumerationMode.Unordered\r\n                    ? this.dictionary.Where(x => filter(x.Key))\r\n                    : this.dictionary.Where(x => filter(x.Key)).OrderBy(x => x.Key)));\r\n        }\r\n\r\n        public Task<long> GetCountAsync(ITransaction tx)\r\n        {\n            return Task.FromResult((long)this.dictionary.Count);\r\n        }\r\n    }\n}"
  },
  {
    "path": "ReferenceApp/Mocks/MockReliableQueue.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Mocks\r\n{\r\n    using Microsoft.ServiceFabric.Data;\r\n    using Microsoft.ServiceFabric.Data.Collections;\r\n    using System;\r\n    using System.Collections.Concurrent;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n\r\n    public class MockReliableQueue<T> : IReliableQueue<T>\r\n    {\r\n        private ConcurrentQueue<T> queue = new ConcurrentQueue<T>();\r\n\r\n        public Task EnqueueAsync(ITransaction tx, T item, TimeSpan timeout, CancellationToken cancellationToken)\r\n        {\r\n            this.queue.Enqueue(item);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task EnqueueAsync(ITransaction tx, T item)\r\n        {\r\n            this.queue.Enqueue(item);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task<ConditionalValue<T>> TryDequeueAsync(ITransaction tx, TimeSpan timeout, CancellationToken cancellationToken)\r\n        {\r\n            T item;\r\n            bool result = this.queue.TryDequeue(out item);\r\n\r\n            return Task.FromResult((ConditionalValue<T>)Activator.CreateInstance(typeof(ConditionalValue<T>), result, item));\r\n        }\r\n\r\n        public Task<ConditionalValue<T>> TryDequeueAsync(ITransaction tx)\r\n        {\r\n            T item;\r\n            bool result = this.queue.TryDequeue(out item);\r\n\r\n            return Task.FromResult((ConditionalValue<T>)Activator.CreateInstance(typeof(ConditionalValue<T>), result, item));\r\n        }\r\n\r\n        public Task<ConditionalValue<T>> TryPeekAsync(ITransaction tx, LockMode lockMode, TimeSpan timeout, CancellationToken cancellationToken)\r\n        {\r\n            T item;\r\n            bool result = this.queue.TryPeek(out item);\r\n\r\n            return Task.FromResult((ConditionalValue<T>)Activator.CreateInstance(typeof(ConditionalValue<T>), result, item));\r\n        }\r\n\r\n        public Task<ConditionalValue<T>> TryPeekAsync(ITransaction tx, LockMode lockMode)\r\n        {\r\n            T item;\r\n            bool result = this.queue.TryPeek(out item);\r\n\r\n            return Task.FromResult((ConditionalValue<T>)Activator.CreateInstance(typeof(ConditionalValue<T>), result, item));\r\n        }\r\n\r\n        public Task<ConditionalValue<T>> TryPeekAsync(ITransaction tx, TimeSpan timeout, CancellationToken cancellationToken)\r\n        {\r\n            T item;\r\n            bool result = this.queue.TryPeek(out item);\r\n\r\n            return Task.FromResult((ConditionalValue<T>)Activator.CreateInstance(typeof(ConditionalValue<T>), result, item));\r\n        }\r\n\r\n        public Task<ConditionalValue<T>> TryPeekAsync(ITransaction tx)\r\n        {\r\n            T item;\r\n            bool result = this.queue.TryPeek(out item);\r\n\r\n            return Task.FromResult((ConditionalValue<T>)Activator.CreateInstance(typeof(ConditionalValue<T>), result, item));\r\n        }\r\n\r\n        public Task ClearAsync()\r\n        {\r\n            while (!this.queue.IsEmpty)\r\n            {\r\n                T result;\r\n                this.queue.TryDequeue(out result);\r\n            }\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task<long> GetCountAsync()\r\n        {\r\n            return Task.FromResult((long)this.queue.Count);\r\n        }\r\n\r\n        public Task<IAsyncEnumerable<T>> CreateEnumerableAsync(ITransaction tx)\r\n        {\r\n            return Task.FromResult<IAsyncEnumerable<T>>(new MockAsyncEnumerable<T>(this.queue));\r\n        }\r\n\r\n        public Task<long> GetCountAsync(ITransaction tx)\r\n        {\r\n            return Task.FromResult<long>(this.queue.Count);\r\n        }\r\n\r\n        public Uri Name { get; set; }\r\n\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Mocks/MockReliableStateManager.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Mocks\r\n{\r\n    using Microsoft.ServiceFabric.Data;\r\n    using Microsoft.ServiceFabric.Data.Collections;\r\n    using Microsoft.ServiceFabric.Data.Notifications;\r\n    using System;\r\n    using System.Collections.Concurrent;\r\n    using System.Collections.Generic;\r\n    using System.Fabric;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n\r\n    public class MockReliableStateManager : IReliableStateManagerReplica\r\n    {\r\n        private ConcurrentDictionary<Uri, IReliableState> store = new ConcurrentDictionary<Uri, IReliableState>();\r\n        private Func<CancellationToken, Task<bool>> datalossFunction;\r\n\r\n        private Dictionary<Type, Type> dependencyMap = new Dictionary<Type, Type>()\r\n        {\r\n            {typeof(IReliableDictionary<,>), typeof(MockReliableDictionary<,>)},\r\n            {typeof(IReliableQueue<>), typeof(MockReliableQueue<>)}\r\n        };\r\n\r\n        public Func<CancellationToken, Task<bool>> OnDataLossAsync\r\n        {\r\n            set\r\n            {\r\n                this.datalossFunction = value;\r\n            }\r\n\r\n            get\r\n            {\r\n                return this.datalossFunction;\r\n            }\r\n        }\r\n\r\n        public event EventHandler<NotifyTransactionChangedEventArgs> TransactionChanged;\r\n        public event EventHandler<NotifyStateManagerChangedEventArgs> StateManagerChanged;\r\n\r\n        public Task ClearAsync(ITransaction tx)\r\n        {\r\n            this.store.Clear();\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task ClearAsync()\r\n        {\r\n            this.store.Clear();\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public ITransaction CreateTransaction()\r\n        {\r\n            return new MockTransaction();\r\n        }\r\n\r\n        public Task RemoveAsync(string name)\r\n        {\r\n            IReliableState result;\r\n            this.store.TryRemove(this.ToUri(name), out result);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task RemoveAsync(ITransaction tx, string name)\r\n        {\r\n            IReliableState result;\r\n            this.store.TryRemove(this.ToUri(name), out result);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task RemoveAsync(string name, TimeSpan timeout)\r\n        {\r\n            IReliableState result;\r\n            this.store.TryRemove(this.ToUri(name), out result);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task RemoveAsync(ITransaction tx, string name, TimeSpan timeout)\r\n        {\r\n            IReliableState result;\r\n            this.store.TryRemove(this.ToUri(name), out result);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task RemoveAsync(Uri name)\r\n        {\r\n            IReliableState result;\r\n            this.store.TryRemove(name, out result);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task RemoveAsync(Uri name, TimeSpan timeout)\r\n        {\r\n            IReliableState result;\r\n            this.store.TryRemove(name, out result);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task RemoveAsync(ITransaction tx, Uri name)\r\n        {\r\n            IReliableState result;\r\n            this.store.TryRemove(name, out result);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task RemoveAsync(ITransaction tx, Uri name, TimeSpan timeout)\r\n        {\r\n            IReliableState result;\r\n            this.store.TryRemove(name, out result);\r\n\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task<ConditionalValue<T>> TryGetAsync<T>(string name) where T : IReliableState\r\n        {\r\n            IReliableState item;\r\n            bool result = this.store.TryGetValue(this.ToUri(name), out item);\r\n\r\n            return Task.FromResult(new ConditionalValue<T>(result, (T)item));\r\n        }\r\n\r\n        public Task<ConditionalValue<T>> TryGetAsync<T>(Uri name) where T : IReliableState\r\n        {\r\n            IReliableState item;\r\n            bool result = this.store.TryGetValue(name, out item);\r\n\r\n            return Task.FromResult(new ConditionalValue<T>(result, (T)item));\r\n        }\r\n\r\n        public Task<T> GetOrAddAsync<T>(string name) where T : IReliableState\r\n        {\r\n            return Task.FromResult((T)this.store.GetOrAdd(this.ToUri(name), this.GetDependency(typeof(T))));\r\n        }\r\n\r\n        public Task<T> GetOrAddAsync<T>(ITransaction tx, string name) where T : IReliableState\r\n        {\r\n            return Task.FromResult((T)this.store.GetOrAdd(this.ToUri(name), this.GetDependency(typeof(T))));\r\n        }\r\n\r\n        public Task<T> GetOrAddAsync<T>(string name, TimeSpan timeout) where T : IReliableState\r\n        {\r\n            return Task.FromResult((T)this.store.GetOrAdd(this.ToUri(name), this.GetDependency(typeof(T))));\r\n        }\r\n\r\n        public Task<T> GetOrAddAsync<T>(ITransaction tx, string name, TimeSpan timeout) where T : IReliableState\r\n        {\r\n            return Task.FromResult((T)this.store.GetOrAdd(this.ToUri(name), this.GetDependency(typeof(T))));\r\n        }\r\n\r\n        public Task<T> GetOrAddAsync<T>(Uri name) where T : IReliableState\r\n        {\r\n            return Task.FromResult((T)this.store.GetOrAdd(name, this.GetDependency(typeof(T))));\r\n        }\r\n\r\n        public Task<T> GetOrAddAsync<T>(Uri name, TimeSpan timeout) where T : IReliableState\r\n        {\r\n            return Task.FromResult((T)this.store.GetOrAdd(name, this.GetDependency(typeof(T))));\r\n        }\r\n\r\n        public Task<T> GetOrAddAsync<T>(ITransaction tx, Uri name) where T : IReliableState\r\n        {\r\n            return Task.FromResult((T)this.store.GetOrAdd(name, this.GetDependency(typeof(T))));\r\n        }\r\n\r\n        public Task<T> GetOrAddAsync<T>(ITransaction tx, Uri name, TimeSpan timeout) where T : IReliableState\r\n        {\r\n            return Task.FromResult((T)this.store.GetOrAdd(name, this.GetDependency(typeof(T))));\r\n        }\r\n\r\n        public bool TryAddStateSerializer<T>(IStateSerializer<T> stateSerializer)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        private IReliableState GetDependency(Type t)\r\n        {\r\n            Type mockType = this.dependencyMap[t.GetGenericTypeDefinition()];\r\n\r\n            return (IReliableState)Activator.CreateInstance(mockType.MakeGenericType(t.GetGenericArguments()));\r\n        }\r\n\r\n        private Uri ToUri(string name)\r\n        {\r\n            return new Uri(\"mock://\" + name, UriKind.Absolute);\r\n        }\r\n\r\n        public IAsyncEnumerator<IReliableState> GetAsyncEnumerator()\r\n        {\r\n            return new MockAsyncEnumerator<IReliableState>(this.store.Values.GetEnumerator());\r\n        }\r\n\r\n        public void Initialize(StatefulServiceInitializationParameters initializationParameters)\r\n        {\r\n\r\n        }\r\n\r\n        public Task<IReplicator> OpenAsync(ReplicaOpenMode openMode, IStatefulServicePartition partition, CancellationToken cancellationToken)\r\n        {\r\n            return null;\r\n        }\r\n\r\n        public Task ChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)\r\n        {\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public Task CloseAsync(CancellationToken cancellationToken)\r\n        {\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public void Abort()\r\n        {\r\n        }\r\n\r\n        public Task BackupAsync(Func<BackupInfo, CancellationToken, Task<bool>> backupCallback)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public Task BackupAsync(BackupOption option, TimeSpan timeout, CancellationToken cancellationToken, Func<BackupInfo, CancellationToken, Task<bool>> backupCallback)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public Task RestoreAsync(string backupFolderPath)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n\r\n        public Task RestoreAsync(string backupFolderPath, RestorePolicy restorePolicy, CancellationToken cancellationToken)\r\n        {\r\n            throw new NotImplementedException();\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Mocks/MockServiceProxy.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Mocks\r\n{\r\n    using Microsoft.ServiceFabric.Services.Client;\r\n    using Microsoft.ServiceFabric.Services.Communication.Client;\r\n    using Microsoft.ServiceFabric.Services.Remoting;\r\n    using Microsoft.ServiceFabric.Services.Remoting.Client;\r\n    using System;\r\n    using System.Collections.Generic;\r\n\r\n    public class MockServiceProxy : IServiceProxy\r\n    {\r\n        private IDictionary<Type, Func<Uri, object>> createFunctions = new Dictionary<Type, Func<Uri, object>>();\r\n\r\n        public Type ServiceInterfaceType { get; private set; }\r\n\r\n        public IServiceRemotingPartitionClient ServicePartitionClient { get; private set; }\r\n\r\n        public TServiceInterface Create<TServiceInterface>(Uri serviceName) where TServiceInterface : IService\r\n        {\r\n            this.ServiceInterfaceType = typeof(TServiceInterface);\r\n            return (TServiceInterface)this.createFunctions[typeof(TServiceInterface)](serviceName);\r\n        }\r\n\r\n        //public TServiceInterface Create<TServiceInterface>(Uri serviceName, ServicePartitionKey key) where TServiceInterface : IService\r\n        //{\r\n        //    return (TServiceInterface)this.createFunctions[typeof(TServiceInterface)](serviceName);\r\n        //}\r\n\r\n        public TServiceInterface Create<TServiceInterface>(Uri serviceUri, ServicePartitionKey partitionKey = null, TargetReplicaSelector targetReplicaSelector = TargetReplicaSelector.Default, string listenerName = null) where TServiceInterface : IService\r\n        {\r\n            return (TServiceInterface)this.createFunctions[typeof(TServiceInterface)](serviceUri);\r\n        }\r\n\r\n        public void Supports<TServiceInterface>(Func<Uri, object> Create)\r\n        {\r\n            this.createFunctions[typeof(TServiceInterface)] = Create;\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Mocks/MockServiceProxyFactory.cs",
    "content": "﻿// ------------------------------------------------------------\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\n// ------------------------------------------------------------\n\nnamespace Mocks\n{\n    using System;\n    using Microsoft.ServiceFabric.Services.Remoting;\n    using Microsoft.ServiceFabric.Services.Remoting.Client;\n    using Microsoft.ServiceFabric.Services.Client;\n    using Microsoft.ServiceFabric.Services.Communication.Client;\n    using System.Collections.Concurrent;\n\n    /// <summary>\n    /// Wrapper class for the static ServiceProxy.\n    /// </summary>\n    public class MockServiceProxyFactory : IServiceProxyFactory\n    {\n        private ConcurrentDictionary<Uri, IService> mockServiceLookupTable = new ConcurrentDictionary<Uri, IService>();\n\n        public TServiceInterface CreateServiceProxy<TServiceInterface>(Uri serviceUri, ServicePartitionKey partitionKey = null, TargetReplicaSelector targetReplicaSelector = TargetReplicaSelector.Default, string listenerName = null) where TServiceInterface : IService\n        {\n            MockServiceProxy serviceProxy = new MockServiceProxy();\n            \n            serviceProxy.Supports<TServiceInterface>((mockUri) => mockServiceLookupTable[serviceUri]);\n\n            return serviceProxy.Create<TServiceInterface>(serviceUri, partitionKey, targetReplicaSelector, listenerName);\n            \n        }\n\n        public void AssociateMockServiceAndName(Uri mockServiceUri, IService mockService)\n        {\n            mockServiceLookupTable.AddOrUpdate(mockServiceUri, mockService, (uri, service) => mockService);\n        }\n    }\n}"
  },
  {
    "path": "ReferenceApp/Mocks/MockTransaction.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Mocks\r\n{\r\n    using Microsoft.ServiceFabric.Data;\r\n    using System;\r\n    using System.Threading.Tasks;\r\n\r\n    public class MockTransaction : ITransaction\r\n    {\r\n        public Task CommitAsync()\r\n        {\r\n            return Task.FromResult(true);\r\n        }\r\n\r\n        public void Abort()\r\n        {\r\n        }\r\n\r\n        public long TransactionId\r\n        {\r\n            get { return 0L; }\r\n        }\r\n\r\n        public long CommitSequenceNumber\r\n        {\r\n            get\r\n            {\r\n                throw new NotImplementedException();\r\n            }\r\n        }\r\n\r\n        public void Dispose()\r\n        {\r\n        }\r\n\r\n        public Task<long> GetVisibilitySequenceNumberAsync()\r\n        {\r\n            return Task.FromResult(0L);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Mocks/Mocks.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\r\n    <ProjectGuid>{00E00484-BD00-40CD-B2CC-1CFA8E893972}</ProjectGuid>\r\n    <OutputType>Library</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>Mocks</RootNamespace>\r\n    <AssemblyName>Mocks</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <DebugType>full</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\r\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <Optimize>true</Optimize>\r\n    <DebugType>pdbonly</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n    <Reference Include=\"System.Xml.Linq\" />\r\n    <Reference Include=\"System.Data.DataSetExtensions\" />\r\n    <Reference Include=\"Microsoft.CSharp\" />\r\n    <Reference Include=\"System.Data\" />\r\n    <Reference Include=\"System.Net.Http\" />\r\n    <Reference Include=\"System.Xml\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"MockActorStateManager.cs\" />\r\n    <Compile Include=\"MockAsyncEnumerable.cs\" />\r\n    <Compile Include=\"MockCodePackageActivationContext.cs\" />\r\n    <Compile Include=\"MockInventoryService.cs\" />\r\n    <Compile Include=\"MockReliableDictionary.cs\" />\r\n    <Compile Include=\"MockReliableQueue.cs\" />\r\n    <Compile Include=\"MockReliableStateManager.cs\" />\r\n    <Compile Include=\"MockServiceProxy.cs\" />\r\n    <Compile Include=\"MockServiceProxyFactory.cs\" />\r\n    <Compile Include=\"MockTransaction.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\CustomerOrder.Domain\\CustomerOrder.Domain.csproj\">\r\n      <Project>{1e7e813f-43d3-4d0b-8546-5e1023873f28}</Project>\r\n      <Name>CustomerOrder.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\">\r\n      <Project>{7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae}</Project>\r\n      <Name>Inventory.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\RestockRequest.Domain\\RestockRequest.Domain.csproj\">\r\n      <Project>{a44fc2c5-6781-447e-80f5-7265b960b36a}</Project>\r\n      <Name>RestockRequest.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\RestockRequestManager.Domain\\RestockRequestManager.Domain.csproj\">\r\n      <Project>{4162f266-d657-4143-aa62-626c10d23561}</Project>\r\n      <Name>RestockRequestManager.Domain</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"app.config\" />\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \n       Other similar extension points exist, see Microsoft.Common.targets.\n  <Target Name=\"BeforeBuild\">\n  </Target>\n  <Target Name=\"AfterBuild\">\n  </Target>\n  -->\r\n</Project>"
  },
  {
    "path": "ReferenceApp/Mocks/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\n// ------------------------------------------------------------\n\nusing System.Reflection;\nusing System.Runtime.InteropServices;\n\n// General Information about an assembly is controlled through the following \n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n\n[assembly: AssemblyTitle(\"Mocks\")]\n[assembly: AssemblyDescription(\"\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyCompany(\"\")]\n[assembly: AssemblyProduct(\"Mocks\")]\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n\n// Setting ComVisible to false makes the types in this assembly not visible \n// to COM components.  If you need to access a type in this assembly from \n// COM, set the ComVisible attribute to true on that type.\n\n[assembly: ComVisible(false)]\n\n// The following GUID is for the ID of the typelib if this project is exposed to COM\n\n[assembly: Guid(\"00e00484-bd00-40cd-b2cc-1cfa8e893972\")]\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version \n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers \n// by using the '*' as shown below:\n// [assembly: AssemblyVersion(\"1.0.*\")]\n\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/Mocks/app.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Services\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Data\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Internal\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>"
  },
  {
    "path": "ReferenceApp/Mocks/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/Nuget.Config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <config>\r\n    <add key=\"repositorypath\" value=\"packages\" />\r\n  </config>\r\n</configuration>\r\n"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/ActorEventSource.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Actor\r\n{\r\n    using System;\r\n    using System.Diagnostics.Tracing;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Actors.Runtime;\r\n\r\n    [EventSource(Name = \"MyCompany-Web_UIApplication-RestockRequestActor\")]\r\n    internal sealed class ActorEventSource : EventSource\r\n    {\r\n        private const int MessageEventId = 1;\r\n\r\n        // For very high-frequency events it might be advantageous to raise events using WriteEventCore API.\r\n        // This results in more efficient parameter handling, but requires explicit allocation of EventData structure and unsafe code.\r\n        // To enable this code path, define UNSAFE conditional compilation symbol and turn on unsafe code support in project properties.\r\n        private const int ActorMessageEventId = 2;\r\n\r\n        private const int ActorHostInitializationFailedEventId = 3;\r\n        public static readonly ActorEventSource Current = new ActorEventSource();\r\n\r\n        static ActorEventSource()\r\n        {\r\n            // A workaround for the problem where ETW activities do not get tracked until Tasks infrastructure is initialized.\r\n            // This problem will be fixed in .NET Framework 4.6.2.\r\n            Task.Run(() => { }).Wait();\r\n        }\r\n\r\n        // Instance constructor is private to enforce singleton semantics\r\n        private ActorEventSource() : base()\r\n        {\r\n        }\r\n\r\n        // Define an instance method for each event you want to record and apply an [Event] attribute to it.\r\n        // The method name is the name of the event.\r\n        // Pass any parameters you want to record with the event (only primitive integer types, DateTime, Guid & string are allowed).\r\n        // Each event method implementation should check whether the event source is enabled, and if it is, call WriteEvent() method to raise the event.\r\n        // The number and types of arguments passed to every event method must exactly match what is passed to WriteEvent().\r\n        // Put [NonEvent] attribute on all methods that do not define an event.\r\n        // For more information see https://msdn.microsoft.com/en-us/library/system.diagnostics.tracing.eventsource.aspx\r\n\r\n        [NonEvent]\r\n        public void Message(string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                this.Message(finalMessage);\r\n            }\r\n        }\r\n\r\n        [Event(MessageEventId, Level = EventLevel.Informational, Message = \"{0}\")]\r\n        public void Message(string message)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                this.WriteEvent(MessageEventId, message);\r\n            }\r\n        }\r\n\r\n        [NonEvent]\r\n        public void ActorMessage(Actor actor, string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled()\r\n                && actor.Id != null\r\n                && actor.ActorService != null\r\n                && actor.ActorService.Context != null\r\n                && actor.ActorService.Context.CodePackageActivationContext != null)\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                this.ActorMessage(\r\n                    actor.GetType().ToString(),\r\n                    actor.Id.ToString(),\r\n                    actor.ActorService.Context.CodePackageActivationContext.ApplicationTypeName,\r\n                    actor.ActorService.Context.CodePackageActivationContext.ApplicationName,\r\n                    actor.ActorService.Context.ServiceTypeName,\r\n                    actor.ActorService.Context.ServiceName.ToString(),\r\n                    actor.ActorService.Context.PartitionId,\r\n                    actor.ActorService.Context.ReplicaId,\r\n                    actor.ActorService.Context.NodeContext.NodeName,\r\n                    finalMessage);\r\n            }\r\n        }\r\n\r\n        [Event(ActorHostInitializationFailedEventId, Level = EventLevel.Error, Message = \"Actor host initialization failed\",\r\n            Keywords = Keywords.HostInitialization)]\r\n        public void ActorHostInitializationFailed(string exception)\r\n        {\r\n            this.WriteEvent(ActorHostInitializationFailedEventId, exception);\r\n        }\r\n\r\n        [Event(ActorMessageEventId, Level = EventLevel.Informational, Message = \"{9}\")]\r\n        private\r\n        void ActorMessage(\r\n            string actorType,\r\n            string actorId,\r\n            string applicationTypeName,\r\n            string applicationName,\r\n            string serviceTypeName,\r\n            string serviceName,\r\n            Guid partitionId,\r\n            long replicaOrInstanceId,\r\n            string nodeName,\r\n            string message)\r\n        {\r\n            this.WriteEvent(\r\n                ActorMessageEventId,\r\n                actorType,\r\n                actorId,\r\n                applicationTypeName,\r\n                applicationName,\r\n                serviceTypeName,\r\n                serviceName,\r\n                partitionId,\r\n                replicaOrInstanceId,\r\n                nodeName,\r\n                message);\r\n        }\r\n\r\n        // Event keywords can be used to categorize events. \r\n        // Each keyword is a bit flag. A single event can be associated with multiple keywords (via EventAttribute.Keywords property).\r\n        // Keywords must be defined as a public class named 'Keywords' inside EventSource that uses them.\r\n        public static class Keywords\r\n        {\r\n            public const EventKeywords HostInitialization = (EventKeywords) 0x1L;\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/App.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <startup>\r\n    <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.5.2\" />\r\n  </startup>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>\r\n"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/PackageRoot/Config/Settings.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Settings xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\r\n  <Section Name=\"RestockRequestActorServiceReplicatorConfig\">\r\n    <Parameter Name=\"ReplicatorEndpoint\" Value=\"RestockRequestActorServiceReplicatorEndpoint\" />\r\n    <Parameter Name=\"BatchAcknowledgementInterval\" Value=\"0.005\" />\r\n  </Section>\r\n  <Section Name=\"RestockRequestActorServiceReplicatorSecurityConfig\">\r\n    <Parameter Name=\"CredentialType\" Value=\"None\" />\r\n  </Section>\r\n</Settings>"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/PackageRoot/ServiceManifest.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<ServiceManifest xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Name=\"RestockRequest.ActorPkg\" Version=\"1.0.0\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\r\n  <ServiceTypes>\r\n    <StatefulServiceType ServiceTypeName=\"RestockRequestActorServiceType\">\r\n      <Extensions>\r\n        <Extension Name=\"__GeneratedServiceType__\" GeneratedId=\"cd8c75cc-03eb-4aec-ab00-dd3cc5048d9d|None\">\r\n          <GeneratedNames xmlns=\"http://schemas.microsoft.com/2015/03/fabact-no-schema\">\r\n            <DefaultService Name=\"RestockRequestActorService\" />\r\n            <ServiceEndpoint Name=\"RestockRequestActorServiceEndpoint\" />\r\n            <ReplicatorEndpoint Name=\"RestockRequestActorServiceReplicatorEndpoint\" />\r\n            <ReplicatorConfigSection Name=\"RestockRequestActorServiceReplicatorConfig\" />\r\n            <ReplicatorSecurityConfigSection Name=\"RestockRequestActorServiceReplicatorSecurityConfig\" />\r\n            <StoreConfigSection Name=\"RestockRequestActorServiceLocalStoreConfig\" />\r\n          </GeneratedNames>\r\n        </Extension>\r\n      </Extensions>\r\n    </StatefulServiceType>\r\n  </ServiceTypes>\r\n  <CodePackage Name=\"Code\" Version=\"1.0.0\">\r\n    <EntryPoint>\r\n      <ExeHost>\r\n        <Program>RestockRequest.Actor.exe</Program>\r\n      </ExeHost>\r\n    </EntryPoint>\r\n  </CodePackage>\r\n  <ConfigPackage Name=\"Config\" Version=\"1.0.0\" />\r\n  <Resources>\r\n    <Endpoints>\r\n      <Endpoint Name=\"RestockRequestActorServiceEndpoint\" />\r\n      <Endpoint Name=\"RestockRequestActorServiceReplicatorEndpoint\" />\r\n    </Endpoints>\r\n  </Resources>\r\n</ServiceManifest>"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"RestockRequestActor\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"RestockRequestActor\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"4c5acf3b-e6d1-4fbd-8b23-a9fa7ba6326e\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/RestockRequest.Actor.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{4C5ACF3B-E6D1-4FBD-8B23-A9FA7BA6326E}</ProjectGuid>\r\n    <OutputType>Exe</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>RestockRequest.Actor</RootNamespace>\r\n    <AssemblyName>RestockRequest.Actor</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n    <TargetFrameworkProfile />\r\n    <IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <UpdateServiceFabricManifestEnabled>true</UpdateServiceFabricManifestEnabled>\r\n    <ServicePackagePath>PackageRoot</ServicePackagePath>\r\n    <ServicePackagePrefix>$(MSBuildProjectName)</ServicePackagePrefix>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x64' \">\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <DebugType>full</DebugType>\r\n    <Optimize>false</Optimize>\r\n    <OutputPath>bin\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|x64' \">\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <DebugType>pdbonly</DebugType>\r\n    <Optimize>true</Optimize>\r\n    <OutputPath>bin\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"RestockRequestReminderNames.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n    <Compile Include=\"RestockRequestActor.cs\" />\r\n    <Compile Include=\"RestockRequestActorState.cs\" />\r\n    <Compile Include=\"ServiceHost.cs\" />\r\n    <Compile Include=\"ActorEventSource.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"PackageRoot\\ServiceManifest.xml\" />\r\n    <None Include=\"PackageRoot\\Config\\Settings.xml\" />\r\n    <None Include=\"App.config\">\r\n      <SubType>Designer</SubType>\r\n    </None>\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\RestockRequest.Domain\\RestockRequest.Domain.csproj\">\r\n      <Project>{A44FC2C5-6781-447E-80F5-7265B960B36A}</Project>\r\n      <Name>RestockRequest.Domain</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n</Project>"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/RestockRequestActor.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Actor\r\n{\r\n    using System;\r\n    using System.Fabric;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Actors.Runtime;\r\n    using Microsoft.ServiceFabric.Data;\r\n    using RestockRequest.Domain;\r\n    using Microsoft.ServiceFabric.Actors;\r\n\r\n    //internal class RestockRequestActor : StatefulActor<RestockRequestActorState>, IRestockRequestActor, IRemindable\r\n    internal class RestockRequestActor : Actor, IRestockRequestActor, IRemindable\r\n    {\r\n        // The duration the verification at beginning of each pipeline step takes\r\n        private static TimeSpan PipelineStageVerificationDelay = TimeSpan.FromSeconds(5);\r\n        // The duration each step of the pipeline takes\r\n        private static TimeSpan PipelineStageProcessingDuration = TimeSpan.FromSeconds(10);\r\n\r\n        private static string ActorStatePropertyName = \"RestockRequestActorStatePropertyName\";\r\n\r\n        public RestockRequestActor(ActorService actorService, ActorId actorId)\r\n            : base (actorService, actorId)\r\n        { }\r\n\r\n        public Task ReceiveReminderAsync(string reminderName, byte[] context, TimeSpan dueTime, TimeSpan period)\r\n        {\r\n            switch (reminderName)\r\n            {\r\n                case RestockRequestReminderNames.RestockPipelineChangeReminderName:\r\n                    return this.RestockPipeline();\r\n\r\n                default:\r\n                    // We should never arrive here normally. The system won't call reminders that don't exist. \r\n                    // But for our own sake in case we add a new reminder somewhere and forget to handle it, this will remind us.\r\n                    throw new InvalidOperationException(\"Unknown reminder: \" + reminderName);\r\n            }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Accepts a restock request and changes the Actor's state accordingly. The request is processed\r\n        /// async and the caller will be notified when the processing is done. \r\n        /// </summary>\r\n        /// <param name=\"request\"></param>\r\n        /// <returns></returns>\r\n        public async Task AddRestockRequestAsync(RestockRequest request)\r\n        {\r\n            RestockRequestActorState state = await this.StateManager.GetStateAsync<RestockRequestActorState>(ActorStatePropertyName);\r\n\r\n            if (state.IsStarted()) //Don't accept a request that is already started\r\n            {\r\n                ActorEventSource.Current.Message(string.Format(\"RestockRequestActor: {0}: Can't accept restock request in this state\", state));\r\n                throw new InvalidOperationException(string.Format(\"{0}: Can't accept restock request in this state\", state));\r\n            }\r\n\r\n            // Accept the request\r\n            ActorEventSource.Current.ActorMessage(this, \"RestockRequestActor: Accept update quantity request {0}\", request);\r\n\r\n            state.Status = RestockRequestStatus.Accepted;\r\n            state.Request = request;\r\n\r\n            await this.StateManager.SetStateAsync<RestockRequestActorState>(ActorStatePropertyName, state);\r\n\r\n            // Start a reminder to go through the processing pipeline.\r\n            // A reminder keeps the actor from being garbage collected due to lack of use, \r\n            // which works better than a timer in this case.\r\n            await this.RegisterReminderAsync(\r\n                RestockRequestReminderNames.RestockPipelineChangeReminderName,\r\n                null,\r\n                PipelineStageVerificationDelay,\r\n                PipelineStageProcessingDuration);\r\n\r\n            return;\r\n        }\r\n\r\n        protected override async Task OnActivateAsync()\r\n        {\r\n            ConditionalValue<RestockRequestActorState> state = await this.StateManager.TryGetStateAsync<RestockRequestActorState>(ActorStatePropertyName);\r\n\r\n            if (!state.HasValue)\r\n            {\r\n                await this.StateManager.SetStateAsync<RestockRequestActorState>(ActorStatePropertyName, new RestockRequestActorState());\r\n                ActorEventSource.Current.ActorMessage(this, \"RestockRequestActor: State initialized\");\r\n            }\r\n\r\n            return;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Simulates the processing of a restock request by advancing the processing status each time this method is invoked\r\n        /// until it reaches the complete stage.\r\n        /// </summary>\r\n        /// <returns></returns>\r\n        internal async Task RestockPipeline()\r\n        {\r\n            RestockRequestActorState state = await this.StateManager.GetStateAsync<RestockRequestActorState>(ActorStatePropertyName);\r\n\r\n            ActorEventSource.Current.ActorMessage(this, \"RestockRequestActor: {0}: Pipeline change reminder\", state);\r\n\r\n            switch (state.Status)\r\n            {\r\n                case RestockRequestStatus.Accepted:\r\n\r\n                    // Change to next step and let it \"execute\" until the reminder fires again\r\n                    state.Status = RestockRequestStatus.Manufacturing;\r\n                    break;\r\n\r\n                case RestockRequestStatus.Manufacturing:\r\n\r\n                    // Changet the step to completed to indicate the \"processing\" is complete.\r\n                    state.Status = RestockRequestStatus.Completed;\r\n\r\n                    // Raise the event to let interested parties (RestockRequestManager) know that the restock is complete\r\n                    this.SignalRequestStatusChange(state);\r\n\r\n                    // Done, so unregister the reminder\r\n                    await this.UnregisterRestockPipelineChangeReminderAsync();\r\n                    break;\r\n\r\n                default:\r\n                    throw new InvalidOperationException(string.Format(\"{0}: remainder received in invalid status\", state));\r\n            }\r\n\r\n            await this.StateManager.SetStateAsync<RestockRequestActorState>(ActorStatePropertyName, state);\r\n            return;\r\n        }\r\n\r\n        private void SignalRequestStatusChange(RestockRequestActorState state)\r\n        {\r\n            ActorEventSource.Current.ActorMessage(this, \"RestockRequestActor: {0}: Raise event for state change\", state);\r\n\r\n            IRestockRequestEvents events = this.GetEvent<IRestockRequestEvents>();\r\n            events.RestockRequestCompleted(this.Id, state.Request);\r\n        }\r\n\r\n        private Task UnregisterRestockPipelineChangeReminderAsync()\r\n        {\r\n            IActorReminder reminder;\r\n            try\r\n            {\r\n                reminder = this.GetReminder(RestockRequestReminderNames.RestockPipelineChangeReminderName);\r\n            }\r\n            catch (FabricException)\r\n            {\r\n                reminder = null;\r\n            }\r\n\r\n            return (reminder == null) ? Task.FromResult(true) : this.UnregisterReminderAsync(reminder);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/RestockRequestActorState.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Actor\r\n{\r\n    using System;\r\n    using System.Runtime.Serialization;\r\n    using RestockRequest.Domain;\r\n\r\n    [DataContract]\r\n    internal sealed class RestockRequestActorState\r\n    {\r\n        [DataMember]\r\n        public RestockRequest Request { get; set; }\r\n\r\n        [DataMember]\r\n        public RestockRequestStatus Status { get; set; }\r\n\r\n        public bool IsStarted()\r\n        {\r\n            return this.Status == RestockRequestStatus.Manufacturing ||\r\n                   this.Status == RestockRequestStatus.Accepted;\r\n        }\r\n\r\n        public override string ToString()\r\n        {\r\n            if (this.Request == null)\r\n            {\r\n                return String.Format(\"{0}\", this.Status);\r\n            }\r\n\r\n            return string.Format(\"{0}: {1}\", this.Request, this.Status);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/RestockRequestReminderNames.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Actor\r\n{\r\n    internal static class RestockRequestReminderNames\r\n    {\r\n        public const string RestockPipelineChangeReminderName = \"RestockPipelineChange\";\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/ServiceHost.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Actor\r\n{\r\n    using System;\r\n    using System.Threading;\r\n    using Microsoft.ServiceFabric.Actors.Runtime;\r\n\r\n    public class ServiceHost\r\n    {\r\n        public static void Main(string[] args)\r\n        {\r\n            try\r\n            {\r\n                ActorRuntime.RegisterActorAsync<RestockRequestActor>().GetAwaiter().GetResult();\r\n\r\n                Thread.Sleep(Timeout.Infinite);\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ActorEventSource.Current.ActorHostInitializationFailed(e.ToString());\r\n                throw;\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Actor/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/RestockRequest.Domain/IRestockRequestActor.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Domain\r\n{\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Actors;\r\n\r\n    public interface IRestockRequestActor : IActor, IActorEventPublisher<IRestockRequestEvents>\r\n    {\r\n        Task AddRestockRequestAsync(RestockRequest request);\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Domain/IRestockRequestEvents.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Domain\r\n{\r\n    using Microsoft.ServiceFabric.Actors;\r\n\r\n    public interface IRestockRequestEvents : IActorEvents\r\n    {\r\n        // Notify that the actor idenfitied by actor id has completed the request.\r\n        // The recipient can find the actor id based on the request item id, but we want to avoid another lookup\r\n        void RestockRequestCompleted(ActorId actorId, RestockRequest request);\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Domain/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"RestockRequestActor.Interfaces\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"RestockRequestActor.Interfaces\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"a44fc2c5-6781-447e-80f5-7265b960b36a\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/RestockRequest.Domain/RestockRequest.Domain.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{A44FC2C5-6781-447E-80F5-7265B960B36A}</ProjectGuid>\r\n    <OutputType>Library</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>RestockRequest.Domain</RootNamespace>\r\n    <AssemblyName>RestockRequest.Domain</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <DebugType>full</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\r\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <Optimize>true</Optimize>\r\n    <DebugType>pdbonly</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"IRestockRequestEvents.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n    <Compile Include=\"IRestockRequestActor.cs\" />\r\n    <Compile Include=\"RestockRequest.cs\" />\r\n    <Compile Include=\"RestockRequestStatus.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\">\r\n      <Project>{7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae}</Project>\r\n      <Name>Inventory.Domain</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"app.config\" />\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n</Project>"
  },
  {
    "path": "ReferenceApp/RestockRequest.Domain/RestockRequest.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Domain\r\n{\r\n    using System;\r\n    using System.Runtime.Serialization;\r\n    using Inventory.Domain;\r\n\r\n    [DataContract]\r\n    public sealed class RestockRequest\r\n    {\r\n        public RestockRequest(InventoryItemId itemId, int quantity)\r\n        {\r\n            this.ItemId = itemId;\r\n            this.Quantity = quantity;\r\n        }\r\n\r\n        [DataMember]\r\n        public InventoryItemId ItemId { get; private set; }\r\n\r\n        [DataMember]\r\n        public int Quantity { get; private set; }\r\n\r\n        public override string ToString()\r\n        {\r\n            return String.Format(\"ItemId: {0}, Quantity: {1}\", this.ItemId, this.Quantity);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Domain/RestockRequestStatus.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequest.Domain\r\n{\r\n    public enum RestockRequestStatus\r\n    {\r\n        NA = 0,\r\n        Accepted,\r\n        Manufacturing,\r\n        Completed,\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequest.Domain/app.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>"
  },
  {
    "path": "ReferenceApp/RestockRequest.Domain/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Domain/IRestockRequestManager.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequestManager.Domain\r\n{\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Services.Remoting;\r\n    using RestockRequest.Domain;\r\n\r\n    public interface IRestockRequestManager : IService\r\n    {\r\n        Task AddRestockRequestAsync(RestockRequest request);\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Domain/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"RestockRequestManager.Domain\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"RestockRequestManager.Domain\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"4162f266-d657-4143-aa62-626c10d23561\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Domain/RestockRequestManager.Domain.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{4162F266-D657-4143-AA62-626C10D23561}</ProjectGuid>\r\n    <OutputType>Library</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>RestockRequestManager.Domain</RootNamespace>\r\n    <AssemblyName>RestockRequestManager.Domain</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <DebugType>full</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\r\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <Optimize>true</Optimize>\r\n    <DebugType>pdbonly</DebugType>\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n    <Reference Include=\"System.Xml.Linq\" />\r\n    <Reference Include=\"System.Data.DataSetExtensions\" />\r\n    <Reference Include=\"Microsoft.CSharp\" />\r\n    <Reference Include=\"System.Data\" />\r\n    <Reference Include=\"System.Net.Http\" />\r\n    <Reference Include=\"System.Xml\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"IRestockRequestManager.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\RestockRequest.Domain\\RestockRequest.Domain.csproj\">\r\n      <Project>{a44fc2c5-6781-447e-80f5-7265b960b36a}</Project>\r\n      <Name>RestockRequest.Domain</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"app.config\" />\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r\n       Other similar extension points exist, see Microsoft.Common.targets.\r\n  <Target Name=\"BeforeBuild\">\r\n  </Target>\r\n  <Target Name=\"AfterBuild\">\r\n  </Target>\r\n  -->\r\n</Project>"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Domain/app.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Services\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Data\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"Microsoft.ServiceFabric.Internal\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Domain/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/App.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <startup>\r\n    <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.5.2\" />\r\n  </startup>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Fabric\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n        <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\r\n      </dependentAssembly>\r\n    </assemblyBinding>\r\n  </runtime>\r\n</configuration>"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/PackageRoot/Config/Settings.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<Settings xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\n  <!-- This is used by the StateManager's replicator. -->\n  <Section Name=\"ReplicatorConfig\">\n    <Parameter Name=\"ReplicatorEndpoint\" Value=\"ReplicatorEndpoint\" />\n  </Section>\n  <!-- This is used for securing StateManager's replication traffic. -->\n  <Section Name=\"ReplicatorSecurityConfig\" />\n\n  <!-- Add your custom configuration sections and parameters here. -->\n  <!--\n  <Section Name=\"MyConfigSection\">\n    <Parameter Name=\"MyParameter\" Value=\"Value1\" />\n  </Section>\n  -->\n</Settings>\n"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/PackageRoot/ServiceManifest.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ServiceManifest Name=\"RestockRequestManager.ServicePkg\"\n                 Version=\"1.0.0\"\n                 xmlns=\"http://schemas.microsoft.com/2011/01/fabric\"\n                 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n                 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n  <ServiceTypes>\n    <!-- This is the name of your ServiceType. \n         This name must match the string used in RegisterServiceType call in Program.cs. -->\n    <StatefulServiceType ServiceTypeName=\"RestockRequestManagerServiceType\" HasPersistedState=\"true\" />\n  </ServiceTypes>\n\n  <!-- Code package is your service executable. -->\n  <CodePackage Name=\"Code\" Version=\"1.0.0\">\n    <EntryPoint>\n      <ExeHost>\n        <Program>RestockRequestManager.Service.exe</Program>\n      </ExeHost>\n    </EntryPoint>\n  </CodePackage>\n\n  <!-- Config package is the contents of the Config directoy under PackageRoot that contains an \n       independently-updateable and versioned set of custom configuration settings for your service. -->\n  <ConfigPackage Name=\"Config\" Version=\"1.0.0\" />\n\n  <Resources>\n    <Endpoints>\n      <!-- This endpoint is used by the communication listener to obtain the port on which to \n           listen. Please note that if your service is partitioned, this port is shared with \n           replicas of different partitions that are placed in your code. -->\n      <Endpoint Name=\"ServiceEndpoint\" />\n\n      <!-- This endpoint is used by the replicator for replicating the state of your service.\n           This endpoint is configured through a ReplicatorSettings config section in the Settings.xml\n           file under the ConfigPackage. -->\n      <Endpoint Name=\"ReplicatorEndpoint\" />\n    </Endpoints>\n  </Resources>\n</ServiceManifest>\n"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/Program.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequestManager.Service\r\n{\r\n    using System;\r\n    using System.Threading;\r\n    using Microsoft.ServiceFabric.Services.Runtime;\r\n\r\n    public class Program\r\n    {\r\n        public static void Main(string[] args)\r\n        {\r\n            try\r\n            {\r\n                ServiceRuntime.RegisterServiceAsync(\"RestockRequestManagerServiceType\", (context) => new RestockRequestManagerService(context))\r\n                    .GetAwaiter()\r\n                    .GetResult();\r\n\r\n                Thread.Sleep(Timeout.Infinite);\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());\r\n                throw;\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/Properties/AssemblyInfo.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nusing System.Reflection;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n\r\n[assembly: AssemblyTitle(\"RestockRequestManagerService\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"\")]\r\n[assembly: AssemblyProduct(\"RestockRequestManagerService\")]\r\n[assembly: AssemblyCopyright(\"Copyright ©  2015\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n\r\n[assembly: Guid(\"7c404bc4-7589-488c-ab09-876e5b33b641\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/RestockRequestManager.Service.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x64</Platform>\r\n    <ProjectGuid>{7C404BC4-7589-488C-AB09-876E5B33B641}</ProjectGuid>\r\n    <OutputType>Exe</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>RestockRequestManager.Service</RootNamespace>\r\n    <AssemblyName>RestockRequestManager.Service</AssemblyName>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <FileAlignment>512</FileAlignment>\r\n    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\r\n    <NuGetPackageImportStamp>\r\n    </NuGetPackageImportStamp>\r\n    <IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x64' \">\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <DebugType>full</DebugType>\r\n    <Optimize>false</Optimize>\r\n    <OutputPath>bin\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|x64' \">\r\n    <PlatformTarget>x64</PlatformTarget>\r\n    <DebugType>pdbonly</DebugType>\r\n    <Optimize>true</Optimize>\r\n    <OutputPath>bin\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <AdditionalFileItemNames>$(AdditionalFileItemNames);None</AdditionalFileItemNames>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Actors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Actors.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Data.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Data.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Data.Interfaces.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.FabricTransport, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.FabricTransport.Internal.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.FabricTransport.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\Microsoft.ServiceFabric.Internal.Strings.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"Microsoft.ServiceFabric.Services.Remoting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.Services.Remoting.2.6.204\\lib\\net45\\Microsoft.ServiceFabric.Services.Remoting.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Management.ServiceModel.XmlSerializers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Management.ServiceModel.XmlSerializers.dll</HintPath>\r\n    </Reference>\r\n    <Reference Include=\"System.Fabric.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64\">\r\n      <HintPath>..\\packages\\Microsoft.ServiceFabric.5.6.204\\lib\\net45\\System.Fabric.Strings.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System.Runtime.Serialization\" />\r\n    <Reference Include=\"System.ServiceModel\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n    <Compile Include=\"RestockRequestManagerService.cs\" />\r\n    <Compile Include=\"Program.cs\" />\r\n    <Compile Include=\"ServiceEventSource.cs\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"PackageRoot\\Config\\Settings.xml\" />\r\n    <None Include=\"PackageRoot\\ServiceManifest.xml\" />\r\n    <None Include=\"App.config\">\r\n      <SubType>Designer</SubType>\r\n    </None>\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\">\r\n      <Project>{9ec0063f-489e-43fe-94b5-bf5f89977cd3}</Project>\r\n      <Name>Common</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\">\r\n      <Project>{7e9c2dfd-71a5-496d-aa4d-5ec53eaeb9ae}</Project>\r\n      <Name>Inventory.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\RestockRequest.Domain\\RestockRequest.Domain.csproj\">\r\n      <Project>{a44fc2c5-6781-447e-80f5-7265b960b36a}</Project>\r\n      <Name>RestockRequest.Domain</Name>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"..\\RestockRequestManager.Domain\\RestockRequestManager.Domain.csproj\">\r\n      <Project>{4162f266-d657-4143-aa62-626c10d23561}</Project>\r\n      <Name>RestockRequestManager.Domain</Name>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <Import Project=\"..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets\" Condition=\"Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" />\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', '..\\packages\\Microsoft.ServiceFabric.Actors.2.6.204\\build\\Microsoft.ServiceFabric.Actors.targets'))\" />\r\n  </Target>\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \n       Other similar extension points exist, see Microsoft.Common.targets.\n  <Target Name=\"BeforeBuild\">\n  </Target>\n  <Target Name=\"AfterBuild\">\n  </Target>\n  -->\r\n</Project>"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/RestockRequestManagerService.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequestManager.Service\r\n{\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Fabric;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n    using Common;\r\n    using Inventory.Domain;\r\n    using Microsoft.ServiceFabric.Actors;\r\n    using Microsoft.ServiceFabric.Actors.Client;\r\n    using Microsoft.ServiceFabric.Data;\r\n    using Microsoft.ServiceFabric.Data.Collections;\r\n    using Microsoft.ServiceFabric.Services.Communication.Runtime;\r\n    using Microsoft.ServiceFabric.Services.Remoting.Client;\r\n    using Microsoft.ServiceFabric.Services.Remoting.Runtime;\r\n    using Microsoft.ServiceFabric.Services.Runtime;\r\n    using RestockRequest.Domain;\r\n    using RestockRequestManager.Domain;\r\n\r\n    internal class RestockRequestManagerService : StatefulService, IRestockRequestManager, IRestockRequestEvents\r\n    {\r\n        //TODO: Look@ use of these variables.\r\n        private const string ItemIdToActorIdMapName = \"actorIdToMapName\"; //Name of ItemId-ActorId IReliableDictionary\r\n        private const string CompletedRequestsQueueName = \"completedRequests\"; //Name of CompletedRequests IReliableQueue\r\n        private const string InventoryServiceName = \"InventoryService\";\r\n        private static TimeSpan CompletedRequestsBatchInterval = TimeSpan.FromSeconds(1);\r\n        private static TimeSpan TxTimeout = TimeSpan.FromSeconds(4);\r\n\r\n        public RestockRequestManagerService(StatefulServiceContext serviceContext) : base(serviceContext)\r\n        {\r\n        }\r\n\r\n        public RestockRequestManagerService(StatefulServiceContext serviceContext, IReliableStateManagerReplica reliableStateManagerReplica)\r\n            : base(serviceContext, reliableStateManagerReplica)\r\n        {\r\n        }\r\n\r\n        public string ApplicationName\r\n        {\r\n            get { return this.Context.CodePackageActivationContext.ApplicationName; }\r\n        }\r\n\r\n        /// <summary>\r\n        /// This method uses an IReliableQueue to store completed RestockRequests which are later sent to the client using batch processing.\r\n        /// We could send the request immediately but we prefer to minimize traffic back to the Inventory Service by batching multiple requests\r\n        /// in one trip. \r\n        /// </summary>\r\n        /// <param name=\"actorId\"></param>\r\n        /// <param name=\"request\"></param>\r\n        public async void RestockRequestCompleted(ActorId actorId, RestockRequest request)\r\n        {\r\n            IReliableQueue<RestockRequest> completedRequests = await this.StateManager.GetOrAddAsync<IReliableQueue<RestockRequest>>(CompletedRequestsQueueName);\r\n\r\n            using (ITransaction tx = this.StateManager.CreateTransaction())\r\n            {\r\n                await completedRequests.EnqueueAsync(tx, request);\r\n                await tx.CommitAsync();\r\n            }\r\n\r\n            IRestockRequestActor restockRequestActor = ActorProxy.Create<IRestockRequestActor>(actorId, this.ApplicationName);\r\n            await restockRequestActor.UnsubscribeAsync<IRestockRequestEvents>(this); //QUESTION:What does this method do?\r\n        }\r\n\r\n        /// <summary>\r\n        /// This method activates an actor to fulfill the RestockRequest.\r\n        /// </summary>\r\n        /// <param name=\"request\"></param>\r\n        /// <returns></returns>\r\n        public async Task AddRestockRequestAsync(RestockRequest request)\r\n        {\r\n            try\r\n            {\r\n                //Get dictionary of Restock Requests\r\n                IReliableDictionary<InventoryItemId, ActorId> requestDictionary =\r\n                    await this.StateManager.GetOrAddAsync<IReliableDictionary<InventoryItemId, ActorId>>(ItemIdToActorIdMapName);\r\n\r\n                ActorId actorId = ActorId.CreateRandom();\r\n\r\n                try\r\n                {\r\n                    using (ITransaction tx = this.StateManager.CreateTransaction())\r\n                    {\r\n                        await requestDictionary.AddAsync(tx, request.ItemId, actorId);\r\n                        await tx.CommitAsync();\r\n                    }\r\n                }\r\n                catch (ArgumentException)\r\n                {\r\n                    // restock request already exists\r\n                    return;\r\n                }\r\n\r\n                // Create actor proxy and send the request\r\n                IRestockRequestActor restockRequestActor = ActorProxy.Create<IRestockRequestActor>(actorId, this.ApplicationName);\r\n\r\n                await restockRequestActor.AddRestockRequestAsync(request);\r\n\r\n                // Successfully added, register for event notifications for completion\r\n                await restockRequestActor.SubscribeAsync<IRestockRequestEvents>(this);\r\n\r\n                ServiceEventSource.Current.ServiceMessage(this, \"Created restock request. Item ID: {0}. Actor ID: {1}\", request.ItemId, actorId);\r\n            }\r\n            catch (InvalidOperationException ex)\r\n            {\r\n                ServiceEventSource.Current.Message(string.Format(\"RestockRequestManagerService: Actor rejected {0}: {1}\", request, ex));\r\n                throw;\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                ServiceEventSource.Current.Message(string.Format(\"RestockRequestManagerService: Exception {0}: {1}\", request, ex));\r\n                throw;\r\n            }\r\n        }\r\n\r\n\r\n        protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()\r\n        {\r\n            return new[]\r\n            {\r\n                new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context))\r\n            };\r\n        }\r\n\r\n        /// <summary>\r\n        /// Drains the queue of completed restock requests sends them to InventoryService.\r\n        /// </summary>\r\n        /// <param name=\"cancellationToken\"></param>\r\n        /// <returns></returns>\r\n        protected override async Task RunAsync(CancellationToken cancellationToken)\r\n        {\r\n            IReliableQueue<RestockRequest> completedRequests = await this.StateManager.GetOrAddAsync<IReliableQueue<RestockRequest>>(CompletedRequestsQueueName);\r\n\r\n            while (!cancellationToken.IsCancellationRequested)\r\n            {\r\n                using (ITransaction tx = this.StateManager.CreateTransaction())\r\n                {\r\n                    ConditionalValue<RestockRequest> result = await completedRequests.TryDequeueAsync(tx, TxTimeout, cancellationToken);\r\n\r\n                    if (result.HasValue)\r\n                    {\r\n                        ServiceUriBuilder builder = new ServiceUriBuilder(InventoryServiceName);\r\n                        IInventoryService inventoryService = ServiceProxy.Create<IInventoryService>(builder.ToUri(), result.Value.ItemId.GetPartitionKey());\r\n\r\n                        await inventoryService.AddStockAsync(result.Value.ItemId, result.Value.Quantity);\r\n\r\n                        ServiceEventSource.Current.ServiceMessage(\r\n                            this,\r\n                            \"Adding stock to inventory service. ID: {0}. Quantity: {1}\",\r\n                            result.Value.ItemId,\r\n                            result.Value.Quantity);\r\n                    }\r\n\r\n                    // This commits the dequeue operations.\r\n                    // If the request to add the stock to the inventory service throws, this commit will not execute\r\n                    // and the items will remain on the queue, so we can be sure that we didn't dequeue items\r\n                    // that didn't get saved successfully in the inventory service.\r\n                    // However there is a very small chance that the stock was added to the inventory service successfully,\r\n                    // but service execution stopped before reaching this commit (machine crash, for example).\r\n                    await tx.CommitAsync();\r\n                }\r\n\r\n                await Task.Delay(CompletedRequestsBatchInterval, cancellationToken);\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/ServiceEventSource.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace RestockRequestManager.Service\r\n{\r\n    using System;\r\n    using System.Diagnostics.Tracing;\r\n    using System.Threading.Tasks;\r\n    using Microsoft.ServiceFabric.Services.Runtime;\r\n\r\n    [EventSource(Name = \"MyCompany-Web_UIApplication-RestockRequestManagerService\")]\r\n    internal sealed class ServiceEventSource : EventSource\r\n    {\r\n        private const int MessageEventId = 1;\r\n\r\n        // For very high-frequency events it might be advantageous to raise events using WriteEventCore API.\r\n        // This results in more efficient parameter handling, but requires explicit allocation of EventData structure and unsafe code.\r\n        // To enable this code path, define UNSAFE conditional compilation symbol and turn on unsafe code support in project properties.\r\n        private const int ServiceMessageEventId = 2;\r\n\r\n        private const int ServiceTypeRegisteredEventId = 3;\r\n\r\n        private const int ServiceHostInitializationFailedEventId = 4;\r\n\r\n        // A pair of events sharing the same name prefix with a \"Start\"/\"Stop\" suffix implicitly marks boundaries of an event tracing activity.\r\n        // These activities can be automatically picked up by debugging and profiling tools, which can compute their execution time, child activities,\r\n        // and other statistics.\r\n        private const int ServiceRequestStartEventId = 5;\r\n\r\n        private const int ServiceRequestStopEventId = 6;\r\n\r\n        private const int ServiceRequestFailedEventId = 7;\r\n        public static readonly ServiceEventSource Current = new ServiceEventSource();\r\n\r\n        static ServiceEventSource()\r\n        {\r\n            // A workaround for the problem where ETW activities do not get tracked until Tasks infrastructure is initialized.\r\n            // This problem will be fixed in .NET Framework 4.6.2.\r\n            Task.Run(() => { }).Wait();\r\n        }\r\n\r\n        // Instance constructor is private to enforce singleton semantics\r\n        private ServiceEventSource() : base()\r\n        {\r\n        }\r\n\r\n        // Define an instance method for each event you want to record and apply an [Event] attribute to it.\r\n        // The method name is the name of the event.\r\n        // Pass any parameters you want to record with the event (only primitive integer types, DateTime, Guid & string are allowed).\r\n        // Each event method implementation should check whether the event source is enabled, and if it is, call WriteEvent() method to raise the event.\r\n        // The number and types of arguments passed to every event method must exactly match what is passed to WriteEvent().\r\n        // Put [NonEvent] attribute on all methods that do not define an event.\r\n        // For more information see https://msdn.microsoft.com/en-us/library/system.diagnostics.tracing.eventsource.aspx\r\n\r\n        [NonEvent]\r\n        public void Message(string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                this.Message(finalMessage);\r\n            }\r\n        }\r\n\r\n        [Event(MessageEventId, Level = EventLevel.Informational, Message = \"{0}\")]\r\n        public void Message(string message)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                this.WriteEvent(MessageEventId, message);\r\n            }\r\n        }\r\n\r\n        [NonEvent]\r\n        public void ServiceMessage(StatefulService service, string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                this.ServiceMessage(\r\n                    service.Context.ServiceName.ToString(),\r\n                    service.Context.ServiceTypeName,\r\n                    service.Context.ReplicaId,\r\n                    service.Context.PartitionId,\r\n                    service.Context.CodePackageActivationContext.ApplicationName,\r\n                    service.Context.CodePackageActivationContext.ApplicationTypeName,\r\n                    service.Context.NodeContext.NodeName,\r\n                    finalMessage);\r\n            }\r\n        }\r\n\r\n        [Event(ServiceTypeRegisteredEventId, Level = EventLevel.Informational, Message = \"Service host process {0} registered service type {1}\",\r\n            Keywords = Keywords.ServiceInitialization)]\r\n        public void ServiceTypeRegistered(int hostProcessId, string serviceType)\r\n        {\r\n            this.WriteEvent(ServiceTypeRegisteredEventId, hostProcessId, serviceType);\r\n        }\r\n\r\n        [Event(ServiceHostInitializationFailedEventId, Level = EventLevel.Error, Message = \"Service host initialization failed\",\r\n            Keywords = Keywords.ServiceInitialization)]\r\n        public void ServiceHostInitializationFailed(string exception)\r\n        {\r\n            this.WriteEvent(ServiceHostInitializationFailedEventId, exception);\r\n        }\r\n\r\n        [Event(ServiceRequestStartEventId, Level = EventLevel.Informational, Message = \"Service request '{0}' started\", Keywords = Keywords.Requests)]\r\n        public void ServiceRequestStart(string requestTypeName)\r\n        {\r\n            this.WriteEvent(ServiceRequestStartEventId, requestTypeName);\r\n        }\r\n\r\n        [Event(ServiceRequestStopEventId, Level = EventLevel.Informational, Message = \"Service request '{0}' finished\", Keywords = Keywords.Requests)]\r\n        public void ServiceRequestStop(string requestTypeName)\r\n        {\r\n            this.WriteEvent(ServiceRequestStopEventId, requestTypeName);\r\n        }\r\n\r\n        [Event(ServiceRequestFailedEventId, Level = EventLevel.Error, Message = \"Service request '{0}' failed\", Keywords = Keywords.Requests)]\r\n        public void ServiceRequestFailed(string requestTypeName, string exception)\r\n        {\r\n            this.WriteEvent(ServiceRequestFailedEventId, exception);\r\n        }\r\n\r\n        [Event(ServiceMessageEventId, Level = EventLevel.Informational, Message = \"{7}\")]\r\n        private void ServiceMessage(\r\n            string serviceName,\r\n            string serviceTypeName,\r\n            long replicaOrInstanceId,\r\n            Guid partitionId,\r\n            string applicationName,\r\n            string applicationTypeName,\r\n            string nodeName,\r\n            string message)\r\n        {\r\n            this.WriteEvent(\r\n                ServiceMessageEventId,\r\n                serviceName,\r\n                serviceTypeName,\r\n                replicaOrInstanceId,\r\n                partitionId,\r\n                applicationName,\r\n                applicationTypeName,\r\n                nodeName,\r\n                message);\r\n        }\r\n\r\n        // Event keywords can be used to categorize events. \r\n        // Each keyword is a bit flag. A single event can be associated with multiple keywords (via EventAttribute.Keywords property).\r\n        // Keywords must be defined as a public class named 'Keywords' inside EventSource that uses them.\r\n        public static class Keywords\r\n        {\r\n            public const EventKeywords Requests = (EventKeywords) 0x1L;\r\n            public const EventKeywords ServiceInitialization = (EventKeywords) 0x2L;\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/RestockRequestManager.Service/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.ServiceFabric\" version=\"5.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Actors\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Data\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.FabricTransport.Internal\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n  <package id=\"Microsoft.ServiceFabric.Services.Remoting\" version=\"2.6.204\" targetFramework=\"net452\" />\r\n</packages>"
  },
  {
    "path": "ReferenceApp/Web.Service/.bowerrc",
    "content": "{\n  \"directory\": \"wwwroot/lib\"\n}\n"
  },
  {
    "path": "ReferenceApp/Web.Service/App.config",
    "content": "﻿<configuration>\r\n   <runtime>\r\n      <gcServer enabled=\"true\"/>\r\n   </runtime>\r\n</configuration>\r\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Controllers/HomeController.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Web.Service.Controllers\n{\n    public class HomeController : Controller\n    {\n        public IActionResult Index()\n        {\n            return View();\n        }\n\n        public IActionResult Admin()\n        {\n            return View();\n        }\n        \n        public IActionResult OrderConfirmation()\n        {\n            return View();\n        }\n        public IActionResult Error()\n        {\n            return View();\n        }\n    }\n}\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Controllers/InventoryController.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Web.Service.Controllers\r\n{\r\n    using System;\r\n    using System.Threading.Tasks;\r\n    using Common;\r\n    using Inventory.Domain;\r\n    using Microsoft.ServiceFabric.Services.Remoting.Client;\r\n    using Microsoft.AspNetCore.Mvc;\r\n\r\n    public class InventoryController : Controller\r\n    {\r\n        private const string InventoryServiceName = \"InventoryService\";\r\n\r\n\r\n        /// <summary>\r\n        /// Calls and adds a new item to inventory.\r\n        /// </summary>\r\n        /// <param name=\"customerOrderId\"></param>\r\n        ///Description\r\n        ///Price\r\n        ///Number\r\n        ///Reorder Threshold\r\n        ///Max\r\n        /// <returns>String</returns>\r\n        [HttpPost]\r\n        [Route(\"api/inventory/add/{description}/{price}/{number}/{reorderThreshold}/{max}\")]\r\n        public Task<bool> CreateInventoryItem(string description, decimal price, int number, int reorderThreshold, int max)\r\n        {\r\n            InventoryItem i = new InventoryItem(description, price, number, reorderThreshold, max);\r\n\r\n            ServiceUriBuilder builder = new ServiceUriBuilder(InventoryServiceName);\r\n            IInventoryService inventoryServiceClient = ServiceProxy.Create<IInventoryService>(builder.ToUri(), i.Id.GetPartitionKey());\r\n\r\n            try\r\n            {\r\n                return inventoryServiceClient.CreateInventoryItemAsync(i);\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                ServiceEventSource.Current.Message(\"Web Service: Exception creating {0}: {1}\", i, ex);\r\n                throw;\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Web.Service/Controllers/OrdersController.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Web.Service.Controllers\r\n{\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Threading.Tasks;\r\n    using Common;\r\n    using CustomerOrder.Domain;\r\n    using Microsoft.ServiceFabric.Actors;\r\n    using Microsoft.ServiceFabric.Actors.Client;\r\n    using Microsoft.AspNetCore.Mvc;\r\n\r\n    public class OrdersController : Controller\r\n    {\r\n        private const string CustomerOrderServiceName = \"CustomerOrderActorService\";\r\n\r\n        /// <summary>\r\n        /// POST api/orders\r\n        /// Based on a shopping cart passed into the method, PostCheckout creates an actor proxy object to activate an actor instance of CustomerOrderActor,\r\n        /// which is used to represent the state of the customer order. Through the actor proxy, the FulfillOrderAsync method is invoked on the actor\r\n        /// to fulfill the customer order by removing items from inventory.  \r\n        ///        \r\n        /// In the current version of this example, the shopping cart which a customer uses to check out exists\r\n        /// entirely on the client side. A shopping cart, in this example, is therefore stateless and its state is\r\n        /// only committed to memory when a customer order is created and an Actor Id is associated with it. \r\n        /// \r\n        /// Because the status of an order is changed inside the FulfillOrderAsync method, the OrdersController relies\r\n        /// on a separate GetStatus method that the client can call to see if the Status of the order has changed to completed. \r\n        /// There is currently no event notification to the WebUI frontend if an order completes. \r\n        /// \r\n        /// </summary>\r\n        /// <param name=\"cart\"></param>\r\n        /// <returns>Guid to identify the order and allow for status look-up later.</returns>\r\n        [HttpPost]\r\n        [Route(\"api/orders\")]\r\n        public async Task<Guid> PostCheckout(List<CustomerOrderItem> cart)\r\n        {\r\n            ServiceEventSource.Current.Message(\"Now printing cart for POSTCHECKOUT...\");\r\n            foreach (CustomerOrderItem item in cart)\r\n            {\r\n                ServiceEventSource.Current.Message(\"Guid {0}, quantity {1}\", item.ItemId.ToString(), item.Quantity.ToString());\r\n            }\r\n\r\n            Guid orderId = Guid.NewGuid();\r\n            ServiceUriBuilder builder = new ServiceUriBuilder(CustomerOrderServiceName);\r\n\r\n            //We create a unique Guid that is associated with a customer order, as well as with the actor that represents that order's state.\r\n            ICustomerOrderActor customerOrder = ActorProxy.Create<ICustomerOrderActor>(new ActorId(orderId), builder.ToUri());\r\n\r\n            try\r\n            {\r\n                await customerOrder.SubmitOrderAsync(cart);\r\n                ServiceEventSource.Current.Message(\"Customer order submitted successfully. ActorOrderID: {0} created\", orderId);\r\n            }\r\n            catch (InvalidOperationException ex)\r\n            {\r\n                ServiceEventSource.Current.Message(\"Web Service: Actor rejected {0}: {1}\", customerOrder, ex);\r\n                throw;\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                ServiceEventSource.Current.Message(\"Web Service: Exception {0}: {1}\", customerOrder, ex);\r\n                throw;\r\n            }\r\n\r\n            return orderId;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Looks up a customer order based on its Guid identifier and by using an ActorProxy, retrieves the order's status and returns it to the client. \r\n        /// </summary>\r\n        /// <param name=\"customerOrderId\"></param>\r\n        /// <returns>String</returns>\r\n        [HttpGet]\r\n        [Route(\"api/orders/{customerOrderId}\")]\r\n        public Task<string> GetOrderStatus(Guid customerOrderId)\r\n        {\r\n            ServiceUriBuilder builder = new ServiceUriBuilder(CustomerOrderServiceName);\r\n            ICustomerOrderActor customerOrder = ActorProxy.Create<ICustomerOrderActor>(new ActorId(customerOrderId), builder.ToUri());\r\n\r\n            try\r\n            {\r\n                return customerOrder.GetOrderStatusAsStringAsync();\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                ServiceEventSource.Current.Message(\"Web Service: Exception {0}: {1}\", customerOrder, ex);\r\n\r\n                throw;\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Web.Service/Controllers/StoreController.cs",
    "content": "﻿// ------------------------------------------------------------\r\n//  Copyright (c) Microsoft Corporation.  All rights reserved.\r\n//  Licensed under the MIT License (MIT). See License.txt in the repo root for license information.\r\n// ------------------------------------------------------------\r\n\r\nnamespace Web.Service.Controllers\r\n{\r\n    using System;\r\n    using System.Collections.Generic;\r\n    using System.Fabric;\r\n    using System.Fabric.Query;\r\n    using System.Threading;\r\n    using System.Threading.Tasks;\r\n    using Common;\r\n    using Inventory.Domain;\r\n    using Microsoft.ServiceFabric.Services.Client;\r\n    using Microsoft.ServiceFabric.Services.Remoting.Client;\r\n    using Microsoft.AspNetCore.Mvc;\r\n\r\n    public class StoreController : Controller\r\n    {\r\n        public const string InventoryServiceName = \"InventoryService\";\r\n        private static FabricClient fc = new FabricClient();\r\n\r\n        /// <summary>\r\n        /// Right now, this method makes an API call via a ServiceProxy to retrieve Inventory Data directly\r\n        /// from InventoryService. In the future, this call will be made with a specified category parameter, \r\n        /// and based on this could call a specific materialized view to return. There would be no option \r\n        /// to return the entire inventory service in one call, as this would be slow and expensive at scale.  \r\n        /// </summary>\r\n        /// <returns>Task of type IEnumerable of InventoryItemView objects</returns>\r\n        [HttpGet]\r\n        [Route(\"api/store\")]\r\n        public async Task<IEnumerable<InventoryItemView>> GetStore()\r\n        {\r\n            ServiceUriBuilder builder = new ServiceUriBuilder(InventoryServiceName);\r\n            Uri serviceName = builder.ToUri();\r\n\r\n            List<InventoryItemView> itemList = new List<InventoryItemView>();\r\n\r\n            ServicePartitionList partitions = await fc.QueryManager.GetPartitionListAsync(serviceName);\r\n\r\n            foreach (Partition p in partitions)\r\n            {\r\n                long minKey = (p.PartitionInformation as Int64RangePartitionInformation).LowKey;\r\n                IInventoryService inventoryServiceClient = ServiceProxy.Create<IInventoryService>(serviceName, new ServicePartitionKey(minKey));\r\n\r\n                IEnumerable<InventoryItemView> result = await inventoryServiceClient.GetCustomerInventoryAsync(CancellationToken.None);\r\n                if (result != null)\r\n                {\r\n                    itemList.AddRange(result);\r\n                }\r\n            }\r\n\r\n            return itemList;\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Web.Service/PackageRoot/Config/Settings.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<Settings xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\n  <!-- Add your custom configuration sections and parameters here -->\n  <!--\n  <Section Name=\"MyConfigSection\">\n    <Parameter Name=\"MyParameter\" Value=\"Value1\" />\n  </Section>\n  -->\n</Settings>\n"
  },
  {
    "path": "ReferenceApp/Web.Service/PackageRoot/ServiceManifest.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ServiceManifest Name=\"Web.ServicePkg\"\n                 Version=\"1.0.0\"\n                 xmlns=\"http://schemas.microsoft.com/2011/01/fabric\"\n                 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n                 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n  <ServiceTypes>\n    <!-- This is the name of your ServiceType. \n         This name must match the string used in RegisterServiceType call in Program.cs. -->\n    <StatelessServiceType ServiceTypeName=\"WebServiceType\" />\n  </ServiceTypes>\n\n  <!-- Code package is your service executable. -->\n  <CodePackage Name=\"Code\" Version=\"1.0.0\">\n    <EntryPoint>\n      <ExeHost>\n        <Program>Web.Service.exe</Program>\n        <WorkingFolder>CodePackage</WorkingFolder>\n      </ExeHost>\n    </EntryPoint>\n  </CodePackage>\n\n  <!-- Config package is the contents of the Config directoy under PackageRoot that contains an \n       independently-updateable and versioned set of custom configuration settings for your service. -->\n  <ConfigPackage Name=\"Config\" Version=\"1.0.0\" />\n\n  <Resources>\n    <Endpoints>\n      <!-- This endpoint is used by the communication listener to obtain the port on which to \n           listen. Please note that if your service is partitioned, this port is shared with \n           replicas of different partitions that are placed in your code. -->\n      <Endpoint Protocol=\"http\" Name=\"ServiceEndpoint\" Type=\"Input\" Port=\"8081\" />\n    </Endpoints>\n  </Resources>\n</ServiceManifest>"
  },
  {
    "path": "ReferenceApp/Web.Service/Program.cs",
    "content": "﻿using Microsoft.ServiceFabric.Services.Runtime;\r\nusing System;\r\nusing System.Diagnostics;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace Web.Service\r\n{\r\n    internal static class Program\r\n    {\r\n        /// <summary>\r\n        /// This is the entry point of the service host process.\r\n        /// </summary>\r\n        private static void Main()\r\n        {\r\n            try\r\n            {\r\n                // The ServiceManifest.XML file defines one or more service type names.\r\n                // Registering a service maps a service type name to a .NET type.\r\n                // When Service Fabric creates an instance of this service type,\r\n                // an instance of the class is created in this host process.\r\n\r\n                ServiceRuntime.RegisterServiceAsync(\"WebServiceType\",\r\n                    context => new WebService(context)).GetAwaiter().GetResult();\r\n\r\n                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(WebService).Name);\r\n\r\n                // Prevents this host process from terminating so services keeps running. \r\n                Thread.Sleep(Timeout.Infinite);\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());\r\n                throw;\r\n            }\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Properties/launchSettings.json",
    "content": "﻿{\n  \"iisSettings\": {\n    \"windowsAuthentication\": false,\n    \"anonymousAuthentication\": true,\n    \"iisExpress\": {\n      \"applicationUrl\": \"http://localhost:1756/\",\n      \"sslPort\": 0\n    }\n  },\n  \"profiles\": {\n    \"IIS Express\": {\n      \"commandName\": \"IISExpress\",\n      \"launchBrowser\": true,\n      \"environmentVariables\": {\n        \"ASPNETCORE_ENVIRONMENT\": \"Development\"\n      }\n    },\n    \"Web.Service\": {\n      \"commandName\": \"Project\",\n      \"launchBrowser\": true,\n      \"environmentVariables\": {\n        \"ASPNETCORE_ENVIRONMENT\": \"Development\"\n      },\n      \"applicationUrl\": \"http://localhost:1757\"\n    }\n  }\n}\n"
  },
  {
    "path": "ReferenceApp/Web.Service/ServiceEventSource.cs",
    "content": "﻿using System;\r\nusing System.Collections.Generic;\r\nusing System.Diagnostics.Tracing;\r\nusing System.Fabric;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing Microsoft.ServiceFabric.Services.Runtime;\r\n\r\nnamespace Web.Service\r\n{\r\n    [EventSource(Name = \"MyCompany-WebReferenceApplication-Service\")]\r\n    internal sealed class ServiceEventSource : EventSource\r\n    {\r\n        public static readonly ServiceEventSource Current = new ServiceEventSource();\r\n\r\n        static ServiceEventSource()\r\n        {\r\n            // A workaround for the problem where ETW activities do not get tracked until Tasks infrastructure is initialized.\r\n            // This problem will be fixed in .NET Framework 4.6.2.\r\n            Task.Run(() => { });\r\n        }\r\n\r\n        // Instance constructor is private to enforce singleton semantics\r\n        private ServiceEventSource() : base() { }\r\n\r\n        #region Keywords\r\n        // Event keywords can be used to categorize events. \r\n        // Each keyword is a bit flag. A single event can be associated with multiple keywords (via EventAttribute.Keywords property).\r\n        // Keywords must be defined as a public class named 'Keywords' inside EventSource that uses them.\r\n        public static class Keywords\r\n        {\r\n            public const EventKeywords Requests = (EventKeywords)0x1L;\r\n            public const EventKeywords ServiceInitialization = (EventKeywords)0x2L;\r\n        }\r\n        #endregion\r\n\r\n        #region Events\r\n        // Define an instance method for each event you want to record and apply an [Event] attribute to it.\r\n        // The method name is the name of the event.\r\n        // Pass any parameters you want to record with the event (only primitive integer types, DateTime, Guid & string are allowed).\r\n        // Each event method implementation should check whether the event source is enabled, and if it is, call WriteEvent() method to raise the event.\r\n        // The number and types of arguments passed to every event method must exactly match what is passed to WriteEvent().\r\n        // Put [NonEvent] attribute on all methods that do not define an event.\r\n        // For more information see https://msdn.microsoft.com/en-us/library/system.diagnostics.tracing.eventsource.aspx\r\n\r\n        [NonEvent]\r\n        public void Message(string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                string finalMessage = string.Format(message, args);\r\n                Message(finalMessage);\r\n            }\r\n        }\r\n\r\n        private const int MessageEventId = 1;\r\n        [Event(MessageEventId, Level = EventLevel.Informational, Message = \"{0}\")]\r\n        public void Message(string message)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n                WriteEvent(MessageEventId, message);\r\n            }\r\n        }\r\n\r\n        [NonEvent]\r\n        public void ServiceMessage(ServiceContext serviceContext, string message, params object[] args)\r\n        {\r\n            if (this.IsEnabled())\r\n            {\r\n\r\n                string finalMessage = string.Format(message, args);\r\n                ServiceMessage(\r\n                    serviceContext.ServiceName.ToString(),\r\n                    serviceContext.ServiceTypeName,\r\n                    GetReplicaOrInstanceId(serviceContext),\r\n                    serviceContext.PartitionId,\r\n                    serviceContext.CodePackageActivationContext.ApplicationName,\r\n                    serviceContext.CodePackageActivationContext.ApplicationTypeName,\r\n                    serviceContext.NodeContext.NodeName,\r\n                    finalMessage);\r\n            }\r\n        }\r\n\r\n        // For very high-frequency events it might be advantageous to raise events using WriteEventCore API.\r\n        // This results in more efficient parameter handling, but requires explicit allocation of EventData structure and unsafe code.\r\n        // To enable this code path, define UNSAFE conditional compilation symbol and turn on unsafe code support in project properties.\r\n        private const int ServiceMessageEventId = 2;\r\n        [Event(ServiceMessageEventId, Level = EventLevel.Informational, Message = \"{7}\")]\r\n        private\r\n#if UNSAFE\r\n        unsafe\r\n#endif\r\n        void ServiceMessage(\r\n            string serviceName,\r\n            string serviceTypeName,\r\n            long replicaOrInstanceId,\r\n            Guid partitionId,\r\n            string applicationName,\r\n            string applicationTypeName,\r\n            string nodeName,\r\n            string message)\r\n        {\r\n#if !UNSAFE\r\n            WriteEvent(ServiceMessageEventId, serviceName, serviceTypeName, replicaOrInstanceId, partitionId, applicationName, applicationTypeName, nodeName, message);\r\n#else\r\n            const int numArgs = 8;\r\n            fixed (char* pServiceName = serviceName, pServiceTypeName = serviceTypeName, pApplicationName = applicationName, pApplicationTypeName = applicationTypeName, pNodeName = nodeName, pMessage = message)\r\n            {\r\n                EventData* eventData = stackalloc EventData[numArgs];\r\n                eventData[0] = new EventData { DataPointer = (IntPtr) pServiceName, Size = SizeInBytes(serviceName) };\r\n                eventData[1] = new EventData { DataPointer = (IntPtr) pServiceTypeName, Size = SizeInBytes(serviceTypeName) };\r\n                eventData[2] = new EventData { DataPointer = (IntPtr) (&replicaOrInstanceId), Size = sizeof(long) };\r\n                eventData[3] = new EventData { DataPointer = (IntPtr) (&partitionId), Size = sizeof(Guid) };\r\n                eventData[4] = new EventData { DataPointer = (IntPtr) pApplicationName, Size = SizeInBytes(applicationName) };\r\n                eventData[5] = new EventData { DataPointer = (IntPtr) pApplicationTypeName, Size = SizeInBytes(applicationTypeName) };\r\n                eventData[6] = new EventData { DataPointer = (IntPtr) pNodeName, Size = SizeInBytes(nodeName) };\r\n                eventData[7] = new EventData { DataPointer = (IntPtr) pMessage, Size = SizeInBytes(message) };\r\n\r\n                WriteEventCore(ServiceMessageEventId, numArgs, eventData);\r\n            }\r\n#endif\r\n        }\r\n\r\n        private const int ServiceTypeRegisteredEventId = 3;\r\n        [Event(ServiceTypeRegisteredEventId, Level = EventLevel.Informational, Message = \"Service host process {0} registered service type {1}\", Keywords = Keywords.ServiceInitialization)]\r\n        public void ServiceTypeRegistered(int hostProcessId, string serviceType)\r\n        {\r\n            WriteEvent(ServiceTypeRegisteredEventId, hostProcessId, serviceType);\r\n        }\r\n\r\n        private const int ServiceHostInitializationFailedEventId = 4;\r\n        [Event(ServiceHostInitializationFailedEventId, Level = EventLevel.Error, Message = \"Service host initialization failed\", Keywords = Keywords.ServiceInitialization)]\r\n        public void ServiceHostInitializationFailed(string exception)\r\n        {\r\n            WriteEvent(ServiceHostInitializationFailedEventId, exception);\r\n        }\r\n\r\n        // A pair of events sharing the same name prefix with a \"Start\"/\"Stop\" suffix implicitly marks boundaries of an event tracing activity.\r\n        // These activities can be automatically picked up by debugging and profiling tools, which can compute their execution time, child activities,\r\n        // and other statistics.\r\n        private const int ServiceRequestStartEventId = 5;\r\n        [Event(ServiceRequestStartEventId, Level = EventLevel.Informational, Message = \"Service request '{0}' started\", Keywords = Keywords.Requests)]\r\n        public void ServiceRequestStart(string requestTypeName)\r\n        {\r\n            WriteEvent(ServiceRequestStartEventId, requestTypeName);\r\n        }\r\n\r\n        private const int ServiceRequestStopEventId = 6;\r\n        [Event(ServiceRequestStopEventId, Level = EventLevel.Informational, Message = \"Service request '{0}' finished\", Keywords = Keywords.Requests)]\r\n        public void ServiceRequestStop(string requestTypeName, string exception = \"\")\r\n        {\r\n            WriteEvent(ServiceRequestStopEventId, requestTypeName, exception);\r\n        }\r\n        #endregion\r\n\r\n        #region Private methods\r\n        private static long GetReplicaOrInstanceId(ServiceContext context)\r\n        {\r\n            StatelessServiceContext stateless = context as StatelessServiceContext;\r\n            if (stateless != null)\r\n            {\r\n                return stateless.InstanceId;\r\n            }\r\n\r\n            StatefulServiceContext stateful = context as StatefulServiceContext;\r\n            if (stateful != null)\r\n            {\r\n                return stateful.ReplicaId;\r\n            }\r\n\r\n            throw new NotSupportedException(\"Context type not supported.\");\r\n        }\r\n#if UNSAFE\r\n        private int SizeInBytes(string s)\r\n        {\r\n            if (s == null)\r\n            {\r\n                return 0;\r\n            }\r\n            else\r\n            {\r\n                return (s.Length + 1) * sizeof(char);\r\n            }\r\n        }\r\n#endif\r\n        #endregion\r\n    }\r\n}\r\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Startup.cs",
    "content": "﻿using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Threading.Tasks;\r\nusing Microsoft.AspNetCore.Builder;\r\nusing Microsoft.AspNetCore.Hosting;\r\nusing Microsoft.Extensions.Configuration;\r\nusing Microsoft.Extensions.DependencyInjection;\r\nusing Microsoft.Extensions.Logging;\r\n\r\nnamespace Web.Service\r\n{\r\n    public class Startup\r\n    {\r\n        public Startup(IHostingEnvironment env)\r\n        {\r\n            var builder = new ConfigurationBuilder()\r\n                .SetBasePath(env.ContentRootPath)\r\n                .AddJsonFile(\"appsettings.json\", optional: false, reloadOnChange: true)\r\n                .AddJsonFile($\"appsettings.{env.EnvironmentName}.json\", optional: true)\r\n                .AddEnvironmentVariables();\r\n            Configuration = builder.Build();\r\n        }\r\n\r\n        public IConfigurationRoot Configuration { get; }\r\n\r\n        // This method gets called by the runtime. Use this method to add services to the container.\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            // Add framework services.\r\n            services.AddMvc();\r\n        }\r\n\r\n        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.\r\n        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)\r\n        {\r\n            loggerFactory.AddConsole(Configuration.GetSection(\"Logging\"));\r\n            loggerFactory.AddDebug();\r\n\r\n            if (env.IsDevelopment())\r\n            {\r\n                app.UseDeveloperExceptionPage();\r\n                app.UseBrowserLink();\r\n            }\r\n            else\r\n            {\r\n                app.UseExceptionHandler(\"/Home/Error\");\r\n            }\r\n\r\n            app.UseStaticFiles();\r\n\r\n            app.UseMvc(routes =>\r\n            {\r\n                routes.MapRoute(\r\n                    name: \"default\",\r\n                    template: \"{controller=Home}/{action=Index}\");\r\n\r\n                routes.MapRoute(\r\n                    name: \"admin\",\r\n                    template: \"Admin\",\r\n                    defaults: new { controller = \"Home\", action = \"Admin\" });\r\n\r\n                routes.MapRoute(\r\n                    name: \"orders\",\r\n                    template: \"OrderConfirmation\",\r\n                    defaults: new { controller = \"Home\", action = \"OrderConfirmation\" });\r\n\r\n            });\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Views/Home/Admin.cshtml",
    "content": "﻿<body ng-controller=\"testController\">\n    <div class=\"masthead\">\n        <div class=\"container\">\n            <p style=\"text-align:right;\"><h7><b>Fabrikam Fashion</b></h7></p><br />\n        </div>\n    </div>\n    <div class=\"container below\" ng-init=\"showStatus=false\">\n        <p style=\"text-align:center; font-size:34px\"><b>Admin Portal!</b></p>\n        <br />\n        Description, Price, Number, Reorder Threshold, Max <br />\n        Bioluminescent Dress, 14.99, 2000, 200, 2000 <br />\n        Electrifying Lightning Skirt, 29.99, 1500, 150, 1500 <br />\n        Blacklight Striped Trousers, 34.99, 3000, 300, 3000 <br />\n        <textarea cols=\"50\" ng-model=\"itemsToCreate\">\n        </textarea>\n\n        <p style=\"text-align: center\">\n            <button ng-click=\"createInventory()\">Create Inventory</button>\n            <div><b>Submission Result = {{createResult}}</b></div>\n        </p>\n\n        <br />\n    </div>\n</body>"
  },
  {
    "path": "ReferenceApp/Web.Service/Views/Home/Index.cshtml",
    "content": "﻿<body ng-controller=\"testController\" data-ng-init=\"initIndex()\">\n    <div class=\"masthead\">\n        <div class=\"container\">\n            <p style=\"text-align:right;\"><h7><b>Fabrikam Fashion</b></h7></p><br />\n        </div>\n    </div>\n    <div class=\"container below\" ng-init=\"showCart=true\">\n        <!--<p style=\"text-align:center; font-size:18px\"><b>Clothing</b></p>-->\n        <table class=\"table table-striped\" style=\"width:100%;\">\n            <thead>\n                <tr>\n                    <th>Item</th>\n                    <th>Price</th>\n                    <th>Available</th>\n                    <th>Quantity</th>\n                </tr>\n            </thead>\n            <tbody>\n                <tr ng-repeat=\"row in inventory\">\n                    <td>{{row.description}}</td>\n                    <td>${{row.price}}</td>\n                    <td>{{row.customerAvailableStock}}</td>\n                    <td>\n                        <input type=\"number\" class=\"textbox\" ng-model=\"row.quantity\" />\n                        <input type=\"submit\" value=\"Add\" ng-click=\"submit(row)\">\n                    </td>\n                </tr>\n            </tbody>\n        </table>\n        <br /> <br />\n\n        <p style=\"text-align:center; font-size:16px\"><b>Shopping Cart</b></p>\n        <table ng-show=\"showCart\" class=\"table table-striped\" style=\"width:60%\">\n            <thead>\n                <tr>\n                    <th colspan=\"2\">Item</th>\n                    <th colspan=\"2\">price</th>\n                    <th colspan=\"2\">Quantity</th>\n                </tr>\n            </thead>\n            <tbody>\n                <tr ng-repeat=\"item in cart\">\n                    <td colspan=\"2\"> {{item.description}}</td>\n                    <td colspan=\"2\"> ${{item.price}}</td>\n                    <td colspan=\"2\"> {{item.quantity}}</td>\n                </tr>\n                <tr class=\"success\">\n                    <td colspan=\"3\"><b>Total</b></td>\n                    <td colspan=\"3\">${{cart_total}}</td>\n                </tr>\n            </tbody>\n        </table>\n        <p style=\"text-align: center\">\n            <button ng-click=\"showCart=false\">Hide Cart</button>\n            <button ng-click=\"showCart=true\">Display Cart</button>\n        </p>\n        <br />\n        <form name=\"OrderForm\" novalidate>\n            <p style=\"text-align: center; align-content:center\">\n                <input type=\"submit\" value=\"Place Order\"\n                       ng-click=\"placeOrder(null)\" />\n            </p>\n        </form>\n    </div>\n</body>"
  },
  {
    "path": "ReferenceApp/Web.Service/Views/Home/OrderConfirmation.cshtml",
    "content": "﻿<body ng-controller=\"testController\" data-ng-init=\"refreshStatus()\">\n    <div class=\"masthead\">\n        <div class=\"container\">\n            <p style=\"text-align:right;\"><h7><b>Fabrikam Fashion</b></h7></p><br />\n        </div>\n    </div>\n    <div class=\"container below\" ng-init=\"showStatus=false\">\n        <p style=\"text-align:center; font-size:34px\"><b>View Order</b></p>\n        <br />\n        <table class=\"table table-striped\" style=\"width:20%\">\n            <tbody>\n                <tr>\n                    <td colspan=\"2\" style=\"font-size:16px\"><b>{{orderStatus}}</b></td>\n                </tr>\n            </tbody>\n        </table>\n        <p style=\"text-align: center\">\n            <button ng-click=\"refreshStatus()\">Get Order Status</button>\n        </p>\n        <br />\n        <br />\n\n        <p style=\"text-align:center; font-size:16px\"><b>Shopping Cart</b></p>\n        <table class=\"table table-striped\" style=\"width:70%\">\n            <thead>\n                <tr>\n                    <th colspan=\"2\">Item</th>\n                    <th colspan=\"2\">Price</th>\n                    <th colspan=\"2\">Quantity</th>\n                </tr>\n            </thead>\n            <tbody>\n                <tr ng-repeat=\"order in orderCompletedCart\">\n                    <td colspan=\"2\"> {{order.Description}}</td>\n                    <td colspan=\"2\"> ${{order.Price}}</td>\n                    <td colspan=\"2\"> {{order.Quantity}}</td>\n                </tr>\n                <tr class=\"success\">\n                    <td colspan=\"3\"><b>Total</b></td>\n                    <td colspan=\"3\">${{completedTotal}}</td>\n                </tr>\n            </tbody>\n        </table>\n        <br />\n\n    </div>\n</body>"
  },
  {
    "path": "ReferenceApp/Web.Service/Views/Shared/Error.cshtml",
    "content": "﻿@{\n    ViewData[\"Title\"] = \"Error\";\n}\n\n<h1 class=\"text-danger\">Error.</h1>\n<h2 class=\"text-danger\">An error occurred while processing your request.</h2>\n\n<h3>Development Mode</h3>\n<p>\n    Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.\n</p>\n<p>\n    <strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.\n</p>\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Views/Shared/_Layout.cshtml",
    "content": "﻿<!DOCTYPE html>\n<html lang=\"en\" ng-app=\"fabrikam\">\n<head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta http-equiv=\"CACHE-CONTROL\" content=\"NO-CACHE\">\n    <meta http-equiv=\"content-type\" content=\"application/force-download\">\n    <meta name=\" viewport\" content=\"width=device-width, initial-scale=1\">\n    <title>Fabrikam Fashion</title>\n    \n    <script type=\"text/javascript\" src=\"~/lib/angular/angular.js\"></script>\n    <script type=\"text/javascript\" src=\"~/lib/angular-cookies/angular-cookies.js\"></script>\n    <script type=\"text/javascript\" src=\"~/js/angular-index.js\"></script>\n\n    <!-- Bootstrap -->\n    <link href=\"~/lib/bootstrap-css-only/css/bootstrap.css\" rel=\"stylesheet\">\n</head>\n@RenderBody();\n</html>"
  },
  {
    "path": "ReferenceApp/Web.Service/Views/Shared/_ValidationScriptsPartial.cshtml",
    "content": "﻿<environment names=\"Development\">\n    <script src=\"~/lib/jquery-validation/dist/jquery.validate.js\"></script>\n    <script src=\"~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js\"></script>\n</environment>\n<environment names=\"Staging,Production\">\n    <script src=\"https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js\"\n            asp-fallback-src=\"~/lib/jquery-validation/dist/jquery.validate.min.js\"\n            asp-fallback-test=\"window.jQuery && window.jQuery.validator\"\n            crossorigin=\"anonymous\"\n            integrity=\"sha384-Fnqn3nxp3506LP/7Y3j/25BlWeA3PXTyT1l78LjECcPaKCV12TsZP7yyMxOe/G/k\">\n    </script>\n    <script src=\"https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js\"\n            asp-fallback-src=\"~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js\"\n            asp-fallback-test=\"window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive\"\n            crossorigin=\"anonymous\"\n            integrity=\"sha384-JrXK+k53HACyavUKOsL+NkmSesD2P+73eDMrbTtTk0h4RmOF8hF8apPlkp26JlyH\">\n    </script>\n</environment>\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Views/_ViewImports.cshtml",
    "content": "﻿@using Web.Service\n@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Views/_ViewStart.cshtml",
    "content": "﻿@{\n    Layout = \"_Layout\";\n}\n"
  },
  {
    "path": "ReferenceApp/Web.Service/Web.Service.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk.Web\">\r\n\r\n  <PropertyGroup>\r\n    <TargetFramework>net452</TargetFramework>\r\n    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>\r\n    <IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>\r\n  </PropertyGroup>\r\n\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|AnyCPU'\">\r\n    <OutputPath>bin\\Debug\\</OutputPath>\r\n  </PropertyGroup>\r\n\r\n  <ItemGroup>\r\n    <Compile Remove=\"wwwroot\\lib\\bootstrap\\**\" />\r\n    <Content Remove=\"wwwroot\\lib\\bootstrap\\**\" />\r\n    <EmbeddedResource Remove=\"wwwroot\\lib\\bootstrap\\**\" />\r\n    <None Remove=\"wwwroot\\lib\\bootstrap\\**\" />\r\n  </ItemGroup>\r\n\r\n  <ItemGroup>\r\n    <Content Include=\"wwwroot\\js\\angular-index.js\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <PackageReference Include=\"Microsoft.ApplicationInsights.AspNetCore\" Version=\"2.0.0\" />\r\n    <PackageReference Include=\"Microsoft.AspNetCore\" Version=\"1.1.1\" />\r\n    <PackageReference Include=\"Microsoft.AspNetCore.Mvc\" Version=\"1.1.2\" />\r\n    <PackageReference Include=\"Microsoft.AspNetCore.StaticFiles\" Version=\"1.1.1\" />\r\n    <PackageReference Include=\"Microsoft.Extensions.Logging.Debug\" Version=\"1.1.1\" />\r\n    <PackageReference Include=\"Microsoft.ServiceFabric\" Version=\"5.6.204\" />\r\n    <PackageReference Include=\"Microsoft.ServiceFabric.Actors\" Version=\"2.6.204\" />\r\n    <PackageReference Include=\"Microsoft.ServiceFabric.AspNetCore.WebListener\" Version=\"2.5.216\" />\r\n    <PackageReference Include=\"Microsoft.ServiceFabric.Data\" Version=\"2.6.204\" />\r\n    <PackageReference Include=\"Microsoft.ServiceFabric.Services\" Version=\"2.6.204\" />\r\n    <PackageReference Include=\"Microsoft.VisualStudio.Web.BrowserLink\" Version=\"1.1.0\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <DotNetCliToolReference Include=\"Microsoft.VisualStudio.Web.CodeGeneration.Tools\" Version=\"1.0.0\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\Common\\Common.csproj\" />\r\n    <ProjectReference Include=\"..\\CustomerOrder.Domain\\CustomerOrder.Domain.csproj\" />\r\n    <ProjectReference Include=\"..\\Inventory.Domain\\Inventory.Domain.csproj\" />\r\n  </ItemGroup>\r\n\r\n</Project>\r\n"
  },
  {
    "path": "ReferenceApp/Web.Service/WebService.cs",
    "content": "﻿using System;\r\nusing System.Collections.Generic;\r\nusing System.Fabric;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\nusing Microsoft.AspNetCore.Hosting;\r\nusing Microsoft.Extensions.DependencyInjection;\r\nusing Microsoft.ServiceFabric.Services.Communication.AspNetCore;\r\nusing Microsoft.ServiceFabric.Services.Communication.Runtime;\r\nusing Microsoft.ServiceFabric.Services.Runtime;\r\n\r\nnamespace Web.Service\r\n{\r\n    /// <summary>\r\n    /// The FabricRuntime creates an instance of this class for each service type instance. \r\n    /// </summary>\r\n    internal sealed class WebService : StatelessService\r\n    {\r\n        public WebService(StatelessServiceContext context)\r\n            : base(context)\r\n        { }\r\n\r\n        /// <summary>\r\n        /// Optional override to create listeners (like tcp, http) for this service instance.\r\n        /// </summary>\r\n        /// <returns>The collection of listeners.</returns>\r\n        protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()\r\n        {\r\n            return new ServiceInstanceListener[]\r\n            {\r\n                new ServiceInstanceListener(serviceContext =>\r\n                    new WebListenerCommunicationListener(serviceContext, \"ServiceEndpoint\", (url, listener) =>\r\n                    {\r\n                        url += \"/fabrikam\";\r\n\r\n                        ServiceEventSource.Current.ServiceMessage(serviceContext, $\"Starting WebListener on {url}\");\r\n\r\n                        return new WebHostBuilder().UseWebListener()\r\n                                    .ConfigureServices(\r\n                                        services => services\r\n                                            .AddSingleton<StatelessServiceContext>(serviceContext))\r\n                                    .UseContentRoot(Directory.GetCurrentDirectory())\r\n                                    .UseStartup<Startup>()\r\n                                    .UseApplicationInsights()\r\n                                    .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)\r\n                                    .UseUrls(url)\r\n                                    .Build();\r\n                    }))\r\n            };\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ReferenceApp/Web.Service/appsettings.Development.json",
    "content": "﻿{\n  \"Logging\": {\n    \"IncludeScopes\": false,\n    \"LogLevel\": {\n      \"Default\": \"Debug\",\n      \"System\": \"Information\",\n      \"Microsoft\": \"Information\"\n    }\n  }\n}\n"
  },
  {
    "path": "ReferenceApp/Web.Service/appsettings.json",
    "content": "﻿{\n  \"Logging\": {\n    \"IncludeScopes\": false,\n    \"LogLevel\": {\n      \"Default\": \"Warning\"\n    }\n  }\n}\n"
  },
  {
    "path": "ReferenceApp/Web.Service/bower.json",
    "content": "{\n  \"name\": \"asp.net\",\n  \"private\": true,\n  \"dependencies\": {\n    \"bootstrap-css-only\": \"v3.3.7\",\n    \"angular\": \"v1.6.4\",\n    \"angular-cookies\": \"v1.6.4\"\n  }\n}\n"
  },
  {
    "path": "ReferenceApp/Web.Service/bundleconfig.json",
    "content": "﻿// Configure bundling and minification for the project.\n// More info at https://go.microsoft.com/fwlink/?LinkId=808241\n[\n  {\n    \"outputFileName\": \"wwwroot/css/site.min.css\",\n    // An array of relative input file paths. Globbing patterns supported\n    \"inputFiles\": [\n      \"wwwroot/css/site.css\"\n    ]\n  },\n  {\n    \"outputFileName\": \"wwwroot/js/site.min.js\",\n    \"inputFiles\": [\n      \"wwwroot/js/site.js\"\n    ],\n    // Optionally specify minification options\n    \"minify\": {\n      \"enabled\": true,\n      \"renameLocals\": true\n    },\n    // Optionally generate .map file\n    \"sourceMap\": false\n  }\n]\n"
  },
  {
    "path": "ReferenceApp/Web.Service/wwwroot/css/site.css",
    "content": "﻿body {\n    padding-top: 50px;\n    padding-bottom: 20px;\n}\n\n/* Wrapping element */\n/* Set some basic padding to keep content from hitting the edges */\n.body-content {\n    padding-left: 15px;\n    padding-right: 15px;\n}\n\n/* Set widths on the form inputs since otherwise they're 100% wide */\ninput,\nselect,\ntextarea {\n    max-width: 280px;\n}\n\n/* Carousel */\n.carousel-caption p {\n    font-size: 20px;\n    line-height: 1.4;\n}\n\n/* Make .svg files in the carousel display properly in older browsers */\n.carousel-inner .item img[src$=\".svg\"] {\n    width: 100%;\n}\n\n/* Hide/rearrange for smaller screens */\n@media screen and (max-width: 767px) {\n    /* Hide captions */\n    .carousel-caption {\n        display: none;\n    }\n}\n"
  },
  {
    "path": "ReferenceApp/Web.Service/wwwroot/js/angular-index.js",
    "content": "﻿(function (angular) {\n    var app = angular.module(\"fabrikam\", ['ngCookies'])\n        .controller(\"testController\", function ($scope, $window, $http, $cookies) {\n\n\n            /*--------------------VARIABLES------------------------*/\n\n            // Shopping cart for UI display only. description, price, quantity.\n            $scope.cart = [];\n            // ItemId, Quanity. Used in HttpPost to fulfill order.\n            $scope.order = [];\n            $scope.cart_total = 0;\n\n            // Local variables to keep track of data / aid in formatting for $scope variables.\n            var local_cart = [];\n            var cart_total_unformatted = 0;\n\n            // Used to keep track of customer's order. Will be undefined until order is placed.\n            $scope.orderCompletedCart = $cookies.getObject('orderPlaced');\n            $scope.completedTotal = $cookies.get('orderTotal');\n\n            /* -----------------------FUNCTIONS---------------------------*/\n\n            // Called everytime index.html is loaded. Retrieves inventory items.\n            $scope.initIndex = function () {\n\n                $http.get('/fabrikam/api/store').\n                then(function (data) {\n                    $scope.inventory = inventory = data.data;\n                }, function (data) {\n                    $window.alert(\"Error retrieving inventory from store.\");\n                });\n\n            }\n\n            // Called when a user adds item(s) to cart.\n            $scope.submit = function (row) {\n\n                // Ensure user enters valid non-negative integer.\n                while (row.quantity != parseInt(row.quantity, 10) || row.quantity <= 0) {\n                    row.quantity = \"\";\n                    row.quantity = prompt(\"Please enter a non-negative quantity: \");\n                    if (row.quantity === null) {\n                        $window.alert(\"Order canceled.\");\n                        return;\n                    }\n                }\n                // Check to see if there are enough items in inventory to order quantity specified.\n                if (row.quantity > row.customerAvailableStock) {\n                    $window.alert(\"Order exceeded available stock.\");\n                    return;\n                }\n\n                // Add to shopping cart and calculate total cost. \n                local_cart.push({ 'description': row.description, 'price': row.price, 'quantity': row.quantity });\n                cart_total_unformatted += row.price * row.quantity;\n\n                // Update number of available items in inventory. Only updating local copy of inventory, not actual backend data.\n                row.customerAvailableStock -= row.quantity;\n\n                // Copy data to scope variables to show on webpage.\n                $scope.cart_total = Number(cart_total_unformatted).toFixed(2);\n                $scope.cart = local_cart;\n\n                // Keep track of id and quantity to send back to order service.\n                $scope.order.push({ 'ItemId': row.id, 'quantity': row.quantity });\n\n                // Set UI quantity back to empty.\n                row.quantity = \"\";\n\n            }\n\n            // Called after user enters email and selects Place Order.\n            // Here's where you would store customer email if you wanted to.\n            $scope.placeOrder = function (customerEmail) {\n\n                // Make sure to store orders so user can see persisted shopping cart on confirmation page. \n                $cookies.putObject('orderPlaced', local_cart);\n                $cookies.put('orderTotal', $scope.cart_total);\n\n                // Send data to Order Controller.\n                var promise = $http.post('/fabrikam/api/orders', $scope.order).\n                      then(function (response) {\n                          // Store returned orderId.\n                          //$cookies.put('orderId', response.data);\n                          var orderId = response.data;\n\n                          var path = '/fabrikam/OrderConfirmation?orderId=';\n\n                          var address = path.concat(orderId);\n\n                          // Navigate to order confirmation page.\n                          window.location.href = address;\n\n                      }, function (response) {\n\n                          $window.alert(\"Error sending orders.\");\n\n                      });\n            }\n\n            // Called when orderconfirmation.html is loaded and when user clicks 'Get Order Status'\n            $scope.refreshStatus = function () {\n\n                // Initialize status in case asynchronous retrieval of status takes a while.\n                $scope.orderStatus = \"\";\n\n                var route = '/fabrikam/api/orders/';\n                var prodId = $scope.getQueryParameterByName('orderId');\n                var address = route.concat(prodId);\n\n                // Retrieve order status based on orderId.\n                $http.get(address).\n                    then(function (response) {\n                        $scope.orderStatus = orderStatus = response.data;\n                    }, function (response) {\n                        $window.alert(\"Error retrieving order status from store.\");\n                    });\n            }\n\n            $scope.createInventory = function () {\n                //description\n                //price\n                //Number\n                //Reorder Threshold\n                //Max\n\n                var text = $scope.itemsToCreate;\n                var itemArrays = text.split('\\n');\n\n                for (var i = 0; i < itemArrays.length; i++)\n                {\n                    var route = '/fabrikam/api/inventory/add/';\n                    var propertyArray = itemArrays[i].split(',');\n\n                    for (var x = 0; x < propertyArray.length; x++)\n                    {\n                        var strtemp = encodeURIComponent(propertyArray[x].trim());\n                        strtemp = strtemp.concat(\"/\");\n                        route = route.concat(strtemp)\n                    }\n\n                    $http.post(route).\n                        then(function (response) {\n                            $scope.createResult = createResult = response.data;\n                        }, function (response) {\n                            $window.alert(\"Error sending request to Inventory Service.\");\n                        });\n                }\n\n\n\n\n            }\n\n            $scope.getQueryParameterByName = function (name) {\n\n                name = name.replace(/[\\[]/, \"\\\\[\").replace(/[\\]]/, \"\\\\]\");\n\n                var regex = new RegExp(\"[\\\\?&]\" + name + \"=([^&#]*)\"), results = regex.exec(location.search);\n\n                return results === null ? \"\" : decodeURIComponent(results[1].replace(/\\+/g, \" \"));\n            }\n\n        });\n\n})(angular)"
  },
  {
    "path": "ReferenceApp/WebReferenceApp.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio 15\r\nVisualStudioVersion = 15.0.26430.6\r\nMinimumVisualStudioVersion = 10.0.40219.1\r\nProject(\"{A07B5EB6-E848-4116-A8D0-A826331D98C6}\") = \"WebReferenceApplication\", \"WebReferenceApplication\\WebReferenceApplication.sfproj\", \"{0EE37B65-FCCB-44AE-B4F7-AED85FDEB072}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{9EC0063F-489E-43FE-94B5-BF5F89977CD3} = {9EC0063F-489E-43FE-94B5-BF5F89977CD3}\r\n\t\t{1E7E813F-43D3-4D0B-8546-5E1023873F28} = {1E7E813F-43D3-4D0B-8546-5E1023873F28}\r\n\t\t{A44FC2C5-6781-447E-80F5-7265B960B36A} = {A44FC2C5-6781-447E-80F5-7265B960B36A}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"CustomerOrder.Actor\", \"CustomerOrder.Actor\\CustomerOrder.Actor.csproj\", \"{5F0C7805-C91D-47E9-AEDE-946CADEA1C8F}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"CustomerOrder.Domain\", \"CustomerOrder.Domain\\CustomerOrder.Domain.csproj\", \"{1E7E813F-43D3-4D0B-8546-5E1023873F28}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"RestockRequest.Actor\", \"RestockRequest.Actor\\RestockRequest.Actor.csproj\", \"{4C5ACF3B-E6D1-4FBD-8B23-A9FA7BA6326E}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{9EC0063F-489E-43FE-94B5-BF5F89977CD3} = {9EC0063F-489E-43FE-94B5-BF5F89977CD3}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"RestockRequest.Domain\", \"RestockRequest.Domain\\RestockRequest.Domain.csproj\", \"{A44FC2C5-6781-447E-80F5-7265B960B36A}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{9EC0063F-489E-43FE-94B5-BF5F89977CD3} = {9EC0063F-489E-43FE-94B5-BF5F89977CD3}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Inventory.Service\", \"Inventory.Service\\Inventory.Service.csproj\", \"{714B1C61-FFA8-4A5E-8DD2-D0A290677293}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"RestockRequestManager.Service\", \"RestockRequestManager.Service\\RestockRequestManager.Service.csproj\", \"{7C404BC4-7589-488C-AB09-876E5B33B641}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Common\", \"Common\\Common.csproj\", \"{9EC0063F-489E-43FE-94B5-BF5F89977CD3}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"RestockRequestManager.Domain\", \"RestockRequestManager.Domain\\RestockRequestManager.Domain.csproj\", \"{4162F266-D657-4143-AA62-626C10D23561}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Inventory.Domain\", \"Inventory.Domain\\Inventory.Domain.csproj\", \"{7E9C2DFD-71A5-496D-AA4D-5EC53EAEB9AE}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Inventory.UnitTests\", \"Inventory.UnitTests\\Inventory.UnitTests.csproj\", \"{71E58E09-BEE4-4B19-BCF7-4C9BD71514FB}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Mocks\", \"Mocks\\Mocks.csproj\", \"{00E00484-BD00-40CD-B2CC-1CFA8E893972}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"CustomerOrder.UnitTests\", \"CustomerOrder.UnitTests\\CustomerOrder.UnitTests.csproj\", \"{226B8D34-99CF-4172-87DC-E20B39030CC0}\"\r\nEndProject\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Web.Service\", \"Web.Service\\Web.Service.csproj\", \"{EB1D3837-C58C-4F47-8B64-938E6013E8EB}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|x64 = Debug|x64\r\n\t\tRelease|x64 = Release|x64\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{0EE37B65-FCCB-44AE-B4F7-AED85FDEB072}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{0EE37B65-FCCB-44AE-B4F7-AED85FDEB072}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{0EE37B65-FCCB-44AE-B4F7-AED85FDEB072}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{0EE37B65-FCCB-44AE-B4F7-AED85FDEB072}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{0EE37B65-FCCB-44AE-B4F7-AED85FDEB072}.Release|x64.Build.0 = Release|x64\r\n\t\t{0EE37B65-FCCB-44AE-B4F7-AED85FDEB072}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{5F0C7805-C91D-47E9-AEDE-946CADEA1C8F}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{5F0C7805-C91D-47E9-AEDE-946CADEA1C8F}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{5F0C7805-C91D-47E9-AEDE-946CADEA1C8F}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{5F0C7805-C91D-47E9-AEDE-946CADEA1C8F}.Release|x64.Build.0 = Release|x64\r\n\t\t{1E7E813F-43D3-4D0B-8546-5E1023873F28}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{1E7E813F-43D3-4D0B-8546-5E1023873F28}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{1E7E813F-43D3-4D0B-8546-5E1023873F28}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{1E7E813F-43D3-4D0B-8546-5E1023873F28}.Release|x64.Build.0 = Release|x64\r\n\t\t{4C5ACF3B-E6D1-4FBD-8B23-A9FA7BA6326E}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{4C5ACF3B-E6D1-4FBD-8B23-A9FA7BA6326E}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{4C5ACF3B-E6D1-4FBD-8B23-A9FA7BA6326E}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{4C5ACF3B-E6D1-4FBD-8B23-A9FA7BA6326E}.Release|x64.Build.0 = Release|x64\r\n\t\t{A44FC2C5-6781-447E-80F5-7265B960B36A}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{A44FC2C5-6781-447E-80F5-7265B960B36A}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{A44FC2C5-6781-447E-80F5-7265B960B36A}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{A44FC2C5-6781-447E-80F5-7265B960B36A}.Release|x64.Build.0 = Release|x64\r\n\t\t{714B1C61-FFA8-4A5E-8DD2-D0A290677293}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{714B1C61-FFA8-4A5E-8DD2-D0A290677293}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{714B1C61-FFA8-4A5E-8DD2-D0A290677293}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{714B1C61-FFA8-4A5E-8DD2-D0A290677293}.Release|x64.Build.0 = Release|x64\r\n\t\t{7C404BC4-7589-488C-AB09-876E5B33B641}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{7C404BC4-7589-488C-AB09-876E5B33B641}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{7C404BC4-7589-488C-AB09-876E5B33B641}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{7C404BC4-7589-488C-AB09-876E5B33B641}.Release|x64.Build.0 = Release|x64\r\n\t\t{9EC0063F-489E-43FE-94B5-BF5F89977CD3}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{9EC0063F-489E-43FE-94B5-BF5F89977CD3}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{9EC0063F-489E-43FE-94B5-BF5F89977CD3}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{9EC0063F-489E-43FE-94B5-BF5F89977CD3}.Release|x64.Build.0 = Release|x64\r\n\t\t{4162F266-D657-4143-AA62-626C10D23561}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{4162F266-D657-4143-AA62-626C10D23561}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{4162F266-D657-4143-AA62-626C10D23561}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{4162F266-D657-4143-AA62-626C10D23561}.Release|x64.Build.0 = Release|x64\r\n\t\t{7E9C2DFD-71A5-496D-AA4D-5EC53EAEB9AE}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{7E9C2DFD-71A5-496D-AA4D-5EC53EAEB9AE}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{7E9C2DFD-71A5-496D-AA4D-5EC53EAEB9AE}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{7E9C2DFD-71A5-496D-AA4D-5EC53EAEB9AE}.Release|x64.Build.0 = Release|x64\r\n\t\t{71E58E09-BEE4-4B19-BCF7-4C9BD71514FB}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{71E58E09-BEE4-4B19-BCF7-4C9BD71514FB}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{71E58E09-BEE4-4B19-BCF7-4C9BD71514FB}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{71E58E09-BEE4-4B19-BCF7-4C9BD71514FB}.Release|x64.Build.0 = Release|x64\r\n\t\t{00E00484-BD00-40CD-B2CC-1CFA8E893972}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{00E00484-BD00-40CD-B2CC-1CFA8E893972}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{00E00484-BD00-40CD-B2CC-1CFA8E893972}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{00E00484-BD00-40CD-B2CC-1CFA8E893972}.Release|x64.Build.0 = Release|x64\r\n\t\t{226B8D34-99CF-4172-87DC-E20B39030CC0}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{226B8D34-99CF-4172-87DC-E20B39030CC0}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{226B8D34-99CF-4172-87DC-E20B39030CC0}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{226B8D34-99CF-4172-87DC-E20B39030CC0}.Release|x64.Build.0 = Release|x64\r\n\t\t{EB1D3837-C58C-4F47-8B64-938E6013E8EB}.Debug|x64.ActiveCfg = Debug|Any CPU\r\n\t\t{EB1D3837-C58C-4F47-8B64-938E6013E8EB}.Debug|x64.Build.0 = Debug|Any CPU\r\n\t\t{EB1D3837-C58C-4F47-8B64-938E6013E8EB}.Release|x64.ActiveCfg = Release|Any CPU\r\n\t\t{EB1D3837-C58C-4F47-8B64-938E6013E8EB}.Release|x64.Build.0 = Release|Any CPU\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/ApplicationPackageRoot/ApplicationManifest.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<ApplicationManifest xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ApplicationTypeName=\"WebReferenceApplicationType\" ApplicationTypeVersion=\"1.0.0\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\r\n  <Parameters>\r\n    <Parameter Name=\"WebService_InstanceCount\" DefaultValue=\"-1\" />\r\n    <Parameter Name=\"RestockRequestActorService_PartitionCount\" DefaultValue=\"9\" />\r\n    <Parameter Name=\"RestockRequestActorService_MinReplicaSetSize\" DefaultValue=\"3\" />\r\n    <Parameter Name=\"RestockRequestActorService_TargetReplicaSetSize\" DefaultValue=\"3\" />\r\n    <Parameter Name=\"CustomerOrderActorService_PartitionCount\" DefaultValue=\"9\" />\r\n    <Parameter Name=\"CustomerOrderActorService_MinReplicaSetSize\" DefaultValue=\"3\" />\r\n    <Parameter Name=\"CustomerOrderActorService_TargetReplicaSetSize\" DefaultValue=\"3\" />\r\n    <Parameter Name=\"RestockRequestManagerService_MinReplicaSetSize\" DefaultValue=\"3\" />\r\n    <Parameter Name=\"RestockRequestManagerService_TargetReplicaSetSize\" DefaultValue=\"3\" />\r\n    <Parameter Name=\"InventoryService_PartitionCount\" DefaultValue=\"9\" />\r\n    <Parameter Name=\"InventoryService_MinReplicaSetSize\" DefaultValue=\"3\" />\r\n    <Parameter Name=\"InventoryService_TargetReplicaSetSize\" DefaultValue=\"3\" />\r\n  </Parameters>\r\n  <ServiceManifestImport>\r\n    <ServiceManifestRef ServiceManifestName=\"Web.ServicePkg\" ServiceManifestVersion=\"1.0.0\" />\r\n    <ConfigOverrides />\r\n  </ServiceManifestImport>\r\n  <ServiceManifestImport>\r\n    <ServiceManifestRef ServiceManifestName=\"RestockRequest.ActorPkg\" ServiceManifestVersion=\"1.0.0\" />\r\n  </ServiceManifestImport>\r\n  <ServiceManifestImport>\r\n    <ServiceManifestRef ServiceManifestName=\"CustomerOrder.ActorPkg\" ServiceManifestVersion=\"1.0.0\" />\r\n  </ServiceManifestImport>\r\n  <ServiceManifestImport>\r\n    <ServiceManifestRef ServiceManifestName=\"RestockRequestManager.ServicePkg\" ServiceManifestVersion=\"1.0.0\" />\r\n    <ConfigOverrides />\r\n  </ServiceManifestImport>\r\n  <ServiceManifestImport>\r\n    <ServiceManifestRef ServiceManifestName=\"Inventory.ServicePkg\" ServiceManifestVersion=\"1.0.0\" />\r\n    <ConfigOverrides />\r\n  </ServiceManifestImport>\r\n  <DefaultServices>\r\n    <Service Name=\"WebService\">\r\n      <StatelessService ServiceTypeName=\"WebServiceType\" InstanceCount=\"[WebService_InstanceCount]\">\r\n        <SingletonPartition />\r\n      </StatelessService>\r\n    </Service>\r\n    <Service Name=\"RestockRequestActorService\" GeneratedIdRef=\"cd8c75cc-03eb-4aec-ab00-dd3cc5048d9d|None\">\r\n      <StatefulService ServiceTypeName=\"RestockRequestActorServiceType\" TargetReplicaSetSize=\"[RestockRequestActorService_TargetReplicaSetSize]\" MinReplicaSetSize=\"[RestockRequestActorService_MinReplicaSetSize]\">\r\n        <UniformInt64Partition PartitionCount=\"[RestockRequestActorService_PartitionCount]\" LowKey=\"-9223372036854775808\" HighKey=\"9223372036854775807\" />\r\n      </StatefulService>\r\n    </Service>\r\n    <Service Name=\"CustomerOrderActorService\" GeneratedIdRef=\"36545b1e-9aa7-417b-a8aa-b7e28fd47353|None\">\r\n      <StatefulService ServiceTypeName=\"CustomerOrderActorServiceType\" TargetReplicaSetSize=\"[CustomerOrderActorService_TargetReplicaSetSize]\" MinReplicaSetSize=\"[CustomerOrderActorService_MinReplicaSetSize]\">\r\n        <UniformInt64Partition PartitionCount=\"[CustomerOrderActorService_PartitionCount]\" LowKey=\"-9223372036854775808\" HighKey=\"9223372036854775807\" />\r\n      </StatefulService>\r\n    </Service>\r\n    <Service Name=\"RestockRequestManager\">\r\n      <StatefulService ServiceTypeName=\"RestockRequestManagerServiceType\" TargetReplicaSetSize=\"[RestockRequestManagerService_TargetReplicaSetSize]\" MinReplicaSetSize=\"[RestockRequestManagerService_MinReplicaSetSize]\">\r\n        <SingletonPartition />\r\n      </StatefulService>\r\n    </Service>\r\n    <Service Name=\"InventoryService\">\r\n      <StatefulService ServiceTypeName=\"InventoryServiceType\" TargetReplicaSetSize=\"[InventoryService_TargetReplicaSetSize]\" MinReplicaSetSize=\"[InventoryService_MinReplicaSetSize]\">\r\n        <UniformInt64Partition PartitionCount=\"[InventoryService_PartitionCount]\" LowKey=\"-9223372036854775808\" HighKey=\"9223372036854775807\" />\r\n      </StatefulService>\r\n    </Service>\r\n  </DefaultServices>\r\n</ApplicationManifest>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/ApplicationParameters/Cloud.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Application Name=\"fabric:/WebReferenceApplication\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\n  <Parameters>\n    <Parameter Name=\"WebService_InstanceCount\" Value=\"-1\" />\n    <Parameter Name=\"RestockRequestActorService_PartitionCount\" Value=\"9\" />\n    <Parameter Name=\"RestockRequestActorService_MinReplicaSetSize\" Value=\"3\" />\n    <Parameter Name=\"RestockRequestActorService_TargetReplicaSetSize\" Value=\"3\" />\n    <Parameter Name=\"CustomerOrderActorService_PartitionCount\" Value=\"9\" />\n    <Parameter Name=\"CustomerOrderActorService_MinReplicaSetSize\" Value=\"3\" />\n    <Parameter Name=\"CustomerOrderActorService_TargetReplicaSetSize\" Value=\"3\" />\n    <Parameter Name=\"RestockRequestManagerService_MinReplicaSetSize\" Value=\"3\" />\n    <Parameter Name=\"RestockRequestManagerService_TargetReplicaSetSize\" Value=\"3\" />\n    <Parameter Name=\"InventoryService_PartitionCount\" Value=\"9\" />\n    <Parameter Name=\"InventoryService_MinReplicaSetSize\" Value=\"3\" />\n    <Parameter Name=\"InventoryService_TargetReplicaSetSize\" Value=\"3\" />   \n  </Parameters>\n</Application>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/ApplicationParameters/Local.1Node.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Application xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Name=\"fabric:/WebReferenceApplication\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\r\n  <Parameters>\r\n    <Parameter Name=\"WebService_InstanceCount\" Value=\"1\" />\r\n    <Parameter Name=\"RestockRequestActorService_PartitionCount\" Value=\"1\" />\r\n    <Parameter Name=\"RestockRequestActorService_MinReplicaSetSize\" Value=\"1\" />\r\n    <Parameter Name=\"RestockRequestActorService_TargetReplicaSetSize\" Value=\"1\" />\r\n    <Parameter Name=\"CustomerOrderActorService_PartitionCount\" Value=\"1\" />\r\n    <Parameter Name=\"CustomerOrderActorService_MinReplicaSetSize\" Value=\"1\" />\r\n    <Parameter Name=\"CustomerOrderActorService_TargetReplicaSetSize\" Value=\"1\" />\r\n    <Parameter Name=\"RestockRequestManagerService_MinReplicaSetSize\" Value=\"1\" />\r\n    <Parameter Name=\"RestockRequestManagerService_TargetReplicaSetSize\" Value=\"1\" />\r\n    <Parameter Name=\"InventoryService_PartitionCount\" Value=\"1\" />\r\n    <Parameter Name=\"InventoryService_MinReplicaSetSize\" Value=\"1\" />\r\n    <Parameter Name=\"InventoryService_TargetReplicaSetSize\" Value=\"1\" />\r\n  </Parameters>\r\n</Application>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/ApplicationParameters/Local.5Node.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Application xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Name=\"fabric:/WebReferenceApplication\" xmlns=\"http://schemas.microsoft.com/2011/01/fabric\">\r\n  <Parameters>\r\n    <Parameter Name=\"WebService_InstanceCount\" Value=\"-1\" />\r\n    <Parameter Name=\"RestockRequestActorService_PartitionCount\" Value=\"9\" />\r\n    <Parameter Name=\"RestockRequestActorService_MinReplicaSetSize\" Value=\"3\" />\r\n    <Parameter Name=\"RestockRequestActorService_TargetReplicaSetSize\" Value=\"3\" />\r\n    <Parameter Name=\"CustomerOrderActorService_PartitionCount\" Value=\"9\" />\r\n    <Parameter Name=\"CustomerOrderActorService_MinReplicaSetSize\" Value=\"3\" />\r\n    <Parameter Name=\"CustomerOrderActorService_TargetReplicaSetSize\" Value=\"3\" />\r\n    <Parameter Name=\"RestockRequestManagerService_MinReplicaSetSize\" Value=\"3\" />\r\n    <Parameter Name=\"RestockRequestManagerService_TargetReplicaSetSize\" Value=\"3\" />\r\n    <Parameter Name=\"InventoryService_PartitionCount\" Value=\"9\" />\r\n    <Parameter Name=\"InventoryService_MinReplicaSetSize\" Value=\"3\" />\r\n    <Parameter Name=\"InventoryService_TargetReplicaSetSize\" Value=\"3\" />\r\n  </Parameters>\r\n</Application>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/PublishProfiles/Cloud.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<PublishProfile xmlns=\"http://schemas.microsoft.com/2015/05/fabrictools\">\n  <!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.\n       Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.\n       \n       For a remote cluster, you would need to specify the appropriate parameters for that specific cluster.\n         For example: <ClusterConnectionParameters ConnectionEndpoint=\"mycluster.westus.cloudapp.azure.com:19000\" />\n\n       Example showing parameters for a cluster that uses certificate security:\n       <ClusterConnectionParameters ConnectionEndpoint=\"mycluster.westus.cloudapp.azure.com:19000\"\n                                    X509Credential=\"true\"\n                                    ServerCertThumbprint=\"0123456789012345678901234567890123456789\"\n                                    FindType=\"FindByThumbprint\"\n                                    FindValue=\"9876543210987654321098765432109876543210\"\n                                    StoreLocation=\"CurrentUser\"\n                                    StoreName=\"My\" />\n  -->\n  <ClusterConnectionParameters ConnectionEndpoint=\"party17982.westus.cloudapp.azure.com:19000\" />\n  <ApplicationParameterFile Path=\"..\\ApplicationParameters\\Cloud.xml\" />\n</PublishProfile>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/PublishProfiles/Local.1Node.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<PublishProfile xmlns=\"http://schemas.microsoft.com/2015/05/fabrictools\">\n  <!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.\n       Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.\n       \n       For a local cluster, you would typically not use any parameters.\n         For example: <ClusterConnectionParameters />\n  -->\n  <ClusterConnectionParameters />\n  <ApplicationParameterFile Path=\"..\\ApplicationParameters\\Local.1Node.xml\" />\n</PublishProfile>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/PublishProfiles/Local.5Node.xml",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<PublishProfile xmlns=\"http://schemas.microsoft.com/2015/05/fabrictools\">\n  <!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.\n       Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.\n       \n       For a local cluster, you would typically not use any parameters.\n         For example: <ClusterConnectionParameters />\n  -->\n  <ClusterConnectionParameters />\n  <ApplicationParameterFile Path=\"..\\ApplicationParameters\\Local.5Node.xml\" />\n</PublishProfile>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/Scripts/Deploy-FabricApplication.ps1",
    "content": "﻿<#\r\n.SYNOPSIS \r\nDeploys a Service Fabric application type to a cluster.\r\n\r\n.DESCRIPTION\r\nThis script deploys a Service Fabric application type to a cluster.  It is invoked by Visual Studio when deploying a Service Fabric Application project.\r\n\r\n.NOTES\r\nWARNING: This script file is invoked by Visual Studio.  Its parameters must not be altered but its logic can be customized as necessary.\r\n\r\n.PARAMETER PublishProfileFile\r\nPath to the file containing the publish profile.\r\n\r\n.PARAMETER ApplicationPackagePath\r\nPath to the folder of the packaged Service Fabric application.\r\n\r\n.PARAMETER DeployOnly\r\nIndicates that the Service Fabric application should not be created or upgraded after registering the application type.\r\n\r\n.PARAMETER ApplicationParameter\r\nHashtable of the Service Fabric application parameters to be used for the application.\r\n\r\n.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade\r\nIndicates whether to unregister any unused application versions that exist after an upgrade is finished.\r\n\r\n.PARAMETER OverrideUpgradeBehavior\r\nIndicates the behavior used to override the upgrade settings specified by the publish profile.\r\n'None' indicates that the upgrade settings will not be overridden.\r\n'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile.\r\n'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile.\r\n\r\n.PARAMETER UseExistingClusterConnection\r\nIndicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session.  The cluster connection parameters configured in the publish profile are ignored.\r\n\r\n.PARAMETER OverwriteBehavior\r\nOverwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application.\r\n'Never' will not remove the existing application. This is the default behavior.\r\n'Always' will remove the existing application even if its Application type and Version is different from the application being created. \r\n'SameAppTypeAndVersion' will remove the existing application only if its Application type and Version is same as the application being created.\r\n\r\n.PARAMETER SkipPackageValidation\r\nSwitch signaling whether the package should be validated or not before deployment.\r\n\r\n.PARAMETER SecurityToken\r\nA security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory.\r\n\r\n.PARAMETER CopyPackageTimeoutSec\r\nTimeout in seconds for copying application package to image store.\r\n\r\n.EXAMPLE\r\n. Scripts\\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\\Debug'\r\n\r\nDeploy the application using the default package location for a Debug build.\r\n\r\n.EXAMPLE\r\n. Scripts\\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\\Debug' -DoNotCreateApplication\r\n\r\nDeploy the application but do not create the application instance.\r\n\r\n.EXAMPLE\r\n. Scripts\\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'}\r\n\r\nDeploy the application by providing values for parameters that are defined in the application manifest.\r\n#>\r\n\r\nParam\r\n(\r\n    [String]\r\n    $PublishProfileFile,\r\n\r\n    [String]\r\n    $ApplicationPackagePath,\r\n\r\n    [Switch]\r\n    $DeployOnly,\r\n\r\n    [Hashtable]\r\n    $ApplicationParameter,\r\n\r\n    [Boolean]\r\n    $UnregisterUnusedApplicationVersionsAfterUpgrade,\r\n\r\n    [String]\r\n    [ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')]\r\n    $OverrideUpgradeBehavior = 'None',\r\n\r\n    [Switch]\r\n    $UseExistingClusterConnection,\r\n\r\n    [String]\r\n    [ValidateSet('Never','Always','SameAppTypeAndVersion')]\r\n    $OverwriteBehavior = 'Never',\r\n\r\n    [Switch]\r\n    $SkipPackageValidation,\r\n\r\n    [String]\r\n    $SecurityToken,\r\n\r\n    [int]\r\n    $CopyPackageTimeoutSec\r\n)\r\n\r\nfunction Read-XmlElementAsHashtable\r\n{\r\n    Param (\r\n        [System.Xml.XmlElement]\r\n        $Element\r\n    )\r\n\r\n    $hashtable = @{}\r\n    if ($Element.Attributes)\r\n    {\r\n        $Element.Attributes | \r\n            ForEach-Object {\r\n                $boolVal = $null\r\n                if ([bool]::TryParse($_.Value, [ref]$boolVal)) {\r\n                    $hashtable[$_.Name] = $boolVal\r\n                }\r\n                else {\r\n                    $hashtable[$_.Name] = $_.Value\r\n                }\r\n            }\r\n    }\r\n\r\n    return $hashtable\r\n}\r\n\r\nfunction Read-PublishProfile\r\n{\r\n    Param (\r\n        [ValidateScript({Test-Path $_ -PathType Leaf})]\r\n        [String]\r\n        $PublishProfileFile\r\n    )\r\n\r\n    $publishProfileXml = [Xml] (Get-Content $PublishProfileFile)\r\n    $publishProfile = @{}\r\n\r\n    $publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item(\"ClusterConnectionParameters\")\r\n    $publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item(\"UpgradeDeployment\")\r\n    $publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item(\"CopyPackageParameters\")\r\n\r\n    if ($publishProfileXml.PublishProfile.Item(\"UpgradeDeployment\"))\r\n    {\r\n        $publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item(\"UpgradeDeployment\").Item(\"Parameters\")\r\n        if ($publishProfile.UpgradeDeployment[\"Mode\"])\r\n        {\r\n            $publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment[\"Mode\"]] = $true\r\n        }\r\n    }\r\n\r\n    $publishProfileFolder = (Split-Path $PublishProfileFile)\r\n    $publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path)\r\n\r\n    return $publishProfile\r\n}\r\n\r\n$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path)\r\n\r\nif (!$PublishProfileFile)\r\n{\r\n    $PublishProfileFile = \"$LocalFolder\\..\\PublishProfiles\\Local.xml\"\r\n}\r\n\r\nif (!$ApplicationPackagePath)\r\n{\r\n    $ApplicationPackagePath = \"$LocalFolder\\..\\pkg\\Release\"\r\n}\r\n\r\n$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath\r\n\r\n$publishProfile = Read-PublishProfile $PublishProfileFile\r\n\r\nif (-not $UseExistingClusterConnection)\r\n{\r\n    $ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters\r\n    if ($SecurityToken)\r\n    {\r\n        $ClusterConnectionParameters[\"SecurityToken\"] = $SecurityToken\r\n    }\r\n\r\n    try\r\n    {\r\n        [void](Connect-ServiceFabricCluster @ClusterConnectionParameters)\r\n    }\r\n    catch [System.Fabric.FabricObjectClosedException]\r\n    {\r\n        Write-Warning \"Service Fabric cluster may not be connected.\"\r\n        throw\r\n    }\r\n}\r\n\r\n$RegKey = \"HKLM:\\SOFTWARE\\Microsoft\\Service Fabric SDK\"\r\n$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath\r\nImport-Module \"$ModuleFolderPath\\ServiceFabricSDK.psm1\"\r\n\r\n$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade'\r\n\r\n$PublishParameters = @{\r\n    'ApplicationPackagePath' = $ApplicationPackagePath\r\n    'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile\r\n    'ApplicationParameter' = $ApplicationParameter\r\n    'ErrorAction' = 'Stop'\r\n}\r\n\r\nif ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec)\r\n{\r\n    $PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec\r\n}\r\n\r\nif ($publishProfile.CopyPackageParameters.CompressPackage)\r\n{\r\n    $PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage\r\n}\r\n\r\n# CopyPackageTimeoutSec parameter overrides the value from the publish profile\r\nif ($CopyPackageTimeoutSec)\r\n{\r\n    $PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec\r\n}\r\n\r\nif ($IsUpgrade)\r\n{\r\n    $Action = \"RegisterAndUpgrade\"\r\n    if ($DeployOnly)\r\n    {\r\n        $Action = \"Register\"\r\n    }\r\n    \r\n    $UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters\r\n\r\n    if ($OverrideUpgradeBehavior -eq 'ForceUpgrade')\r\n    {\r\n        # Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior.\r\n        $UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true }\r\n    }\r\n\r\n    $PublishParameters['Action'] = $Action\r\n    $PublishParameters['UpgradeParameters'] = $UpgradeParameters\r\n    $PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade\r\n\r\n    Publish-UpgradedServiceFabricApplication @PublishParameters\r\n}\r\nelse\r\n{\r\n    $Action = \"RegisterAndCreate\"\r\n    if ($DeployOnly)\r\n    {\r\n        $Action = \"Register\"\r\n    }\r\n\r\n    $PublishParameters['Action'] = $Action\r\n    $PublishParameters['OverwriteBehavior'] = $OverwriteBehavior\r\n    $PublishParameters['SkipPackageValidation'] = $SkipPackageValidation\r\n    \r\n    Publish-NewServiceFabricApplication @PublishParameters\r\n}"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/WebReferenceApplication.sfproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"..\\packages\\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.5.0\\build\\Microsoft.VisualStudio.Azure.Fabric.Application.props\" Condition=\"Exists('..\\packages\\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.5.0\\build\\Microsoft.VisualStudio.Azure.Fabric.Application.props')\" />\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>0ee37b65-fccb-44ae-b4f7-aed85fdeb072</ProjectGuid>\r\n    <ProjectVersion>1.5</ProjectVersion>\r\n    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\r\n    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\r\n    <MinToolsVersion>1.5</MinToolsVersion>\r\n  </PropertyGroup>\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"Scripts\\Deploy-FabricApplication.ps1\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"..\\CustomerOrder.Actor\\CustomerOrder.Actor.csproj\" />\r\n    <ProjectReference Include=\"..\\Inventory.Service\\Inventory.Service.csproj\" />\r\n    <ProjectReference Include=\"..\\RestockRequest.Actor\\RestockRequest.Actor.csproj\" />\r\n    <ProjectReference Include=\"..\\RestockRequestManager.Service\\RestockRequestManager.Service.csproj\" />\r\n    <ProjectReference Include=\"..\\Web.Service\\Web.Service.csproj\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Content Include=\"app.config\" />\r\n    <Content Include=\"ApplicationPackageRoot\\ApplicationManifest.xml\" />\r\n    <Content Include=\"ApplicationParameters\\Cloud.xml\" />\r\n    <Content Include=\"ApplicationParameters\\Local.1Node.xml\" />\r\n    <Content Include=\"ApplicationParameters\\Local.5Node.xml\" />\r\n    <Content Include=\"packages.config\" />\r\n    <Content Include=\"PublishProfiles\\Cloud.xml\" />\r\n    <Content Include=\"PublishProfiles\\Local.1Node.xml\" />\r\n    <Content Include=\"PublishProfiles\\Local.5Node.xml\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.Common.targets\" />\r\n  <PropertyGroup>\r\n    <ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\Service Fabric Tools\\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(ApplicationProjectTargetsPath)\" Condition=\"Exists('$(ApplicationProjectTargetsPath)')\" />\r\n  <Import Project=\"..\\packages\\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.5.0\\build\\Microsoft.VisualStudio.Azure.Fabric.Application.targets\" Condition=\"Exists('..\\packages\\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.5.0\\build\\Microsoft.VisualStudio.Azure.Fabric.Application.targets')\" />\r\n</Project>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/app.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<configuration>\n  <runtime>\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n      <dependentAssembly>\n        <assemblyIdentity name=\"Microsoft.Azure.KeyVault.Core\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n        <bindingRedirect oldVersion=\"0.0.0.0-2.0.0.0\" newVersion=\"2.0.0.0\" />\n      </dependentAssembly>\n      <dependentAssembly>\n        <assemblyIdentity name=\"Newtonsoft.Json\" publicKeyToken=\"30ad4fe6b2a6aeed\" culture=\"neutral\" />\n        <bindingRedirect oldVersion=\"0.0.0.0-10.0.0.0\" newVersion=\"10.0.0.0\" />\n      </dependentAssembly>\n      <dependentAssembly>\n        <assemblyIdentity name=\"Microsoft.Owin\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n        <bindingRedirect oldVersion=\"0.0.0.0-3.1.0.0\" newVersion=\"3.1.0.0\" />\n      </dependentAssembly>\n    </assemblyBinding>\n  </runtime>\n</configuration>"
  },
  {
    "path": "ReferenceApp/WebReferenceApplication/packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<packages>\r\n  <package id=\"Microsoft.VisualStudio.Azure.Fabric.MSBuild\" version=\"1.5.0\" />\r\n</packages>"
  }
]