From 9c6d9157b606f7aba8605c4ac34d49c557487e98 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Wed, 27 Aug 2014 09:56:59 -0400 Subject: Add assm ver --- crypto/src/AssemblyInfo.cs | 26 ++++++++++++++++++++++++++ crypto/src/bcpg/ArmoredOutputStream.cs | 4 +--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crypto/src/AssemblyInfo.cs b/crypto/src/AssemblyInfo.cs index 374e590cc..7a0f3c0fc 100644 --- a/crypto/src/AssemblyInfo.cs +++ b/crypto/src/AssemblyInfo.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -75,3 +76,28 @@ using System.Runtime.InteropServices; // see Org.BouncyCastle.Crypto.Encodings.Pkcs1Encoding.StrictLengthEnabledProperty //[assembly: EnvironmentPermission(SecurityAction.RequestOptional, Read="Org.BouncyCastle.Pkcs1.Strict")] +internal class AssemblyInfo +{ + private static string version; + public static string Version + { + get + { + if (version == null) + { + var ver = (AssemblyVersionAttribute)typeof(AssemblyInfo).Assembly.GetCustomAttributes(typeof(AssemblyVersionAttribute), false).FirstOrDefault(); + if (ver != null) + { + version = ver.Version; + } + + // if we're still here, then don't try again + if (version == null) + version = string.Empty; + } + + return version; + } + + } +} diff --git a/crypto/src/bcpg/ArmoredOutputStream.cs b/crypto/src/bcpg/ArmoredOutputStream.cs index 801e06205..458e74a97 100644 --- a/crypto/src/bcpg/ArmoredOutputStream.cs +++ b/crypto/src/bcpg/ArmoredOutputStream.cs @@ -97,9 +97,7 @@ namespace Org.BouncyCastle.Bcpg private static readonly string footerStart = "-----END PGP "; private static readonly string footerTail = "-----"; - private static readonly string version = "BCPG C# v" - + Assembly.GetExecutingAssembly() - .FullName;//.GetName().Version; + private static readonly string version = "BCPG C# v" + AssemblyInfo.Version; private readonly IDictionary headers; -- cgit 1.4.1