diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-06-20 22:11:01 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-06-20 22:11:01 -0700 |
commit | 15f234f335ab7cdbcb14cc25a97f5dba22c7c663 (patch) | |
tree | 69b51e7c23497bcb356614374af925d7dfe97205 /src/DotNetOpenAuth.Core/Util.cs | |
parent | 5893cc9e24eafe3982a7b8c467845b6e99ece8bc (diff) | |
parent | 191a46b778536eb9ce26d2589039ddbb765ef5c6 (diff) | |
download | DotNetOpenAuth-15f234f335ab7cdbcb14cc25a97f5dba22c7c663.zip DotNetOpenAuth-15f234f335ab7cdbcb14cc25a97f5dba22c7c663.tar.gz DotNetOpenAuth-15f234f335ab7cdbcb14cc25a97f5dba22c7c663.tar.bz2 |
Merge branch 'v4.0'
Diffstat (limited to 'src/DotNetOpenAuth.Core/Util.cs')
-rw-r--r-- | src/DotNetOpenAuth.Core/Util.cs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.Core/Util.cs b/src/DotNetOpenAuth.Core/Util.cs index 5a1a5d0..e9d617a 100644 --- a/src/DotNetOpenAuth.Core/Util.cs +++ b/src/DotNetOpenAuth.Core/Util.cs @@ -36,10 +36,12 @@ namespace DotNetOpenAuth { /// Gets a human-readable description of the library name and version, including /// whether the build is an official or private one. /// </summary> - public static string LibraryVersion { + internal static string LibraryVersion { get { - string assemblyFullName = Assembly.GetExecutingAssembly().FullName; + var assembly = Assembly.GetExecutingAssembly(); + string assemblyFullName = assembly.FullName; bool official = assemblyFullName.Contains("PublicKeyToken=2780ccd10d57b246"); + assemblyFullName = assemblyFullName.Replace(assembly.GetName().Version.ToString(), AssemblyFileVersion); // We use InvariantCulture since this is used for logging. return string.Format(CultureInfo.InvariantCulture, "{0} ({1})", assemblyFullName, official ? "official" : "private"); @@ -47,6 +49,22 @@ namespace DotNetOpenAuth { } /// <summary> + /// Gets the assembly file version of the executing assembly, otherwise falls back to the assembly version. + /// </summary> + internal static string AssemblyFileVersion { + get { + var assembly = Assembly.GetExecutingAssembly(); + var attributes = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false); + if (attributes.Length == 1) { + var fileVersionAttribute = (AssemblyFileVersionAttribute)attributes[0]; + return fileVersionAttribute.Version; + } + + return assembly.GetName().Version.ToString(); + } + } + + /// <summary> /// Tests for equality between two objects. Safely handles the case where one or both are null. /// </summary> /// <typeparam name="T">The type of objects been checked for equality.</typeparam> |