Changeset 2674


Ignore:
Timestamp:
Feb 12, 2011, 5:05:00 PM (11 years ago)
Author:
Matthäus Wander
Message:

Use FileVersion instead of AssemblyVersion

Created helper properties and methods for that purpose:

  • AssemblyHelper.Version
  • AssemblyHelper.GetVersion(Assembly)
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypCore/PluginManager.cs

    r2511 r2674  
    1818using System.Collections;
    1919using System.Collections.Generic;
     20using System.Diagnostics;
    2021using System.Reflection;
    2122using System.IO;
     
    170171                      sendMessage = true;
    171172                    }
    172                     else
    173                       if (new AssemblyName(asm.FullName).Version > new AssemblyName(foundAssemblies[key].FullName).Version)
    174                       {
     173                    else if (GetVersion(asm) > GetVersion(foundAssemblies[key]))
     174                    {
    175175                        foundAssemblies[key] = asm;
    176176                        sendMessage = true;
    177                       }
     177                    }
    178178
    179179                    if (sendMessage)
     
    182182                        if (OnPluginLoaded != null)
    183183                        {
    184                           OnPluginLoaded(this, new PluginLoadedEventArgs(currentPosition, this.availablePluginsApproximation, asm.GetName().Name + " Version=" + asm.GetName().Version.ToString()));
     184                            OnPluginLoaded(this, new PluginLoadedEventArgs(currentPosition, this.availablePluginsApproximation, string.Format("{0} Version={1}", asm.GetName().Name, GetVersion(asm))));
    185185                        }                         
    186186                    }
     
    195195                }
    196196            }
     197        }
     198
     199        private static Version GetVersion(Assembly asm)
     200        {
     201            return new Version(FileVersionInfo.GetVersionInfo(asm.Location).FileVersion);
    197202        }
    198203
  • trunk/CrypPluginBase/Miscellaneous/AssemblyHelper.cs

    r2323 r2674  
    1717using System;
    1818using System.Collections.Generic;
     19using System.Diagnostics;
    1920using System.Linq;
    2021using System.Reflection;
     
    2526{
    2627    /*
    27      * Access assembly information of entry assembly (starting exe).
     28     * Access assembly information of executing assembly (which is CrypPluginBase).
    2829     */
    2930    public class AssemblyHelper
     
    4849            {
    4950                object[] attributes =
    50                     Assembly.GetEntryAssembly().GetCustomAttributes(typeof (AssemblyCt2BuildTypeAttribute), false);
     51                    Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyCt2BuildTypeAttribute), false);
    5152                if (attributes != null && attributes.Length >= 1)
    5253                {
     
    6162            {
    6263                object[] attributes =
    63                     Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
     64                    Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
    6465                if (attributes != null && attributes.Length >= 1)
    6566                {
     
    6970            }
    7071            {
    71                 AssemblyHelper.Version = Assembly.GetEntryAssembly().GetName().Version;
     72                AssemblyHelper.Version = GetVersion(Assembly.GetExecutingAssembly());
    7273            }
     74        }
     75
     76        public static Version GetVersion(Assembly asm)
     77        {
     78            return new Version(GetVersionString(asm));
     79        }
     80
     81        public static string GetVersionString(Assembly asm)
     82        {
     83            if (asm == null || asm.Location == null)
     84            {
     85                throw new ArgumentNullException("asm");
     86            }
     87
     88            return FileVersionInfo.GetVersionInfo(asm.Location).FileVersion;
    7389        }
    7490    }
  • trunk/CrypPluginBase/Properties/AssemblyInfo.cs

    r2668 r2674  
    1818using System.Runtime.CompilerServices;
    1919using System.Runtime.InteropServices;
     20using Cryptool.PluginBase.Attributes;
    2021
    2122[assembly: AssemblyTitle("CrypTool Plugin Base")]
     
    2526[assembly: ComVisible(false)]
    2627[assembly: AssemblyVersion("2.0.0.0")]
     28
     29[assembly: AssemblyCt2BuildType(Ct2BuildType.Developer)]
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/ActivateEmailView.xaml.cs

    r2572 r2674  
    22using System.ComponentModel;
    33using System.IO;
     4using System.Reflection;
    45using System.Windows;
    56using System.Windows.Forms;
     
    78using Cryptool.P2PEditor.Worker;
    89using Cryptool.PluginBase;
     10using Cryptool.PluginBase.Miscellaneous;
    911using PeersAtPlay.CertificateLibrary.Network;
    1012using System.Threading;
     
    101103                }
    102104
    103                 certificateClient.ProgramName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
    104                 certificateClient.ProgramVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
     105                Assembly asm = Assembly.GetEntryAssembly();
     106                certificateClient.ProgramName = asm.GetName().Name;
     107                certificateClient.ProgramVersion = AssemblyHelper.GetVersionString(asm);
    105108
    106109                certificateClient.CertificateAuthorizationRequired += new EventHandler<EventArgs>(delegate
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/ConnectView.xaml.cs

    r2572 r2674  
    11using System;
     2using System.Reflection;
    23using System.Windows;
    34using Cryptool.P2P;
     
    67using System.Threading;
    78using Cryptool.P2P.Internal;
     9using Cryptool.PluginBase.Miscellaneous;
    810using PeersAtPlay.CertificateLibrary.Certificates;
    911using Cryptool.PluginBase;
     
    181183
    182184                    certificateClient.TimeOut = 5;
    183                     certificateClient.ProgramName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
    184                     certificateClient.ProgramVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
     185                    Assembly asm = Assembly.GetEntryAssembly();
     186                    certificateClient.ProgramName = asm.GetName().Name;
     187                    certificateClient.ProgramVersion = AssemblyHelper.GetVersionString(asm);
    185188                    certificateClient.InvalidCertificateRequest += InvalidCertificateRequest;
    186189                    certificateClient.CertificateReceived += CertificateReceived;
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/ForgotPasswordView.xaml.cs

    r2572 r2674  
    22using System.ComponentModel;
    33using System.IO;
     4using System.Reflection;
    45using System.Windows;
    56using System.Windows.Forms;
     
    78using Cryptool.P2PEditor.Worker;
    89using Cryptool.PluginBase;
     10using Cryptool.PluginBase.Miscellaneous;
    911using PeersAtPlay.CertificateLibrary.Network;
    1012using System.Threading;
     
    9294                }
    9395
    94                 certificateClient.ProgramName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
    95                 certificateClient.ProgramVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
     96                Assembly asm = Assembly.GetEntryAssembly();
     97                certificateClient.ProgramName = asm.GetName().Name;
     98                certificateClient.ProgramVersion = AssemblyHelper.GetVersionString(asm);
    9699                certificateClient.InvalidPasswordReset += InvalidPasswordReset;
    97100                certificateClient.PasswordResetVerificationRequired += new EventHandler<EventArgs>(delegate
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/GetNewCertificateView.xaml.cs

    r2572 r2674  
    22using System.ComponentModel;
    33using System.IO;
     4using System.Reflection;
    45using System.Windows;
    56using System.Windows.Forms;
     
    78using Cryptool.P2PEditor.Worker;
    89using Cryptool.PluginBase;
     10using Cryptool.PluginBase.Miscellaneous;
    911using PeersAtPlay.CertificateLibrary.Network;
    1012using System.Threading;
     
    127129                }
    128130
    129                 certificateClient.ProgramName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
    130                 certificateClient.ProgramVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
     131                Assembly asm = Assembly.GetEntryAssembly();
     132                certificateClient.ProgramName = asm.GetName().Name;
     133                certificateClient.ProgramVersion = AssemblyHelper.GetVersionString(asm);
    131134
    132135                certificateClient.CertificateAuthorizationRequired += new EventHandler<EventArgs>(delegate
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/VerifyPasswordResetView.xaml.cs

    r2572 r2674  
    22using System.ComponentModel;
    33using System.IO;
     4using System.Reflection;
    45using System.Windows;
    56using System.Windows.Forms;
     
    78using Cryptool.P2PEditor.Worker;
    89using Cryptool.PluginBase;
     10using Cryptool.PluginBase.Miscellaneous;
    911using PeersAtPlay.CertificateLibrary.Network;
    1012using System.Threading;
     
    122124                }
    123125
    124                 certificateClient.ProgramName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
    125                 certificateClient.ProgramVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
     126                Assembly asm = Assembly.GetEntryAssembly();
     127                certificateClient.ProgramName = asm.GetName().Name;
     128                certificateClient.ProgramVersion = AssemblyHelper.GetVersionString(asm);
    126129
    127130                certificateClient.CertificateAuthorizationRequired += new EventHandler<EventArgs>(delegate
  • trunk/CrypPlugins/Primes/Primes/Options/OptionVersionInfo.xaml.cs

    r4 r2674  
    1313using System.Windows.Shapes;
    1414using System.Reflection;
     15using Cryptool.PluginBase.Miscellaneous;
    1516
    1617namespace Primes.Options
     
    2829    private void UserControl_Loaded(object sender, RoutedEventArgs e)
    2930    {
    30       Version version = Assembly.GetAssembly(this.GetType()).GetName().Version;
     31      Version version = AssemblyHelper.GetVersion(Assembly.GetAssembly(this.GetType()));
    3132      string strVersion = String.Format("{0}.{1}.{2}", new Object[] { version.Major-1, version.Minor,version.Revision});
    3233      tbVersionInfo.Text = strVersion;
Note: See TracChangeset for help on using the changeset viewer.