//****************************************************************************************************** // AssemblyExtensions.cs - Gbtc // // Copyright © 2012, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://www.opensource.org/licenses/eclipse-1.0.php // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 09/12/2008 - J. Ritchie Carroll // Generated original version of source code. // 08/07/2009 - Josh L. Patterson // Edited Comments. // 09/14/2009 - Stephen C. Wills // Added new header and license agreement. // 09/28/2010 - Pinal C. Patel // Removed Debuggable extension method since its value source is no longer present in AssemblyInfo. // 12/14/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** using System; using System.Collections.Specialized; using System.IO; using System.Reflection; namespace GSF.Reflection { /// Defines extension functions related to Assemblies. public static class AssemblyExtensions { /// Returns only assembly name and version from full assembly name. /// An to get the short name of. /// The assembly name and version from the full assembly name. public static string ShortName(this Assembly assemblyInstance) { return assemblyInstance.FullName.Split(',')[0]; } /// Gets the specified embedded resource from the assembly. /// Source assembly. /// The full name (including the namespace) of the embedded resource to get. /// The embedded resource. public static Stream GetEmbeddedResource(this Assembly assemblyInstance, string resourceName) { //Extracts and returns the requested embedded resource. return assemblyInstance.GetManifestResourceStream(resourceName); } /// Gets the title information of the assembly. /// Source assembly. /// The title information of the assembly. public static string Title(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).Title; } /// Gets the description information of the assembly. /// Source assembly. /// The description information of the assembly. public static string Description(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).Description; } /// Gets the company name information of the assembly. /// Source assembly. /// The company name information of the assembly. public static string Company(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).Company; } /// Gets the product name information of the assembly. /// Source assembly. /// The product name information of the assembly. public static string Product(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).Product; } /// Gets the copyright information of the assembly. /// Source assembly. /// The copyright information of the assembly. public static string Copyright(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).Copyright; } /// Gets the trademark information of the assembly. /// Source assembly. /// The trademark information of the assembly. public static string Trademark(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).Trademark; } /// Gets the configuration information of the assembly. /// Source assembly. /// The configuration information of the assembly. public static string Configuration(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).Configuration; } /// Gets a boolean value indicating if the assembly has been built as delay-signed. /// Source assembly. /// True, if the assembly has been built as delay-signed; otherwise, False. public static bool DelaySign(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).DelaySign; } /// Gets the version information of the assembly. /// Source assembly. /// The version information of the assembly public static string InformationalVersion(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).InformationalVersion; } /// Gets the name of the file containing the key pair used to generate a strong name for the attributed assembly. /// Source assembly. /// A string containing the name of the file that contains the key pair. public static string KeyFile(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).KeyFile; } /// Gets the culture name of the assembly. /// Source assembly. /// The culture name of the assembly. public static string CultureName(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).CultureName; } /// Gets the assembly version used to instruct the System.Resources.ResourceManager to ask for a particular /// version of a satellite assembly to simplify updates of the main assembly of an application. /// Source assembly. /// The satellite contract version of the assembly. public static string SatelliteContractVersion(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).SatelliteContractVersion; } /// Gets the string representing the assembly version used to indicate to a COM client that all classes /// in the current version of the assembly are compatible with classes in an earlier version of the assembly. /// Source assembly. /// The string representing the assembly version in MajorVersion.MinorVersion.RevisionNumber.BuildNumber /// format. public static string ComCompatibleVersion(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).ComCompatibleVersion; } /// Gets a boolean value indicating if the assembly is exposed to COM. /// Source assembly. /// True, if the assembly is exposed to COM; otherwise, False. public static bool ComVisible(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).ComVisible; } /// Gets the assembly GUID that is used as an ID if the assembly is exposed to COM. /// Source assembly. /// The assembly GUID that is used as an ID if the assembly is exposed to COM. public static string Guid(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).Guid; } /// Gets the string representing the assembly version number in MajorVersion.MinorVersion format. /// Source assembly. /// The string representing the assembly version number in MajorVersion.MinorVersion format. public static string TypeLibVersion(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).TypeLibVersion; } /// Gets a boolean value indicating whether the indicated program element is CLS-compliant. /// Source assembly. /// True, if the program element is CLS-compliant; otherwise, False. public static bool CLSCompliant(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).CLSCompliant; } /// Gets the date and time when the assembly was last built. /// Source assembly. /// The date and time when the assembly was last built. public static DateTime BuildDate(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).BuildDate; } /// Gets the root namespace of the assembly. /// Source assembly. /// The root namespace of the assembly. public static string RootNamespace(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).RootNamespace; } /// Gets a name/value collection of assembly attributes exposed by the assembly. /// Source assembly. /// A NameValueCollection of assembly attributes. public static NameValueCollection GetAttributes(this Assembly assemblyInstance) { return (new AssemblyInfo(assemblyInstance)).GetAttributes(); } } }