zoukankan      html  css  js  c++  java
  • C#反射之获取程序集信息

    先贴代码,再写文字……

    代码
    1 using System;
    2  using System.Reflection;
    3
    4  namespace Dxy.ReflectionTest
    5 {
    6 public class AssemblyInfoHelper
    7 {
    8 Type m_Type;
    9 public AssemblyInfoHelper(Type type)
    10 {
    11 this.m_Type = type;
    12 Assembly assembly = Assembly.GetAssembly(type);
    13 VersionInfo = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0] as AssemblyFileVersionAttribute;
    14 CompanyInfo = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0] as AssemblyCompanyAttribute;
    15 ProductInfo = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0] as AssemblyProductAttribute;
    16 TitleInfo = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute;
    17 CopyrightInfo = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute;
    18 DescriptionInfo = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute;
    19 }
    20 /// <summary>
    21 /// 版本信息
    22 /// </summary>
    23 public AssemblyFileVersionAttribute VersionInfo
    24 {
    25 get;
    26 private set;
    27 }
    28 /// <summary>
    29 /// 公司信息
    30 /// </summary>
    31 public AssemblyCompanyAttribute CompanyInfo
    32 {
    33 get;
    34 private set;
    35 }
    36 /// <summary>
    37 /// 产品信息
    38 /// </summary>
    39 public AssemblyProductAttribute ProductInfo
    40 {
    41 get;
    42 private set;
    43 }
    44 /// <summary>
    45 /// 标题信息
    46 /// </summary>
    47 public AssemblyTitleAttribute TitleInfo
    48 {
    49 get;
    50 private set;
    51 }
    52 /// <summary>
    53 /// 版权信息
    54 /// </summary>
    55 public AssemblyCopyrightAttribute CopyrightInfo
    56 {
    57 get;
    58 private set;
    59 }
    60 /// <summary>
    61 /// 描述信息
    62 /// </summary>
    63 public AssemblyDescriptionAttribute DescriptionInfo
    64 {
    65 get;
    66 private set;
    67 }
    68
    69 }
    70 }
    71
    懒惰,是一个通病。 努力,必会成为一种习惯。
  • 相关阅读:
    NFC性价比高频读卡器首选方案:FM17550
    关于ESP8266和ESP8285的对比
    有没有比NRF51822更好的智能穿戴蓝牙方案
    zigbee CC2530首选方案模组:TZU06A1
    PAN3501兼容AS3933-BTST
    NRF51822和NRF52832的主要区别
    集成模拟温度传感器低成本2.4G CC2500RGPR 中文手册
    USB2.0主机控制器 UPD720114 简单详解
    存储器HK1225-7EQ 使用说明书资料
    爬虫 + 数据
  • 原文地址:https://www.cnblogs.com/encoding/p/1823444.html
Copyright © 2011-2022 走看看