FileAssembly Accessor..

Oct 19, 2011 at 4:07 PM

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace AppLimit.NetSparkle
{
    public class NetSparkleFileAccessor
    {
        private string fileVersion;
        private string productVersion;
        private string productName;
        private string companyName;
        private string legalCopyright;
        private string fileDescription;

        public NetSparkleFileAccessor(String assemblyName)
        {
            if (assemblyName != null)
            {
                fileVersion = FileVersionInfo.GetVersionInfo(assemblyName).FileVersion;
                productVersion = FileVersionInfo.GetVersionInfo(assemblyName).ProductVersion;
                productName = FileVersionInfo.GetVersionInfo(assemblyName).ProductName;
                companyName = FileVersionInfo.GetVersionInfo(assemblyName).CompanyName;
                legalCopyright = FileVersionInfo.GetVersionInfo(assemblyName).LegalCopyright;
                fileDescription = FileVersionInfo.GetVersionInfo(assemblyName).FileDescription; 
            }
        }

        #region Assembly Attribute Accessors

        public string AssemblyTitle
        {
            get
            {
                return productName;                
            }
        }

        public string AssemblyVersion
        {
            get
            {
                return fileVersion;
            }
        }        

        public string AssemblyDescription
        {
            get { return fileDescription; }
        }

        public string AssemblyProduct
        {
            get
            {
                return productVersion;                                
            }
        }

        public string AssemblyCopyright
        {
            get { return legalCopyright; }
        }

        public string AssemblyCompany
        {
            get
            {
                return companyName;                  
            }
        }
        #endregion
    }
}

I added this because in some cases you don't want to perform a reflection load of the assembly because it will fail to load dependent assemblies..
This just uses the System.Diagnostics namespace to pull info from the file..
Oct 29, 2011 at 12:15 PM
Hi,

thanks, I added your stuff as option to the code with the following check in:


Dirk


2011/10/19 Zapbbx <notifications@codeplex.com>

From: Zapbbx


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace AppLimit.NetSparkle
{
    public class NetSparkleFileAccessor
    {
        private string fileVersion;
        private string productVersion;
        private string productName;
        private string companyName;
        private string legalCopyright;
        private string fileDescription;

        public NetSparkleFileAccessor(String assemblyName)
        {
            if (assemblyName != null)
            {
                fileVersion = FileVersionInfo.GetVersionInfo(assemblyName).FileVersion;
                productVersion = FileVersionInfo.GetVersionInfo(assemblyName).ProductVersion;
                productName = FileVersionInfo.GetVersionInfo(assemblyName).ProductName;
                companyName = FileVersionInfo.GetVersionInfo(assemblyName).CompanyName;
                legalCopyright = FileVersionInfo.GetVersionInfo(assemblyName).LegalCopyright;
                fileDescription = FileVersionInfo.GetVersionInfo(assemblyName).FileDescription; 
            }
        }

        #region Assembly Attribute Accessors

        public string AssemblyTitle
        {
            get
            {
                return productName;                
            }
        }

        public string AssemblyVersion
        {
            get
            {
                return fileVersion;
            }
        }        

        public string AssemblyDescription
        {
            get { return fileDescription; }
        }

        public string AssemblyProduct
        {
            get
            {
                return productVersion;                                
            }
        }

        public string AssemblyCopyright
        {
            get { return legalCopyright; }
        }

        public string AssemblyCompany
        {
            get
            {
                return companyName;                  
            }
        }
        #endregion
    }
}

I added this because in some cases you don't want to perform a reflection load of the assembly because it will fail to load dependent assemblies..
This just uses the System.Diagnostics namespace to pull info from the file..

Read the full discussion online.

To add a post to this discussion, reply to this email (netsparkle@discussions.codeplex.com)

To start a new discussion for this project, email netsparkle@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com