c# 如何读取程序集中的描述、公司名称、版权等信息

c# 如何读取程序集中的描述、公司名称、版权等信息,第1张

using System;

using SystemCollectionsGeneric;

using SystemComponentModel;

using SystemData;

using SystemDrawing;

using SystemLinq;

using SystemText;

using SystemWindowsForms;

using SystemReflection;

namespace WindowsFormsApplication11

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

Assembly asm = AssemblyGetExecutingAssembly();//如果是当前程序

//如果是其他文件

//string filename = ApplicationStartupPath + "\\xxxexe";

//Assembly asm = AssemblyLoadFile(filename);

AssemblyDescriptionAttribute asmdis = (AssemblyDescriptionAttribute)AttributeGetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute));

AssemblyCopyrightAttribute asmcpr = (AssemblyCopyrightAttribute)AttributeGetCustomAttribute(asm, typeof(AssemblyCopyrightAttribute));

AssemblyCompanyAttribute asmcpn = (AssemblyCompanyAttribute)AttributeGetCustomAttribute(asm, typeof(AssemblyCompanyAttribute));

string s = stringFormat("{0} {1} {2} ", asmdisDescription, asmcprCopyright, asmcpnCompany);

MessageBoxShow(s);

}

}

}

首先通过wxgetNFCAdapter()来获取nfc实例

然后调用startDiscovery获取当前手机nfc状态

已经打开了nfc的就可以调用监听方法onDiscovered

监听到数据后setData把数据展示出来就ok了,方法如下

button2_click里面的代码写错了

MessageBoxShow(stringFormat("读取的数据为{0}", textBox1Text));

这边提个建议 “退出_Click” “保存_Click_1” 尽量不要带上中文

import javautilHashSet;

import javautilSet;

import javautilregexMatcher;

import javautilregexPattern;

/

从字符串中截取出电话号码

@author zcr

/

public class CheckIfIsPhoneNumber

{

/

获得电话号码的正则表达式:包括固定电话和移动电话

符合规则的号码:

1》、移动电话

86+‘-’+11位电话号码

86+11位正常的电话号码

11位正常电话号码a

(+86) + 11位电话号码

(86) + 11位电话号码

2》、固定电话

区号 + ‘-’ + 固定电话 + ‘-’ + 分机号

区号 + ‘-’ + 固定电话

区号 + 固定电话

@return 电话号码的正则表达式

/

public static String isPhoneRegexp()

{

String regexp = "";

//能满足最长匹配,但无法完成国家区域号和电话号码之间有空格的情况

String mobilePhoneRegexp = "(:(\\(\\+86\\))((13[0-9]{1})|(15[0-9]{1})|(18[0,5-9]{1}))+\\d{8})|" +

"(:86-((13[0-9]{1})|(15[0-9]{1})|(18[0,5-9]{1}))+\\d{8})|" +

"(:((13[0-9]{1})|(15[0-9]{1})|(18[0,5-9]{1}))+\\d{8})";

// Systemoutprintln("regexp = " + mobilePhoneRegexp);

//固定电话正则表达式

String landlinePhoneRegexp = "(:(\\(\\+86\\))(0[0-9]{2,3}\\-)([2-9][0-9]{6,7})+(\\-[0-9]{1,4}))|" +

"(:(86-)(0[0-9]{2,3}\\-)([2-9][0-9]{6,7})+(\\-[0-9]{1,4}))";

regexp += "(:" + mobilePhoneRegexp + "|" + landlinePhoneRegexp +")";

return regexp;

}

/

从dataStr中获取出所有的电话号码(固话和移动电话),将其放入Set

@param dataStr 待查找的字符串

@param phoneSet dataStr中的电话号码

/

public static void getPhoneNumFromStrIntoSet(String dataStr,Set<String> phoneSet)

{

//获得固定电话和移动电话的正则表达式

String regexp = isPhoneRegexp();

Systemoutprintln("Regexp = " + regexp);

Pattern pattern = Patterncompile(regexp);

Matcher matcher = patternmatcher(dataStr);

//找与该模式匹配的输入序列的下一个子序列

while (matcherfind())

{

//获取到之前查找到的字符串,并将其添加入set中

phoneSetadd(matchergroup());

}

//Systemoutprintln(phoneSet);

}

}

  #region 程序集特性访问器

        public string AssemblyTitle

        {

            get

            {

                object[] attributes = AssemblyGetExecutingAssembly()GetCustomAttributes(typeof(AssemblyTitleAttribute), false);

                if (attributesLength > 0)

                {

                    AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];

                    if (titleAttributeTitle != "")

                    {

                        return titleAttributeTitle;

                    }

                }

                return SystemIOPathGetFileNameWithoutExtension(AssemblyGetExecutingAssembly()CodeBase);

            }

        }

        public string AssemblyVersion

        {

            get

            {

                return AssemblyGetExecutingAssembly()GetName()VersionToString();

            }

        }

        public string AssemblyDescription

        {

            get

            {

                object[] attributes = AssemblyGetExecutingAssembly()GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);

                if (attributesLength == 0)

                {

                    return "";

                }

                return ((AssemblyDescriptionAttribute)attributes[0])Description;

            }

        }

        public string AssemblyProduct

        {

            get

            {

                object[] attributes = AssemblyGetExecutingAssembly()GetCustomAttributes(typeof(AssemblyProductAttribute), false);

                if (attributesLength == 0)

                {

                    return "";

                }

                return ((AssemblyProductAttribute)attributes[0])Product;

            }

        }

        public string AssemblyCopyright

        {

            get

            {

                object[] attributes = AssemblyGetExecutingAssembly()GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);

                if (attributesLength == 0)

                {

                    return "";

                }

                return ((AssemblyCopyrightAttribute)attributes[0])Copyright;

            }

        }

        public string AssemblyCompany

        {

            get

            {

                object[] attributes = AssemblyGetExecutingAssembly()GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);

                if (attributesLength == 0)

                {

                    return "";

                }

                return ((AssemblyCompanyAttribute)attributes[0])Company;

            }

        }

        #endregion

以上就是关于c# 如何读取程序集中的描述、公司名称、版权等信息全部的内容,包括:c# 如何读取程序集中的描述、公司名称、版权等信息、微信小程序读取nfc门卡信息、C#窗体编写简单的窗体程序实现简单的信息保存和读取等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/10105171.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存