コード例 #1
0
        public static IEnumerable <Member> GetMembers(this CodeModule module, vbext_ProcKind?procedureKind = null)
        {
            var currentLine = module.CountOfDeclarationLines + 1;

            while (currentLine < module.CountOfLines)
            {
                vbext_ProcKind kind;
                var            name = module.get_ProcOfLine(currentLine, out kind);

                if ((procedureKind ?? kind) == kind)
                {
                    var startLine = module.get_ProcStartLine(name, kind);
                    var lineCount = module.get_ProcCountLines(name, kind);

                    var body = module.Lines[startLine, lineCount].Split('\n');

                    Member member;
                    if (Member.TryParse(body, new QualifiedModuleName(module.Parent), out member))
                    {
                        yield return(member);

                        currentLine = startLine + lineCount;
                    }
                    else
                    {
                        currentLine = currentLine + 1;
                    }
                }
            }
        }
コード例 #2
0
 private void addQueryObjectInfo(string objectName, string objInfo, int objType)
 {
     if (getQueryObjectInfo(objectName) == null)
     {
         string procName      = string.Format("{0}_QueryObjectInfo", AVE.Name);
         int    procStart     = codeModule.get_ProcBodyLine(procName, vbext_ProcKind.vbext_pk_Proc);
         int    procCountLine = codeModule.get_ProcCountLines(procName, vbext_ProcKind.vbext_pk_Proc);
         for (int endLoop = procStart + procCountLine; procStart <= endLoop; procStart++)
         {
             if (codeModule.get_Lines(procStart, 1).IndexOf("Case Else") > 0)
             {
                 break;
             }
         }
         codeModule.InsertLines(procStart, string.Format(@"        Case ""{0}""
     objType = {1}
     objInfo = ""{2}""", objectName, objType, objInfo));
     }
 }
コード例 #3
0
        public IEnumerable <Member> GetMembers()
        {
            var currentLine = _module.CountOfDeclarationLines + 1;

            while (currentLine < _module.CountOfLines)
            {
                vbext_ProcKind kind;
                var            name = _module.get_ProcOfLine(currentLine, out kind);

                var startLine = _module.get_ProcStartLine(name, kind);
                var lineCount = _module.get_ProcCountLines(name, kind);

                var body = _module.Lines[startLine, lineCount].Split('\n');

                Member member;
                if (Member.TryParse(body, _module.Parent.Collection.Parent.Name, _module.Parent.Name, out member))
                {
                    yield return(member);

                    currentLine = startLine + lineCount;
                }
            }
        }
コード例 #4
0
 public int get_ProcCountLines(string ProcName, Microsoft.Vbe.Interop.vbext_ProcKind ProcKind)
 {
     return(_codeModule.get_ProcCountLines(ProcName, ProcKind));
 }
コード例 #5
0
        ///<summary>
        /// ����������� �������������, �������� ����� �� ����������, ����� ��������.
        ///</summary>
        private void getAVEAlarmObject()
        {
            try
            {
                for (int i = 1; i <= ((VBE)m_App.VBE).VBProjects.Count; i++)
                {
                    VBProject bufProject = ((VBE)m_App.VBE).VBProjects.Item(i);
                    if (bufProject.FileName.ToLower() == m_App.ActiveDisplay.Path.ToLower()) // ���� �� ��������� ����� ������
                    {
                        project = bufProject;
                        break;
                    }
                }

                if (project == null)
                {
                    MessageBox.Show("VBProject not found");
                    return;
                }
                List <string> listOfCase      = new List <string>();
                string        procQueryText   = "";
                string        procDisplayText = "";

                codeModule = project.VBComponents.Item("ThisDisplay").CodeModule;
                //TODO: ��� ������� ����� ����� �� "�������� �������", ���� ������� AVExtension1_QueryObjectInfo. �� �������� ��������!
                try
                {
                    string procName      = "AVExtension1_QueryObjectInfo";
                    int    procStart     = codeModule.get_ProcBodyLine(procName, vbext_ProcKind.vbext_pk_Proc);
                    int    procCountLine = codeModule.get_ProcCountLines(procName, vbext_ProcKind.vbext_pk_Proc);

                    procQueryText = codeModule.get_Lines(procStart, procCountLine);
                    if (procQueryText.IndexOf("Select Case") > 0)
                    {
                        int startSelect = procQueryText.IndexOf("Select Case") + ("End Select").Length + 1;
                        int EndSelect   = procQueryText.IndexOf("End Select");
                        procQueryText = procQueryText.Substring(startSelect, EndSelect - startSelect);
                        string[] sfd = procQueryText.Split(new string[] { "Case " }, StringSplitOptions.None);
                        ListOfAVESymbol.Clear();
                        for (int i = 0; i < sfd.Length; i++)
                        {
                            if (sfd[i].IndexOf("objInfo") >= 0)
                            {
                                string objName = sfd[i].Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries)[0];
                                string mdbPath = sfd[i].Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries)[2];
                                Symbol symbol  = getSymbolByName(objName);

                                ListOfAVESymbol.Add(new AVEAlarmObject(objName, mdbPath, symbol));
                            }
                        }
                    }
                }
                catch {
                    string s = string.Format(Res2.DefaultQueryProc, "AVExtension1");
                    codeModule.AddFromString(s);
                    procQueryText = s;
                }

                try
                {
                    string procName      = "Display_Open";
                    int    procStart     = codeModule.get_ProcBodyLine(procName, vbext_ProcKind.vbext_pk_Proc);
                    int    procCountLine = codeModule.get_ProcCountLines(procName, vbext_ProcKind.vbext_pk_Proc);

                    procDisplayText = codeModule.get_Lines(procStart, procCountLine);

                    for (int j = procStart; j <= procCountLine; j++)
                    {
                        listOfCase.Add(codeModule.get_Lines(j, 1));
                    }
                    procDisplayText = procDisplayText.Substring(procDisplayText.IndexOf("Initialize") + ("Initialize").Length + 1);
                    procDisplayText = procDisplayText.Substring(0, procDisplayText.IndexOf('\n'));
                    string[] prop = procDisplayText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    ServerName = prop[0].Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries)[0];
                    ModuleRoot = prop[1].Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries)[0];
                }
                catch {
                    string s = string.Format(Res2.DefaultDisplyaOpen, "AVExtension1");
                    codeModule.AddFromString(s);
                    procDisplayText = s;
                }
            }
            catch { }
        }