Using system; using system. collections. generic; using system. text; using system. reflection; namespace utils {// <summary> /// <para> </para> // common tool class -- Application Property Information category class // <para> ------------------------------------------------- </para >/// <para> getassemblytitle: get the application Assembly title </para> /// <para> getassemblyproduct: Get the application product name </para> /// <para> getassemblyversion: get application version </para> // <para> getassemblydescription: Get Application Program description </para> /// <para> getassemblycopyright: Obtain the copyright information of the application </para> /// <para> getassemblycompany: get the application company name </para> // <para> getassemblyappfullname: obtain the application display name </para> /// </Summary> public class assemblyhelper {# region obtain the application Assembly title /// <summary> // obtain the application assembly's title /// </Summary> /// <returns> </returns> Public static string getassemblytitle () {object [] attributes = assembly. getexecutingassembly (). getcustoma Ttributes (typeof (assemblytitleattribute), false); If (attributes. length> 0) {assemblytitleattribute titleattribute = (assemblytitleattribute) attributes [0]; If (titleattribute. title! = "") {Return titleattribute. title ;}} return system. io. path. getfilenamewithoutextension (assembly. getexecutingassembly (). codebase );} # endregion # region obtain the application product name /// <summary> /// obtain the application product name /// </Summary> /// <returns> </returns> public static string getassemblyproduct () {object [] attributes = assembly. getexecutingassembly (). getcustomattributes (typeof (assemblyproductattribute), false); If (attributes. length = 0) {return "";} return (assemblyproductattribute) attributes [0]). product ;} # endregion # region obtain the application version /// <summary> /// obtain the application version /// </Summary> /// <returns> </returns> Public static string getassemblyversion () {return assembly. getexecutingassembly (). getname (). version. tostring ();} # endregion # region get application description /// <summary> // get application description /// </Summary> /// <returns> </returns> Public static string getassemblydescription () {object [] attributes = assembly. getexecutingassembly (). getcustomattributes (typeof (assemblydescriptionattribute), false); If (attributes. length = 0) {return "";} return (assemblydescriptionattribute) attributes [0]). description ;} # endregion # region obtain the application's copyright information /// <summary> // obtain the application's copyright information /// </Summary> /// <returns> </returns> public static string getassemblycopyright () {object [] attributes = assembly. getexecutingassembly (). getcustomattributes (typeof (assemblycopyrightattribute), false); If (attributes. length = 0) {return "";} return (assemblycopyrightattribute) attributes [0]). copyright ;} # endregion # region get the application company name /// <summary> // get the application company name /// </Summary> /// <returns> </returns> public static string getassemblycompany () {object [] attributes = assembly. getexecutingassembly (). getcustomattributes (typeof (assemblycompanyattribute), false); If (attributes. length = 0) {return "";} return (assemblycompanyattribute) attributes [0]). company ;} # endregion # region obtain the application display name /// <summary> /// obtain the application display name /// </Summary> /// <returns> </returns> public static string getassemblyappfullname () {return assembly. getexecutingassembly (). fullname. tostring () ;}# endregion }}
Common Tools-application Property Information category