From b50b7ddb4c231810d17e0141bb77437718b10110 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 1 Jan 2019 14:30:20 +0200 Subject: Some more work on environments... --- Software/Visual_Studio/Tango.Web/DeploymentSlot.cs | 5 ++++ .../Tango.Web/DeploymentSlotAddressAttribute.cs | 19 +++++++++++++++ .../ExtensionMethods/DeploymentSlotExtensions.cs | 20 ++++++++++++++++ Software/Visual_Studio/Tango.Web/Tango.Web.csproj | 7 ++++++ Software/Visual_Studio/Tango.Web/WebSettings.cs | 27 ++++++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 Software/Visual_Studio/Tango.Web/DeploymentSlotAddressAttribute.cs create mode 100644 Software/Visual_Studio/Tango.Web/ExtensionMethods/DeploymentSlotExtensions.cs create mode 100644 Software/Visual_Studio/Tango.Web/WebSettings.cs (limited to 'Software/Visual_Studio/Tango.Web') diff --git a/Software/Visual_Studio/Tango.Web/DeploymentSlot.cs b/Software/Visual_Studio/Tango.Web/DeploymentSlot.cs index 7ec7ab82e..6531adb64 100644 --- a/Software/Visual_Studio/Tango.Web/DeploymentSlot.cs +++ b/Software/Visual_Studio/Tango.Web/DeploymentSlot.cs @@ -10,14 +10,19 @@ namespace Tango.Web public enum DeploymentSlot { [Description("Development")] + [DeploymentSlotAddress("https://machineservice-dev.twine-srv.com")] DEV, [Description("Testing")] + [DeploymentSlotAddress("https://machineservice-test.twine-srv.com")] TEST, [Description("Process")] + [DeploymentSlotAddress("https://machineservice-process.twine-srv.com")] PROCESS, [Description("Staging")] + [DeploymentSlotAddress("https://machineservice-stage.twine-srv.com")] STAGE, [Description("Production")] + [DeploymentSlotAddress("https://machineservice.twine-srv.com")] PROD } } diff --git a/Software/Visual_Studio/Tango.Web/DeploymentSlotAddressAttribute.cs b/Software/Visual_Studio/Tango.Web/DeploymentSlotAddressAttribute.cs new file mode 100644 index 000000000..c58c7a8b0 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/DeploymentSlotAddressAttribute.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Web +{ + [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] + public class DeploymentSlotAddressAttribute : Attribute + { + public DeploymentSlotAddressAttribute(String address) + { + Address = address; + } + + public String Address { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Web/ExtensionMethods/DeploymentSlotExtensions.cs b/Software/Visual_Studio/Tango.Web/ExtensionMethods/DeploymentSlotExtensions.cs new file mode 100644 index 000000000..04e5ac300 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/ExtensionMethods/DeploymentSlotExtensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Web; + +public static class DeploymentSlotExtensions +{ + /// + /// Gets the deployment slot web address. + /// + /// The slot. + /// + public static String ToAddress(this DeploymentSlot slot) + { + return slot.GetAttribute().Address; + } +} + diff --git a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj index d9a1d1dd1..d0d30482d 100644 --- a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj +++ b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj @@ -246,6 +246,8 @@ + + @@ -260,6 +262,7 @@ + @@ -282,6 +285,10 @@ {e4927038-348d-4295-aaf4-861c58cb3943} Tango.PMR + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + diff --git a/Software/Visual_Studio/Tango.Web/WebSettings.cs b/Software/Visual_Studio/Tango.Web/WebSettings.cs new file mode 100644 index 000000000..fdc92810c --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/WebSettings.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; +using System.Reflection; + +namespace Tango.Web +{ + public class WebSettings : SettingsBase + { + /// + /// Gets or sets the deployment slot. + /// + public DeploymentSlot DeploymentSlot { get; set; } + + /// + /// Gets the machine service address. + /// + /// + public String GetMachineServiceAddress() + { + return DeploymentSlot.GetAttribute().Address; + } + } +} -- cgit v1.3.1