Ejemplo n.º 1
0
        public bool Convert(string ProvidedSource, out string ConvertedSource, out string ErrorMessage)
        {
            bool bSuccessfulConversion = BooHelpers.ConvertToBoo("convert.vb",
                                                                 ProvidedSource,
                                                                 out ConvertedSource,
                                                                 out ErrorMessage);

            return(bSuccessfulConversion);
        }
Ejemplo n.º 2
0
        public static bool ConvertToBoo(string fileName,
                                        string ProvidedSource,
                                        out string ConvertedSource,
                                        out string ErrorMessage)
        {
            ConvertedSource = ErrorMessage = "";

            CompilerErrorCollection   errors   = new CompilerErrorCollection();
            CompilerWarningCollection warnings = new CompilerWarningCollection();
            Module module;
            IList <ICSharpCode.NRefactory.ISpecial> specials;
            CompileUnit compileUnit = new CompileUnit();

            using (StringReader r = new StringReader(ProvidedSource))
            {
                // modified: removed fileName guessing
                module = Parser.ParseModule(compileUnit, r, BooHelpers.ApplySettings(fileName, errors, warnings), out specials);
            }

            if (module == null)
            {
                StringBuilder errorBuilder = new StringBuilder();
                foreach (CompilerError error in errors)
                {
                    errorBuilder.AppendLine(error.ToString());
                }
                if (warnings.Count > 0)
                {
                    foreach (CompilerWarning warning in warnings)
                    {
                        errorBuilder.AppendLine(warning.ToString());
                    }
                }
                ErrorMessage = errorBuilder.ToString();
                return(false);
            }
            else
            {
                ConvertedSource = BooHelpers.CreateBooCode(errors, warnings, module, specials);
            }

            return(true);
        }