Beispiel #1
0
        private string ConvertSource(string csSrc, PreParseResult preResult)
        {
            IRefactoryProvider TmpRefactoryProvider;
            Int32 TmpI;
            Int32 TmpLine;

            string[] TmpLines;
            string   TmpS;
            string   RetS = "";

            //get current RefacotryProvider
            TmpRefactoryProvider = SettingsManager.CurrentRefactoryProvider;
            //convert with the RefactoryProvider
            try {
                RetS = TmpRefactoryProvider.ConvertCStoVB(csSrc);
            } catch (NetVertException ex) {
                //parser error, modify text and re-throw exception
                TmpS     = ex.Message.Substring(8, ex.Message.Length - 9);
                TmpI     = TmpS.IndexOf(" ");
                TmpLine  = Int32.Parse(TmpS.Substring(0, TmpI));
                TmpLine -= preResult.GetShift(TmpLine);
                if (TmpLine == 0)
                {
                    TmpLine = 1;
                }
                TmpS     = "Line " + TmpLine.ToString + TmpS.Substring(TmpI, TmpS.Length - TmpI);
                TmpLines = preResult.OriginalSourceLines;
                if (TmpLine > 1)
                {
                    if (TmpLine > 2)
                    {
                        TmpS += vbCrLf + "==== " + TmpLines(TmpLine - 3);
                    }
                    TmpS += vbCrLf + "==== " + TmpLines(TmpLine - 2);
                }
                if (TmpLines.Length >= TmpLine)
                {
                    TmpS += vbCrLf + "==>> " + TmpLines(TmpLine - 1);
                    if (TmpLines.Length > TmpLine)
                    {
                        TmpS += vbCrLf + "==== " + TmpLines(TmpLine);
                        if (TmpLines.Length > (TmpLine + 1))
                        {
                            TmpS += vbCrLf + "==== " + TmpLines(TmpLine + 1);
                        }
                    }
                }
                throw new NetVertException(TmpS);
            }
            return(RetS);
        }
Beispiel #2
0
        private string ConvertIfStatement(string ifStatement)
        {
            IRefactoryProvider TmpRefactoryProvider;
            string             TmpSrc;
            Int32  TmpI;
            string RetS = "";

            //get current RefacotryProvider
            TmpRefactoryProvider = SettingsManager.CurrentRefactoryProvider;
            //wrap BorderClass, BorderSub and If-Block around the ifStatement
            TmpSrc = "Class BorderClass {" + vbCrLf + "void BorderSub() {" + vbCrLf + "if " + ifStatement + " { }" + vbCrLf + "}" + vbCrLf + "}";
            try {
                //convert with the RefactoryProvider
                RetS = TmpRefactoryProvider.ConvertCStoVB(TmpSrc);
                //remove all wrapped Borders
                TmpI = RetS.IndexOf("If");
                RetS = RetS.Substring(TmpI + 3, RetS.IndexOf("Then", TmpI) - TmpI - 4);
            } catch (Exception ex) {
                //could not convert statement, return orginal
                RetS = ifStatement;
            }
            return(RetS);
        }