using System.Reflection; public sealed class AssemblyInfo { #region Ctors static AssemblyInfo() { } private AssemblyInfo() { PortableExecutableKinds peKind; ImageFileMachine machine; Assembly.GetCallingAssembly().ManifestModule.GetPEKind(out peKind, out machine); this.Kind = peKind; this.Machine = machine; } #endregion #region Public Methods public bool Is(PortableExecutableKinds kind) { return ((this.Kind & kind) != 0); } public bool Is(ImageFileMachine machine) { return ((this.Machine & machine) != 0); } #endregion #region Properties public static AssemblyInfo Instance { get { return (AssemblyInfo._instance); } } public PortableExecutableKinds Kind { get; private set; } public ImageFileMachine Machine { get; private set; } #endregion #region Fields private static readonly AssemblyInfo _instance = new AssemblyInfo(); #endregion }Exemple d'utilisation:
if (AssemblyInfo.Instance.Is(PortableExecutableKinds.Required32Bit)) { }