用c#编写一个vb 工程源码分析工具(带源码工程下载)

简介:

    最近加入一个公司,试用期间要我学习他们的旧系统,旧系统的代码是Visual Basic 6.0编写的,源码大概有10多万行,要一下子看完可不容易,并且还得出一个源码分析的文档。而最近的项目是新版本的开发,采用.Net的Visual C#开发,所以我边学c#边看代码;一是为了解决文档编写的问题,二是为了学习c#,就编写了一套专门分析vb Project的工具,其原理就是根据vb的工程文件解析所有的“ 变量、常量、API、过程、函数、事件”还有它们的类型“私有、全局”;由于时间关系, 准备实现的“事件调用”分析并没有完成,但最后我的文档还是出来了。其中就有它的功劳。
软件的原型是参照 Aivosto 公司的" Aivosto Project Analyzer"制作的,它的功能很强大,只是它需要 ¥¥才能使用全部功能,否则只能导出txt文件, 谁能有破解发我一份吧 :)
代码其实并不复杂,因为vb的语法很简单,都是行模式,虽然支持 & _ 连接符号,但是处理起来只需要替换掉即可。
以下是核心的算法(也算不上什么算法,只是我的分析模式
dd
ExpandedBlockStart.gif ContractedBlock.gif /**/ /******************************************
InBlock.gif * 返回文本内容
ExpandedBlockEnd.gif *****************************************
*/

None.gif private string loadForm( string fileName)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.gifif (fileName != "")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giftry
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif System.IO.StreamReader sr = new System.IO.StreamReader(fileName,System.Text.Encoding.Default);
InBlock.gifreturn sr.ReadToEnd();
ExpandedSubBlockEnd.gif }

InBlock.gifcatch
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn null;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn null;
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif }

None.gif
ContractedBlock.gif ExpandedBlockStart.gif 分析窗体组件 #region 分析窗体组件
ExpandedSubBlockStart.gifContractedSubBlock.gif/**//******************************************
InBlock.gif * 处理组件数据并增加结果到listview
ExpandedSubBlockEnd.gif ****************************************
*/

InBlock.gifprivate void parseControls(
InBlock.gif System.Windows.Forms.ListView lv,
InBlock.gifstring fileName,string s)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(s==null)return;
InBlock.gifstring[] strLines = s.Split (Environment.NewLine.ToCharArray()); //获取分隔符号
InBlock.gif
for(int i=0;i<strLines.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(strLines[i].Trim()!=""&&strLines[i].Trim().Length>=6)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring strScalars = strLines[i].Trim();
InBlock.gifif(strScalars.Substring(0,"Begin ".Length).ToUpper()=="Begin ".ToUpper())
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//取得组件名称
InBlock.gif
string[] strSubList = strScalars.Split(" ".ToCharArray());
InBlock.gifstring strCtrlClass = strSubList[1];
InBlock.gifstring strCtrlName = strSubList[2];
InBlock.gifif(fileName.LastIndexOf("\\")!=-1)
InBlock.gif strSubList[0] = fileName.Substring(fileName.LastIndexOf("\\")+1);
InBlock.gifelse strSubList[0] = fileName;
InBlock.gif
InBlock.gif ListViewItem lvi = new ListViewItem(strSubList,-1);
InBlock.gif lv.Items.Add(lvi);
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif/**//**************************************
InBlock.gif * 主循环处理内容
ExpandedSubBlockEnd.gif ************************************
*/

InBlock.gifprivate void callMain(
InBlock.gif System.Windows.Forms.ListView lv,
InBlock.gifstring[] listFiles)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif lv.Items.Clear();
InBlock.giffor (int i=0;i<listFiles.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif parseControls(lv,listFiles[i],loadForm(listFiles[i]));
ExpandedSubBlockEnd.gif }

InBlock.gif MessageBox.Show("分析完毕!");
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif#endregion

None.gif
None.gif private void button1_Click( object sender, System.EventArgs e)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.gif callMain(listView1,textBox1.Lines);
ExpandedBlockEnd.gif }

None.gif
None.gif private void Form1_Resize( object sender, System.EventArgs e)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.giftry
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif listView1.Height= textBox1.Top - listView1.Top;
ExpandedSubBlockEnd.gif }

InBlock.gifcatch
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif }

None.gif
ExpandedBlockStart.gif ContractedBlock.gif /**/ /********************************
InBlock.gif * 通用函数,返回按分隔符、位的单词
ExpandedBlockEnd.gif ******************************
*/

None.gif private string CharIndex( string sSrc, string SplitChar, int CharIndex)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.gifstring[] tmpArray = sSrc.Split(SplitChar.ToCharArray());
InBlock.gifreturn tmpArray[CharIndex];
ExpandedBlockEnd.gif }

ExpandedBlockStart.gif ContractedBlock.gif /**/ /********************************
InBlock.gif * 通用保存ListView到文件得过程
ExpandedBlockEnd.gif ******************************
*/

None.gif private void mSaveLvToFile_Click( object sender, System.EventArgs e)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.gif
InBlock.gifif(mSaveLvToFile.GetContextMenu().SourceControl is ListView)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif
InBlock.gif saveFileDlg.ShowDialog(this);
InBlock.gifif(saveFileDlg.FileName!="")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring sTextFile = "";
InBlock.gif ListView lv=(ListView)mSaveLvToFile.GetContextMenu().SourceControl;
InBlock.giffor(int i=0;i<lv.Items.Count;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring sLine = "";
InBlock.giffor(int j=0;j<lv.Items[i].SubItems.Count;j++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(j!=(lv.Items[i].SubItems.Count-1))
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sLine += lv.Items[i].SubItems[j].Text + ",";
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sLine += lv.Items[i].SubItems[j].Text + "\r\n";
ExpandedSubBlockEnd.gif }

InBlock.gif
ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifif(sTextFile.IndexOf(sLine)==-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sTextFile += sLine;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.giftry
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif System.IO.StreamWriter sw = new System.IO.StreamWriter(saveFileDlg.FileName,false,System.Text.Encoding.Default);
InBlock.gif sw.Write(sTextFile);
InBlock.gif sw.Close();
InBlock.gif MessageBox.Show("保存文件完成!");
ExpandedSubBlockEnd.gif }

InBlock.gifcatch
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif MessageBox.Show("保存文件错误!");
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif }

None.gif
None.gif private void btnParseVar_Click( object sender, System.EventArgs e)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.gif callMain2(
InBlock.gif listViewConst,
InBlock.gif listViewType,
InBlock.gif listViewAPI,
InBlock.gif listViewPubvar,
InBlock.gif listViewPrivar,
InBlock.gif textBox2.Lines
InBlock.gif );
ExpandedBlockEnd.gif }

None.gif
ContractedBlock.gif ExpandedBlockStart.gif 分析变量,声明等类型 #region 分析变量,声明等类型
ExpandedSubBlockStart.gifContractedSubBlock.gif/**//**************************************
InBlock.gif * 主循环处理内容2
ExpandedSubBlockEnd.gif ************************************
*/

InBlock.gifprivate void callMain2(
InBlock.gif System.Windows.Forms.ListView lv1,
InBlock.gif System.Windows.Forms.ListView lv2,
InBlock.gif System.Windows.Forms.ListView lv3,
InBlock.gif System.Windows.Forms.ListView lv4,
InBlock.gif System.Windows.Forms.ListView lv5,
InBlock.gifstring[] listFiles)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif lv1.Items.Clear();
InBlock.gif lv1.Items.Add("常量定义");
InBlock.gif lv2.Items.Clear();
InBlock.gif lv2.Items.Add("类型声明");
InBlock.gif lv3.Items.Clear();
InBlock.gif lv3.Items.Add("API 声明");
InBlock.gif lv4.Items.Clear();
InBlock.gif lv4.Items.Add("全局变量");
InBlock.gif lv5.Items.Clear();
InBlock.gif lv5.Items.Add("私有变量");
InBlock.giffor (int i=0;i<listFiles.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif parseVar(lv1,lv2,lv3,lv4,lv5,listFiles[i],loadForm(listFiles[i]));
ExpandedSubBlockEnd.gif }

InBlock.gif MessageBox.Show("分析完毕!");
ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//******************************************
InBlock.gif * 处理变量结果并增加结果到listview
ExpandedSubBlockEnd.gif ****************************************
*/

InBlock.gifprivate void parseVar(
InBlock.gif System.Windows.Forms.ListView lv1,
InBlock.gif System.Windows.Forms.ListView lv2,
InBlock.gif System.Windows.Forms.ListView lv3,
InBlock.gif System.Windows.Forms.ListView lv4,
InBlock.gif System.Windows.Forms.ListView lv5,
InBlock.gifstring fileName,string s)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//0.寻找常量定义
InBlock.gif
//1.寻找结构定义
InBlock.gif
//2.寻找API声明
InBlock.gif
//3.寻找工程全局变量
InBlock.gif
//4.寻找过程、函数、事件内局部变量
InBlock.gif

InBlock.gifif(s==null)return;
InBlock.gif s = replace2bank(s);
InBlock.gifstring[] strLines = s.Split (Environment.NewLine.ToCharArray()); //获取分隔符号
InBlock.gif
string[] strLines2 = s.Split (Environment.NewLine.ToCharArray()); //获取分隔符号
InBlock.gif
string[] strConstList = parseVarConst(strLines);
InBlock.gif//lv.Items.Add("常量定义");
InBlock.gif
if(strConstList!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int i=0;i<strConstList.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gifif(strConstList[i].Trim()=="")dot.gif{continue;}
InBlock.gifstring[] smaillList = strConstList[i].Split("\r".ToCharArray());
InBlock.gif ListViewItem lvi = new ListViewItem(smaillList,-1);
InBlock.gifif(fileName.LastIndexOf("\\")!=-1)
InBlock.gif lvi.SubItems.Add(fileName.Substring(fileName.LastIndexOf("\\")+1));
InBlock.gifelse lvi.SubItems.Add(fileName);
InBlock.gif lv1.Items.Add(lvi);
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifstring[] strTypeList = parseVarType(strLines);
InBlock.gif//lv.Items.Add("数据类型");
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(strTypeList!=null)dot.gif{
InBlock.giffor(int i=0;i<strTypeList.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gifif(strTypeList[i].Trim()=="")dot.gif{continue;}
InBlock.gifstring[] smaillList = strTypeList[i].Split("\xff".ToCharArray());
InBlock.gif ListViewItem lvi = new ListViewItem(smaillList,-1);
InBlock.gifif(fileName.LastIndexOf("\\")!=-1)
InBlock.gif lvi.SubItems.Add(fileName.Substring(fileName.LastIndexOf("\\")+1));
InBlock.gifelse lvi.SubItems.Add(fileName);
InBlock.gif lv2.Items.Add(lvi);
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifstring[] strAPIList = parseAPI(strLines);
InBlock.gif//lv.Items.Add("API 声明");
InBlock.gif
if(strAPIList!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int i=0;i<strAPIList.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gifif(strAPIList[i].Trim()=="")dot.gif{continue;}
InBlock.gifstring[] smaillList = strAPIList[i].Split("\r".ToCharArray());
InBlock.gif ListViewItem lvi = new ListViewItem(smaillList,-1);
InBlock.gifif(fileName.LastIndexOf("\\")!=-1)
InBlock.gif lvi.SubItems.Add(fileName.Substring(fileName.LastIndexOf("\\")+1));
InBlock.gifelse lvi.SubItems.Add(fileName);
InBlock.gif lv3.Items.Add(lvi);
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifstring[] strPubvarList = parsePublicVar(strLines);
InBlock.gif//lv.Items.Add("全局变量声明");
InBlock.gif
if(strPubvarList!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int i=0;i<strPubvarList.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gifif(strPubvarList[i].Trim()=="")dot.gif{continue;}
InBlock.gifstring[] smaillList = strPubvarList[i].Split("\r".ToCharArray());
InBlock.gif ListViewItem lvi = new ListViewItem(smaillList,-1);
InBlock.gifif(fileName.LastIndexOf("\\")!=-1)
InBlock.gif lvi.SubItems.Add(fileName.Substring(fileName.LastIndexOf("\\")+1));
InBlock.gifelse lvi.SubItems.Add(fileName);
InBlock.gif lv4.Items.Add(lvi);
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifstring[] strPrivarList = parsePrivateVar(strLines2);
InBlock.gif//lv5.Items.Add("私有变量声明");
InBlock.gif
if(strPrivarList!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int i=0;i<strPrivarList.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gifif(strPrivarList[i].Trim()=="")dot.gif{continue;}
InBlock.gifstring[] smaillList = strPrivarList[i].Split("\r".ToCharArray());
InBlock.gif ListViewItem lvi = new ListViewItem(smaillList,-1);
InBlock.gifif(fileName.LastIndexOf("\\")!=-1)
InBlock.gif lvi.SubItems.Add(fileName.Substring(fileName.LastIndexOf("\\")+1));
InBlock.gifelse lvi.SubItems.Add(fileName);
InBlock.gif lv5.Items.Add(lvi);
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif
ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 处理 双空格 字符 处理vb连接符号
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string replace2bank(string s)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif s = s.Trim().Replace("& _\r\n","");
InBlock.gif s = s.Trim().Replace("_\r\n","");
InBlock.gifwhile(s.IndexOf(" ")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif s = s.Replace(" "," ");
ExpandedSubBlockEnd.gif }

InBlock.gifreturn s;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 查找事件、函数、过程内局部变量
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string[] parsePrivateVar(string[] sSrc)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring tmpStr = "";
InBlock.gifstring privateParentName = "";
InBlock.gifint i=0;
InBlock.gifwhile(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//从代码段开始
InBlock.gif
if(sSrc[i].Trim().ToUpper().IndexOf("Attribute ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gif//预处理
InBlock.gif
while(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//访问sub
InBlock.gif
//先寻找关键字,切断关键字后得行,再按逗号分割,检查每位得时候检查当前后段注解字符
InBlock.gif

InBlock.gifif( sSrc[i].Trim().ToUpper().IndexOf("sub ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private sub ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public sub ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif
InBlock.gifif(CharIndex(sSrc[i]," ",0).Trim().ToUpper()=="sub".ToUpper())
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif privateParentName = CharIndex(sSrc[i]," ",1);
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif privateParentName = CharIndex(sSrc[i]," ",2);
ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifif(privateParentName.Trim().ToUpper().IndexOf("(")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif privateParentName = privateParentName.Substring(0,privateParentName.Trim().ToUpper().IndexOf("("));
ExpandedSubBlockEnd.gif }

InBlock.giffor(int n=i;n<sSrc.Length;n++,i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(sSrc[i].Trim().ToUpper().IndexOf("end sub".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

InBlock.gif//如果检查到 变量 定义
InBlock.gif
if( sSrc[i].Trim().ToUpper().IndexOf("Dim ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] keyWord = sSrc[i].Trim().Substring(sSrc[i].Trim().IndexOf(" ")).Split(",".ToCharArray());
InBlock.giffor(int j=0;j<keyWord.Length;j++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring constLine = keyWord[j];
InBlock.gifif(constLine.Trim().ToUpper().IndexOf("AS")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim().Substring(0,constLine.Trim().ToUpper().IndexOf("AS"))+"\r"+constLine.Trim()+"\r局部变量";
ExpandedSubBlockEnd.gif }

InBlock.gifelse if(constLine.Trim().ToUpper().IndexOf("'")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim().Substring(0,constLine.Trim().ToUpper().IndexOf("'"))+"\r"+constLine.Trim()+"\r局部变量";
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim()+"\r"+constLine.Trim()+"\r局部变量";
ExpandedSubBlockEnd.gif }

InBlock.gif tmpStr += " 来自事件/过程["+privateParentName+"]`";
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }
//访问function
InBlock.gif
else if(sSrc[i].Trim().ToUpper().IndexOf("function ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private function ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public function ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(CharIndex(sSrc[i]," ",0).Trim().ToUpper()=="function".ToUpper())
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif privateParentName = CharIndex(sSrc[i]," ",1);
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif privateParentName = CharIndex(sSrc[i]," ",2);
ExpandedSubBlockEnd.gif }

InBlock.gifif(privateParentName.Trim().ToUpper().IndexOf("(")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif privateParentName = privateParentName.Substring(0,privateParentName.Trim().ToUpper().IndexOf("("));
ExpandedSubBlockEnd.gif }

InBlock.giffor(int n=i;n<sSrc.Length;n++,i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(sSrc[i].Trim().ToUpper().IndexOf("end function".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

InBlock.gif//如果检查到 变量 定义
InBlock.gif
if( sSrc[i].Trim().ToUpper().IndexOf("Dim ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] keyWord = sSrc[i].Trim().Substring(sSrc[i].Trim().IndexOf(" ")).Split(",".ToCharArray());
InBlock.giffor(int j=0;j<keyWord.Length;j++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring constLine = keyWord[j];
InBlock.gifif(constLine.Trim().ToUpper().IndexOf("AS")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim().Substring(0,constLine.Trim().ToUpper().IndexOf("AS"))+"\r"+constLine.Trim()+"\r局部变量";
ExpandedSubBlockEnd.gif }

InBlock.gifelse if(constLine.Trim().ToUpper().IndexOf("'")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim().Substring(0,constLine.Trim().ToUpper().IndexOf("'"))+"\r"+constLine.Trim()+"\r局部变量";
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim()+"\r"+constLine.Trim()+"\r局部变量";
ExpandedSubBlockEnd.gif }

InBlock.gif tmpStr += " 来自函数["+privateParentName+"]`";
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }
//去掉所有Const/api
InBlock.gif
else if( sSrc[i].Trim().ToUpper().IndexOf("const ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private const ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public const ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private Declare ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public Declare ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("Declare ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
ExpandedSubBlockEnd.gif
}
//去掉所有Type
InBlock.gif
else if( sSrc[i].Trim().ToUpper().IndexOf("type ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private type ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public type ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int j=i;j<sSrc.Length;j++,i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(sSrc[i].Trim().ToUpper().IndexOf("end type".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
InBlock.gif
break;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
ExpandedSubBlockEnd.gif
}

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifif(tmpStr!="")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] tmpStr2 = tmpStr.PadLeft(tmpStr.Length-1).Split("`".ToCharArray());
InBlock.gifreturn tmpStr2;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn null;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 查找工程全局变量
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string[] parsePublicVar(string[] sSrc)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring tmpStr = "";
InBlock.gifint i=0;
InBlock.gifwhile(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//从代码段开始
InBlock.gif
if(sSrc[i].Trim().ToUpper().IndexOf("Attribute ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gif//预处理
InBlock.gif
while(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//去掉所有sub
InBlock.gif
if( sSrc[i].Trim().ToUpper().IndexOf("sub ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private sub ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public sub ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int j=i;j<sSrc.Length;j++,i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(sSrc[i].Trim().ToUpper().IndexOf("end sub".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
InBlock.gif
break;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
ExpandedSubBlockEnd.gif
}

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }
//去掉所有function
InBlock.gif
else if( sSrc[i].Trim().ToUpper().IndexOf("function ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private function ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public function ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int j=i;j<sSrc.Length;j++,i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(sSrc[i].Trim().ToUpper().IndexOf("end function".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
InBlock.gif
break;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
ExpandedSubBlockEnd.gif
}

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }
//去掉所有Const/api
InBlock.gif
else if( sSrc[i].Trim().ToUpper().IndexOf("const ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private const ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public const ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private Declare ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public Declare ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("Declare ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
ExpandedSubBlockEnd.gif
}
//去掉所有Type
InBlock.gif
else if( sSrc[i].Trim().ToUpper().IndexOf("type ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("private type ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("public type ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int j=i;j<sSrc.Length;j++,i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(sSrc[i].Trim().ToUpper().IndexOf("end type".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
InBlock.gif
break;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif sSrc[i] = ""; //清除掉
ExpandedSubBlockEnd.gif
}

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gif//恢复起始行
InBlock.gif
i=0;
InBlock.gifwhile(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//从代码段开始
InBlock.gif
if(sSrc[i].Trim().ToUpper().IndexOf("Attribute ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gif//先寻找关键字,切断关键字后得行,再按逗号分割,检查每位得时候检查当前后段注解字符
InBlock.gif
//排除定义的事件之间得全局变量
InBlock.gif
while(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//如果检查到 变量 定义
InBlock.gif
if( sSrc[i].Trim().ToUpper().IndexOf("Private ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("Public ".ToUpper())==0||
InBlock.gif sSrc[i].Trim().ToUpper().IndexOf("Dim ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] keyWord = sSrc[i].Trim().Substring(sSrc[i].Trim().IndexOf(" ")).Split(",".ToCharArray());
InBlock.giffor(int j=0;j<keyWord.Length;j++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring constLine = keyWord[j];
InBlock.gifif(constLine.Trim().ToUpper().IndexOf("AS")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim().Substring(0,constLine.Trim().ToUpper().IndexOf("AS"))+"\r"+constLine.Trim()+"\r"+getVarDomain(sSrc[i]).ToString();
ExpandedSubBlockEnd.gif }

InBlock.gifelse if(constLine.Trim().ToUpper().IndexOf("'")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim().Substring(0,constLine.Trim().ToUpper().IndexOf("'"))+"\r"+constLine.Trim()+"\r"+getVarDomain(sSrc[i]).ToString();
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif tmpStr += constLine.Trim()+"\r"+constLine.Trim()+"\r"+getVarDomain(sSrc[i]).ToString();
ExpandedSubBlockEnd.gif }

InBlock.gif tmpStr += "`";
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gifif(tmpStr!="")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] tmpStr2 = tmpStr.PadLeft(tmpStr.Length-1).Split("`".ToCharArray());
InBlock.gifreturn tmpStr2;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn null;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 返回API定义列表
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string[] parseAPI(string[] sSrc)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring tmpStr = "";
InBlock.gifint i=0;
InBlock.gifwhile(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//从代码段开始
InBlock.gif
if(sSrc[i].Trim().ToUpper().IndexOf("Attribute ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifwhile(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//如果检查到 API 定义
InBlock.gif
if(sSrc[i].Trim().ToUpper().IndexOf("Private Declare ".ToUpper())==0||sSrc[i].Trim().ToUpper().IndexOf("Public Declare ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring constLine = sSrc[i];
InBlock.gif tmpStr += getAPIName(constLine).ToString()+"\r"+constLine+"\r"+getVarDomain(constLine).ToString() + "`";
ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gifif(tmpStr!="")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] tmpStr2 = tmpStr.PadLeft(tmpStr.Length-1).Split("`".ToCharArray());
InBlock.gifreturn tmpStr2;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn null;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 返回API名称
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string getAPIName(string srcCodeLine)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] codeList =srcCodeLine.Split(" ".ToCharArray());
InBlock.gifstring result = "";
InBlock.giffor(int i=0; i<codeList.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(codeList[i].Trim().ToUpper()=="Function".ToUpper())
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(i+1<=codeList.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif result = codeList[i+1];
ExpandedSubBlockEnd.gif }

InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gifreturn result;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 返回结构定义列表
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string[] parseVarType(string[] sSrc)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring tmpStr = "";
InBlock.gifint i=0;
InBlock.gifwhile(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//从代码段开始
InBlock.gif
if(sSrc[i].Trim().ToUpper().IndexOf("Attribute ".ToUpper())==0)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gifwhile(i<sSrc.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//如果检查到 Type 定义
InBlock.gif
if(sSrc[i].Trim().ToUpper().IndexOf("TYPE ")==0||sSrc[i].Trim().ToUpper().IndexOf(" TYPE ")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring constLine = sSrc[i];
InBlock.gifstring s = "";
InBlock.giffor(int j=i;j<sSrc.Length;j++,i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif s += sSrc[j] + "\r\n";
InBlock.gifif(sSrc[i].Trim().ToUpper().IndexOf("END TYPE")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifbreak;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif tmpStr += getVarTypeName(constLine).ToString()+"\xff"+s+"\xff"+getVarDomain(constLine).ToString() + "`";
ExpandedSubBlockEnd.gif }

InBlock.gif i++;
ExpandedSubBlockEnd.gif }

InBlock.gifif(tmpStr!="")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] tmpStr2 = tmpStr.PadLeft(tmpStr.Length-1).Split("`".ToCharArray());
InBlock.gifreturn tmpStr2;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn null;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 返回结构名称
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string getVarTypeName(string srcCodeLine)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] codeList =srcCodeLine.Split(" ".ToCharArray());
InBlock.gifif(codeList[0].Trim().ToUpper()=="TYPE")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn codeList[1].Trim();
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn codeList[2].Trim();
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 返回常量定义列表
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string[] parseVarConst(string[] sSrc)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring tmpStr = "";
InBlock.giffor(int i=0;i<sSrc.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif//如果检查到 const 定义
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(sSrc[i].Length>=6)dot.gif{
InBlock.gifif(sSrc[i].Substring(0,"CONST ".Length).ToUpper()=="CONST "||sSrc[i].ToUpper().IndexOf(" CONST ")!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring constLine = sSrc[i];
InBlock.gif tmpStr += getVarName(constLine).ToString()+"\r"+constLine+"\r"+getVarDomain(constLine).ToString() + "`";
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gifif (tmpStr!="")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] tmpStr2 = tmpStr.PadLeft(tmpStr.Length-1).Split("`".ToCharArray());
InBlock.gifreturn tmpStr2;
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn null;
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//*****************************************
InBlock.gif * 返回常量名称
ExpandedSubBlockEnd.gif ***************************************
*/

InBlock.gifprivate string getVarName(string srcCodeLine)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifstring[] codeList =srcCodeLine.Split(" ".ToCharArray());
InBlock.gifif(codeList[0].Trim().ToUpper()=="CONST")
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn codeList[1].Trim();
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn codeList[2].Trim();
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedSubBlockStart.gifContractedSubBlock.gif/**//******************************************
InBlock.gif * 返回定义作用域说明
ExpandedSubBlockEnd.gif ****************************************
*/

InBlock.gifprivate string getVarDomain(string srcCodeLine)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifif(srcCodeLine.Trim().ToUpper().IndexOf("Private".ToUpper())!=-1)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn "局部共享";
ExpandedSubBlockEnd.gif }

InBlock.gifelse
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gifreturn "全局共享";
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif#endregion

None.gif
None.gif private void btnParseProc_Click( object sender, System.EventArgs e)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.gif
ExpandedBlockEnd.gif }

ExpandedBlockStart.gif ContractedBlock.gif /**/ /**************************************
InBlock.gif * 主循环处理内容3
ExpandedBlockEnd.gif ************************************
*/

None.gif private void callMain2(
None.gif System.Windows.Forms.ListView lv1,
None.gif string[] listFiles)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.gif lv1.Items.Clear();
InBlock.gif lv1.Items.Add("事件过程");
InBlock.giffor (int i=0;i<listFiles.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif parseProc(lv1,listFiles[i],loadForm(listFiles[i]));
ExpandedSubBlockEnd.gif }

InBlock.gif MessageBox.Show("分析完毕!");
ExpandedBlockEnd.gif }

ExpandedBlockStart.gif ContractedBlock.gif /**/ /******************************************
InBlock.gif * 处理变量结果并增加结果到listview
ExpandedBlockEnd.gif ****************************************
*/

None.gif private void parseProc(
None.gif System.Windows.Forms.ListView lv1,
None.gif string fileName, string s)
ExpandedBlockStart.gif ContractedBlock.gif dot.gif {
InBlock.gif//1.寻找API声明
InBlock.gif
//2.寻找过程、函数、事件
InBlock.gif

InBlock.gifif(s==null)return;
InBlock.gif s = replace2bank(s);
InBlock.gifstring[] strLines = s.Split (Environment.NewLine.ToCharArray()); //获取分隔符号
InBlock.gif

InBlock.gifstring[] strConstList = parseVarConst(strLines);
InBlock.gif//lv.Items.Add("API声明");
InBlock.gif
if(strConstList!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.giffor(int i=0;i<strConstList.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gifif(strConstList[i].Trim()=="")dot.gif{continue;}
InBlock.gifstring[] smaillList = strConstList[i].Split("\r".ToCharArray());
InBlock.gif ListViewItem lvi = new ListViewItem(smaillList,-1);
InBlock.gifif(fileName.LastIndexOf("\\")!=-1)
InBlock.gif lvi.SubItems.Add(fileName.Substring(fileName.LastIndexOf("\\")+1));
InBlock.gifelse lvi.SubItems.Add(fileName);
InBlock.gif lv1.Items.Add(lvi);
ExpandedSubBlockEnd.gif }

ExpandedSubBlockEnd.gif }

InBlock.gif
ExpandedBlockEnd.gif }


也许你看到这大段的代码,感觉乱七八糟的,那确实;我只是为了满足自己的需要,并且没有封装整理,全在一个Form.cs中,呵呵,所以我带了源码工程;可以下载编译试试看。
也许你用的着。

下载点这里

这个是图例
1.jpg




本文转自suifei博客园博客,原文链接:http://www.cnblogs.com/Chinasf/archive/2005/04/18/139653.html,如需转载请自行联系原作者
相关文章
|
2月前
|
自然语言处理 C# Windows
C#开源免费的Windows右键菜单管理工具
C#开源免费的Windows右键菜单管理工具
|
Java C# C++
Java源码转C#源码的五款最佳工具
版权声明:本文为博主chszs的原创文章,未经博主允许不得转载。 https://blog.csdn.net/chszs/article/details/41913581 Java源码转C#源码的五款最佳工具 作者:chszs,转载需注明。
1146 0
|
5月前
|
缓存 开发框架 监控
一个C#开发的开源的快速启动工具
一个C#开发的开源的快速启动工具
43 0
|
3月前
|
存储 安全 算法
C# 泛型:类型参数化的强大工具
【1月更文挑战第7天】本文将深入探讨C#语言中的泛型编程,包括泛型的定义、用途、优势以及实际应用。通过类型参数化,泛型允许开发者编写更加灵活且可重用的代码,同时提高程序的类型安全性和性能。本文将通过示例代码和详细解释,帮助读者更好地理解泛型在C#中的重要性和实用性。
|
4月前
|
JSON C# 图形学
【Unity 3D】利用C#、Unity和Socket实现简单的在线聊天室工具(附源码 简单易懂)
【Unity 3D】利用C#、Unity和Socket实现简单的在线聊天室工具(附源码 简单易懂)
48 0
|
7月前
|
缓存 网络协议 C#
C#开源、功能强大、免费的Windows系统优化工具 - Optimizer
C#开源、功能强大、免费的Windows系统优化工具 - Optimizer
|
9月前
|
存储 XML SQL
C#:了解LINQ,简化数据查询和操作的强大工具(下)
C#:了解LINQ,简化数据查询和操作的强大工具
104 0
|
9月前
|
存储 开发框架 .NET
C#:了解LINQ,简化数据查询和操作的强大工具(中)
C#:了解LINQ,简化数据查询和操作的强大工具
68 0
|
9月前
|
存储 开发框架 .NET
C#:了解LINQ,简化数据查询和操作的强大工具(上)
C#:了解LINQ,简化数据查询和操作的强大工具
78 1
|
JavaScript 关系型数据库 MySQL
用node.js给C#写一个数据表的实体类生成工具
用node.js给C#写一个数据表的实体类生成工具
84 0