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.
This commit is contained in:
Morten Christensen
2012-11-26 11:18:06 -01:00
parent 34ac97442d
commit 0ae707fe78
20 changed files with 91 additions and 60 deletions

View File

@@ -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)

View File

@@ -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
}
}
/// <summary>
/// Gets the current version of Umbraco.
/// Version class with the specified major, minor, build (Patch), and revision numbers.
/// </summary>
/// <remarks>
/// CURRENT UMBRACO VERSION ID.
/// </remarks>
public static Version Version
{
get { return _version ?? (_version = typeof (GlobalSettings).Assembly.GetName().Version); }
}
/// <summary>
/// Gets the current version.
/// </summary>
/// <value>The current version.</value>
[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.
/// </summary>
/// <value>The major version number.</value>
[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.
/// </summary>
/// <value>The minor version number.</value>
[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.
/// </summary>
/// <value>The patch version number.</value>
[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).
/// </summary>
/// <value>The version comment.</value>
[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;
}
}

View File

@@ -0,0 +1,27 @@
using System;
namespace Umbraco.Core.Configuration
{
public class UmbracoVersion
{
private static Version _version;
/// <summary>
/// Gets the current version of Umbraco.
/// Version class with the specified major, minor, build (Patch), and revision numbers.
/// </summary>
/// <remarks>
/// CURRENT UMBRACO VERSION ID.
/// </remarks>
public static Version Current
{
get { return _version ?? (_version = typeof(UmbracoVersion).Assembly.GetName().Version); }
}
/// <summary>
/// Gets the version comment (like beta or RC).
/// </summary>
/// <value>The version comment.</value>
public static string CurrentComment { get { return ""; } }
}
}

View File

@@ -73,6 +73,7 @@
<Compile Include="Configuration\FileSystemProviderElementCollection.cs" />
<Compile Include="Configuration\FileSystemProvidersSection.cs" />
<Compile Include="Configuration\InfrastructureSettings\Infrastructure.cs" />
<Compile Include="Configuration\UmbracoVersion.cs" />
<Compile Include="CoreBootManager.cs" />
<Compile Include="DatabaseContext.cs" />
<Compile Include="DataTableExtensions.cs" />

View File

@@ -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")]

View File

@@ -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");

View File

@@ -1,4 +1,5 @@
<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %>
<%@ Import Namespace="Umbraco.Core.Configuration" %>
<!DOCTYPE html>
<html>
@@ -7,7 +8,7 @@
<meta charset="utf-8">
<title>Umbraco
<%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%>
<%=UmbracoVersion.Current.ToString(3)%>
- no pages found</title>

View File

@@ -1,2 +1,3 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Title.ascx.cs" Inherits="umbraco.presentation.install.Title" %>
<title>Umbraco <%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%> Configuration Wizard</title>
<%@ Import Namespace="Umbraco.Core.Configuration" %>
<title>Umbraco <%=UmbracoVersion.Current.ToString(3)%> Configuration Wizard</title>

View File

@@ -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" %>
<asp:PlaceHolder ID="settings" runat="server" Visible="true">
<!-- database box -->
<div class="tab main-tabinfo">
@@ -209,7 +210,7 @@
</div>
<script type="text/javascript">
var hasEmbeddedDlls = <%= HasEmbeddedDatabaseFiles.ToString().ToLower() %>;
var currentVersion = '<%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%>';
var currentVersion = '<%=UmbracoVersion.Current.ToString(3)%>';
var configured = <%= IsConfigured.ToString().ToLower() %>;
jQuery(document).ready(function(){
@@ -336,7 +337,7 @@
<div class="success">
<p>
Umbraco
<%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%>
<%=UmbracoVersion.Current.ToString(3)%>
has now been copied to your database. Press <b>Continue</b> to proceed.
</p>
</div>
@@ -346,7 +347,7 @@
<div class="success">
<p>
Your database has been upgraded to version:
<%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%>.<br />
<%=UmbracoVersion.Current.ToString(3)%>.<br />
Press <b>Continue</b> to proceed.
</p>
</div>

View File

@@ -1,5 +1,6 @@
<%@ Control Language="c#" AutoEventWireup="True" CodeBehind="welcome.ascx.cs" Inherits="umbraco.presentation.install.welcome"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Import Namespace="Umbraco.Core.Configuration" %>
<!-- welcome box -->
<div class="tab main-tabinfo">
<div class="container">
@@ -30,7 +31,7 @@
<asp:PlaceHolder ID="ph_upgrade" runat="server" Visible="false">
<h1>Upgrading Umbraco</h1>
<p>
Welcome to the umbraco upgrade wizard. This will make sure that you upgrade safely from your old version to <strong>Umbraco version <%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3) %></strong>
Welcome to the umbraco upgrade wizard. This will make sure that you upgrade safely from your old version to <strong>Umbraco version <%=UmbracoVersion.Current.ToString(3) %></strong>
</p>
<p>
As this is an upgrade, <strong>the wizard might skip steps</strong> that are only needed for new umbraco installations. It might also ask you questions you've already answered once. But do not worry,

View File

@@ -1,2 +1,3 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Title.ascx.cs" Inherits="umbraco.presentation.install.Title" %>
<title>Umbraco <%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%> Configuration Wizard</title>
<%@ Import Namespace="Umbraco.Core.Configuration" %>
<title>Umbraco <%=UmbracoVersion.Current.ToString(3)%> Configuration Wizard</title>

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Umbraco.Core.Configuration;
using umbraco.BusinessLogic;
namespace umbraco.presentation.install.steps.Skinning
@@ -130,7 +131,7 @@ namespace umbraco.presentation.install.steps.Skinning
if (string.IsNullOrEmpty(GlobalSettings.ConfigurationStatus))
{
GlobalSettings.ConfigurationStatus = Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3);
GlobalSettings.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
Application["umbracoNeedConfiguration"] = false;
}
}

View File

@@ -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" %>
<asp:PlaceHolder ID="settings" runat="server" Visible="true">
<!-- database box -->
<div class="tab main-tabinfo">
@@ -209,7 +210,7 @@
</div>
<script type="text/javascript">
var hasEmbeddedDlls = <%= HasEmbeddedDatabaseFiles.ToString().ToLower() %>;
var currentVersion = '<%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%>';
var currentVersion = '<%=UmbracoVersion.Current.ToString(3)%>';
var configured = <%= IsConfigured.ToString().ToLower() %>;
jQuery(document).ready(function(){
@@ -336,7 +337,7 @@
<div class="success">
<p>
Umbraco
<%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%>
<%=UmbracoVersion.Current.ToString(3)%>
has now been copied to your database. Press <b>Continue</b> to proceed.
</p>
</div>
@@ -346,7 +347,7 @@
<div class="success">
<p>
Your database has been upgraded to version:
<%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%>.<br />
<%=UmbracoVersion.Current.ToString(3)%>.<br />
Press <b>Continue</b> to proceed.
</p>
</div>

View File

@@ -1,4 +1,5 @@
using System.IO;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using umbraco.BusinessLogic;
@@ -23,7 +24,7 @@ namespace umbraco.presentation.install.steps
try
{
GlobalSettings.ConfigurationStatus = Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3);
GlobalSettings.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
Application["umbracoNeedConfiguration"] = false;
}
catch (Exception)

View File

@@ -1,5 +1,6 @@
<%@ Control Language="c#" AutoEventWireup="True" CodeBehind="welcome.ascx.cs" Inherits="umbraco.presentation.install.welcome"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Import Namespace="Umbraco.Core.Configuration" %>
<!-- welcome box -->
<div class="tab main-tabinfo">
<div class="container">
@@ -30,7 +31,7 @@
<asp:PlaceHolder ID="ph_upgrade" runat="server" Visible="false">
<h1>Upgrading Umbraco</h1>
<p>
Welcome to the umbraco upgrade wizard. This will make sure that you upgrade safely from your old version to <strong>Umbraco version <%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3) %></strong>
Welcome to the umbraco upgrade wizard. This will make sure that you upgrade safely from your old version to <strong>Umbraco version <%=UmbracoVersion.Current.ToString(3) %></strong>
</p>
<p>
As this is an upgrade, <strong>the wizard might skip steps</strong> that are only needed for new umbraco installations. It might also ask you questions you've already answered once. But do not worry,

View File

@@ -3,7 +3,7 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Web;
using Umbraco.Core.Configuration;
using umbraco.BusinessLogic;
using System.Collections.Generic;
using umbraco.BusinessLogic.Utils;
@@ -371,7 +371,7 @@ namespace umbraco.presentation
// Check for configured key, checking for currentversion to ensure that a request with
// no httpcontext don't set the whole app in configure mode
if (Umbraco.Core.Configuration.GlobalSettings.Version != null && !GlobalSettings.Configured)
if (UmbracoVersion.Current != null && !GlobalSettings.Configured)
{
HttpApp.Application["umbracoNeedConfiguration"] = true;
}

View File

@@ -10,6 +10,7 @@ using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Xml.XPath;
using Umbraco.Core.Configuration;
using umbraco.IO;
namespace umbraco.presentation.developer.packages {
@@ -47,9 +48,9 @@ namespace umbraco.presentation.developer.packages {
url, repoGuid, category, Request.ServerVariables["SERVER_NAME"],
Request.ServerVariables["SERVER_PORT"], IOHelper.ResolveUrl(SystemDirectories.Umbraco),
IOHelper.ResolveUrl(SystemDirectories.Umbraco).Trim('/'), repoGuid,
Umbraco.Core.Configuration.GlobalSettings.Version.Major,
Umbraco.Core.Configuration.GlobalSettings.Version.Minor,
Umbraco.Core.Configuration.GlobalSettings.Version.Build,
UmbracoVersion.Current.Major,
UmbracoVersion.Current.Minor,
UmbracoVersion.Current.Build,
UmbracoSettings.UseLegacyXmlSchema.ToString(), Environment.Version,
Umbraco.Core.SystemUtilities.GetCurrentTrustLevel());
}

View File

@@ -10,6 +10,7 @@ using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Reflection;
using System.Diagnostics;
using Umbraco.Core.Configuration;
using umbraco.IO;
namespace umbraco.dialogs
@@ -23,7 +24,7 @@ namespace umbraco.dialogs
protected void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
version.Text = Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3);
version.Text = UmbracoVersion.Current.ToString(3);
thisYear.Text = DateTime.Now.Year.ToString();

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using Umbraco.Core.Configuration;
namespace umbraco.presentation.webservices
@@ -24,10 +25,10 @@ namespace umbraco.presentation.webservices
legacyAjaxCalls.Authorize();
org.umbraco.update.CheckForUpgrade check = new global::umbraco.presentation.org.umbraco.update.CheckForUpgrade();
org.umbraco.update.UpgradeResult result = check.CheckUpgrade(Umbraco.Core.Configuration.GlobalSettings.Version.Major,
Umbraco.Core.Configuration.GlobalSettings.Version.Minor,
Umbraco.Core.Configuration.GlobalSettings.Version.Build,
Umbraco.Core.Configuration.GlobalSettings.VersionComment);
org.umbraco.update.UpgradeResult result = check.CheckUpgrade(UmbracoVersion.Current.Major,
UmbracoVersion.Current.Minor,
UmbracoVersion.Current.Build,
UmbracoVersion.CurrentComment);
return new UpgradeResult(result.UpgradeType.ToString(), result.Comment, result.UpgradeUrl);
}
@@ -43,7 +44,7 @@ namespace umbraco.presentation.webservices
{
UpgradeType = upgradeType;
UpgradeComment = upgradeComment;
UpgradeUrl = upgradeUrl + "?version=" + HttpContext.Current.Server.UrlEncode(Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3));
UpgradeUrl = upgradeUrl + "?version=" + HttpContext.Current.Server.UrlEncode(UmbracoVersion.Current.ToString(3));
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Web.Hosting;
using System.Web.Configuration;
using System.Xml;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using umbraco.BusinessLogic;
using umbraco.IO;
@@ -293,50 +294,50 @@ namespace umbraco
/// Gets the current version.
/// </summary>
/// <value>The current version.</value>
[Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)]
[Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)]
public static string CurrentVersion
{
get { return Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3); }
get { return UmbracoVersion.Current.ToString(3); }
}
/// <summary>
/// Gets the major version number.
/// </summary>
/// <value>The major version number.</value>
[Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)]
[Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)]
public static int VersionMajor
{
get { return Umbraco.Core.Configuration.GlobalSettings.Version.Major; }
get { return UmbracoVersion.Current.Major; }
}
/// <summary>
/// Gets the minor version number.
/// </summary>
/// <value>The minor version number.</value>
[Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)]
[Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)]
public static int VersionMinor
{
get { return Umbraco.Core.Configuration.GlobalSettings.Version.Minor; }
get { return UmbracoVersion.Current.Minor; }
}
/// <summary>
/// Gets the patch version number.
/// </summary>
/// <value>The patch version number.</value>
[Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)]
[Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)]
public static int VersionPatch
{
get { return Umbraco.Core.Configuration.GlobalSettings.Version.Build; }
get { return UmbracoVersion.Current.Build; }
}
/// <summary>
/// Gets the version comment (like beta or RC).
/// </summary>
/// <value>The version comment.</value>
[Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)]
[Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)]
public static string VersionComment
{
get { return Umbraco.Core.Configuration.GlobalSettings.VersionComment; }
get { return Umbraco.Core.Configuration.UmbracoVersion.CurrentComment; }
}