From 0ae707fe78ca42da281c2c97e33f2c653063b149 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Mon, 26 Nov 2012 11:18:06 -0100 Subject: [PATCH] Refactoring the umbraco version from GlobalSettings to be a seperate class that simply wraps the version from the assembly. Since the version will come from the assembly there is no need to have it as part of the GlobalSetting, which is internal and needs a makeover of its own. --- src/Umbraco.Core/ApplicationContext.cs | 2 +- .../Configuration/GlobalSettings.cs | 34 ++++++------------- .../Configuration/UmbracoVersion.cs | 27 +++++++++++++++ src/Umbraco.Core/Umbraco.Core.csproj | 1 + src/Umbraco.Tests/GlobalSettingsTests.cs | 3 +- .../Routing/UmbracoModuleTests.cs | 3 +- .../config/splashes/noNodes.aspx | 3 +- src/Umbraco.Web.UI/install/Title.ascx | 3 +- .../install/steps/database.ascx | 7 ++-- src/Umbraco.Web.UI/install/steps/welcome.ascx | 3 +- .../umbraco.presentation/install/Title.ascx | 3 +- .../Skinning/loadStarterKitDesigns.ascx.cs | 3 +- .../install/steps/database.ascx | 7 ++-- .../install/steps/theend.ascx.cs | 3 +- .../install/steps/welcome.ascx | 3 +- .../umbraco.presentation/requestModule.cs | 4 +-- .../Packages/BrowseRepository.aspx.cs | 7 ++-- .../umbraco/dialogs/about.aspx.cs | 3 +- .../webservices/CheckForUpgrade.asmx.cs | 11 +++--- src/umbraco.businesslogic/GlobalSettings.cs | 21 ++++++------ 20 files changed, 91 insertions(+), 60 deletions(-) create mode 100644 src/Umbraco.Core/Configuration/UmbracoVersion.cs diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index a096858f90..d96880a2e2 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -90,7 +90,7 @@ namespace Umbraco.Core try { string configStatus = ConfigurationStatus; - string currentVersion = GlobalSettings.Version.ToString(3); + string currentVersion = UmbracoVersion.Current.ToString(3); if (currentVersion != configStatus) diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index 5903598d09..5b9f24551d 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -254,7 +254,7 @@ namespace Umbraco.Core.Configuration try { string configStatus = ConfigurationStatus; - string currentVersion = Version.ToString(3); + string currentVersion = UmbracoVersion.Current.ToString(3); if (currentVersion != configStatus) @@ -406,28 +406,16 @@ namespace Umbraco.Core.Configuration } } - /// - /// Gets the current version of Umbraco. - /// Version class with the specified major, minor, build (Patch), and revision numbers. - /// - /// - /// CURRENT UMBRACO VERSION ID. - /// - public static Version Version - { - get { return _version ?? (_version = typeof (GlobalSettings).Assembly.GetName().Version); } - } - /// /// Gets the current version. /// /// The current version. - [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] + [Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)] public static string CurrentVersion { get { - return Version.ToString(3); + return UmbracoVersion.Current.ToString(3); } } @@ -435,12 +423,12 @@ namespace Umbraco.Core.Configuration /// Gets the major version number. /// /// The major version number. - [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] + [Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)] public static int VersionMajor { get { - return Version.Major; + return UmbracoVersion.Current.Major; } } @@ -448,12 +436,12 @@ namespace Umbraco.Core.Configuration /// Gets the minor version number. /// /// The minor version number. - [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] + [Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)] public static int VersionMinor { get { - return Version.Minor; + return UmbracoVersion.Current.Minor; } } @@ -461,12 +449,12 @@ namespace Umbraco.Core.Configuration /// Gets the patch version number. /// /// The patch version number. - [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] + [Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)] public static int VersionPatch { get { - return Version.Build; + return UmbracoVersion.Current.Build; } } @@ -474,12 +462,12 @@ namespace Umbraco.Core.Configuration /// Gets the version comment (like beta or RC). /// /// The version comment. - [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] + [Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)] public static string VersionComment { get { - return ""; + return Umbraco.Core.Configuration.UmbracoVersion.CurrentComment; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs new file mode 100644 index 0000000000..58c4364da3 --- /dev/null +++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs @@ -0,0 +1,27 @@ +using System; + +namespace Umbraco.Core.Configuration +{ + public class UmbracoVersion + { + private static Version _version; + + /// + /// Gets the current version of Umbraco. + /// Version class with the specified major, minor, build (Patch), and revision numbers. + /// + /// + /// CURRENT UMBRACO VERSION ID. + /// + public static Version Current + { + get { return _version ?? (_version = typeof(UmbracoVersion).Assembly.GetName().Version); } + } + + /// + /// Gets the version comment (like beta or RC). + /// + /// The version comment. + public static string CurrentComment { get { return ""; } } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index c9f85c43b6..b86fcd642b 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -73,6 +73,7 @@ + diff --git a/src/Umbraco.Tests/GlobalSettingsTests.cs b/src/Umbraco.Tests/GlobalSettingsTests.cs index ea3a569428..f411a55a93 100644 --- a/src/Umbraco.Tests/GlobalSettingsTests.cs +++ b/src/Umbraco.Tests/GlobalSettingsTests.cs @@ -1,6 +1,7 @@ using System.Configuration; using System.Web.Routing; using NUnit.Framework; +using Umbraco.Core.Configuration; using Umbraco.Tests.TestHelpers; using System.Web.Mvc; @@ -32,7 +33,7 @@ namespace Umbraco.Tests [Test] public void Is_Version_From_Assembly_Correct() { - Assert.That(Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3), Is.EqualTo("6.0.0")); + Assert.That(UmbracoVersion.Current.ToString(3), Is.EqualTo("6.0.0")); } [TestCase("/umbraco/umbraco.aspx")] diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs index 78a484e8fd..aa6ec83ec6 100644 --- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs +++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Xml; using NUnit.Framework; using Umbraco.Core; +using Umbraco.Core.Configuration; using Umbraco.Tests.TestHelpers; using Umbraco.Web; using Umbraco.Web.Routing; @@ -57,7 +58,7 @@ namespace Umbraco.Tests.Routing //create the module _module = new UmbracoModule(); - ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)); + ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", UmbracoVersion.Current.ToString(3)); ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "~/umbraco,~/install/"); ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd"); diff --git a/src/Umbraco.Web.UI/config/splashes/noNodes.aspx b/src/Umbraco.Web.UI/config/splashes/noNodes.aspx index b41724e1c5..640bb0229f 100644 --- a/src/Umbraco.Web.UI/config/splashes/noNodes.aspx +++ b/src/Umbraco.Web.UI/config/splashes/noNodes.aspx @@ -1,4 +1,5 @@ <%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> +<%@ Import Namespace="Umbraco.Core.Configuration" %> @@ -7,7 +8,7 @@ Umbraco - <%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%> + <%=UmbracoVersion.Current.ToString(3)%> - no pages found diff --git a/src/Umbraco.Web.UI/install/Title.ascx b/src/Umbraco.Web.UI/install/Title.ascx index 94eef72f48..4765f32e63 100644 --- a/src/Umbraco.Web.UI/install/Title.ascx +++ b/src/Umbraco.Web.UI/install/Title.ascx @@ -1,2 +1,3 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Title.ascx.cs" Inherits="umbraco.presentation.install.Title" %> -Umbraco <%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%> Configuration Wizard \ No newline at end of file +<%@ Import Namespace="Umbraco.Core.Configuration" %> +Umbraco <%=UmbracoVersion.Current.ToString(3)%> Configuration Wizard \ No newline at end of file diff --git a/src/Umbraco.Web.UI/install/steps/database.ascx b/src/Umbraco.Web.UI/install/steps/database.ascx index 3f743d8052..77e33f5441 100644 --- a/src/Umbraco.Web.UI/install/steps/database.ascx +++ b/src/Umbraco.Web.UI/install/steps/database.ascx @@ -1,5 +1,6 @@ <%@ Control Language="c#" AutoEventWireup="True" CodeBehind="database.ascx.cs" Inherits="umbraco.presentation.install.steps.detect" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> +<%@ Import Namespace="Umbraco.Core.Configuration" %>
@@ -209,7 +210,7 @@