using System;
using System.Collections.Generic;
using Microsoft.SharePoint.Administration;
namespace SWO
{
public static class SharePointFriendlyVersion
{
private static readonly Dictionary<string, string> _friendlyNames = new Dictionary<string, string>();
private const int _latestBuildNo = 6129;
private const string _latestBuildName = "October 2012 CU";
static SharePointFriendlyVersion()
{
SharePointFriendlyVersion.InitializeVersionsCollection();
}
private static void InitializeVersionsCollection()
{
_friendlyNames.Add("14.0.4763.1000", "RTM");
_friendlyNames.Add("14.0.4762.1000", "RTM");
_friendlyNames.Add("14.0.5114.5003", "June 2010 CU");
_friendlyNames.Add("14.0.5123.5000", "August 2010 CU");
_friendlyNames.Add("14.0.5128.5000", "October 2010 CU");
_friendlyNames.Add("14.0.5130.5002", "December 2010 CU");
_friendlyNames.Add("14.0.5136.5002", "February 2011 CU");
_friendlyNames.Add("14.0.5138.5000", "April 2011 CU");
_friendlyNames.Add("14.0.6029.1000", "Service Pack 1");
_friendlyNames.Add("14.0.6105.5000", "June 2011 CU Mark 1");
_friendlyNames.Add("14.0.6109.5002", "August 2011 CU");
_friendlyNames.Add("14.0.6109.5000", "August 2011 CU");
_friendlyNames.Add("14.0.6112.5000", "October 2011 CU");
_friendlyNames.Add("14.0.6114.5000", "December 2011 CU");
_friendlyNames.Add("14.0.6117.5002", "February 2012 CU");
_friendlyNames.Add("14.0.6120.5000", "April 2012 CU");
_friendlyNames.Add("14.0.6120.5006", "April 2012 CU Mark 2");
_friendlyNames.Add("14.0.6123.5002", "June 2012 CU");
_friendlyNames.Add("14.0.6126.5002", "August 2012 CU");
_friendlyNames.Add("14.0.6129.5000", "October 2012 CU");
}
public static string GetForBuildVersion(string buildVersion)
{
if (string.IsNullOrEmpty(buildVersion))
throw new ArgumentException("buildVersion");
var version = new Version(buildVersion);
return GetForBuildVersion(version);
}
public static string GetForBuildVersion(Version buildVersion)
{
if (buildVersion == null)
throw new ArgumentNullException("buildVersion");
if (_friendlyNames.ContainsKey(buildVersion.ToString()) == false)
if (buildVersion.Build > _latestBuildNo)
return "Newer than " + _latestBuildName;
else
return "Build version not found";
return SharePointFriendlyVersion._friendlyNames[buildVersion.ToString()];
}
public static string GetFromContext()
{
return GetForBuildVersion(SPFarm.Local.BuildVersion.ToString());
}
}
}
No comments:
Post a Comment