|
#region Copyright notice
// ==================================================================================================
// This is an as-is implementation. feel free to use this code anyway you like :)
//
// - Moim Hossain
// 2006
// ==================================================================================================
#endregion
#region Using Directives
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
#endregion
namespace GACExplorer
{
/// <summary>
/// Encapsulates an assembly informations inside this class
/// </summary>
public class AssemblyInformation
{
string name;
string version;
string culture;
string publicKeyToken;
FileInfo fInfo;
/// <summary>
/// Creates a new instance
/// </summary>
/// <param name="fInfo"></param>
public AssemblyInformation(FileInfo fInfo)
{
this.fInfo = fInfo;
UpdateInformation();
}
/// <summary>
/// Get or set the name
/// </summary>
public string Name
{
get { return name; }
set { name = value; }
}
/// <summary>
/// Get or set the version
/// </summary>
public string Version
{
get { return version; }
set { version = value; }
}
/// <summary>
/// Get or set the culture
/// </summary>
public string Culture
{
get { return culture; }
set { culture = value; }
}
/// <summary>
/// Get or set the
/// </summary>
public string PublicKeyToken
{
get { return publicKeyToken; }
set { publicKeyToken = value; }
}
/// <summary>
/// Get the full name
/// </summary>
public string FullName
{
get { return string.Format("{0}, Version={1}, Culture=natural, PublicKeyToken={2}", name, version, publicKeyToken); }
}
/// <summary>
/// Get the file informations
/// </summary>
public FileInfo FileInformation
{
get { return fInfo; }
}
/// <summary>
/// Update the informations
/// </summary>
private void UpdateInformation()
{
string name = fInfo.Name.Substring(0, fInfo.Name.LastIndexOf("."));
string version = string.Empty;
string publicKeyToken = string.Empty;
try
{
string directory = fInfo.DirectoryName.Substring(fInfo.DirectoryName.LastIndexOf("\\") + 1);
version = directory.Substring(0, directory.IndexOf("__"));
publicKeyToken = directory.Substring(directory.IndexOf("__") + 2);
}
catch (Exception)
{
}
this.name = name;
this.version = version;
this.publicKeyToken = publicKeyToken;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.