Exemplo n.º 1
0
 public void ClassUnitTestRoundtrip()
 {
     // formatted class doesn't match the converted class because of the testMethod modifiers
     CompareLineByLine(ApexSharpParser.IndentApex(ClassUnitTest_Original), ClassUnitTest_Formatted);
     CompareLineByLine(ApexSharpParser.ConvertApexToCSharp(ClassUnitTest_Original), ClassUnitTest_CSharp1);
     CompareLineByLine(ApexSharpParser.ToApex(ClassUnitTest_CSharp1)[0], ClassUnitTest_Converted);
 }
Exemplo n.º 2
0
 private void Check(string apexOriginal, string apexFormatted, string csharp)
 {
     Assert.Multiple(() =>
     {
         CompareLineByLine(ApexSharpParser.IndentApex(apexOriginal), apexFormatted);
         CompareLineByLine(ApexSharpParser.ConvertApexToCSharp(apexOriginal), csharp);
         CompareLineByLine(ApexSharpParser.ToApex(csharp)[0], apexFormatted);
     });
 }
Exemplo n.º 3
0
 private string ToCSharp(string s)
 {
     try
     {
         return(ApexSharpParser.ConvertApexToCSharp(s));
     }
     catch (ParseException)
     {
         return(string.Empty);
     }
 }
Exemplo n.º 4
0
        public Dictionary <string, ClassReference> ProcessApexClasses(params string[] apexTexts)
        {
            if (apexTexts == null || !apexTexts.Any(t => !string.IsNullOrWhiteSpace(t)))
            {
                return(ProcessCSharpClasses());
            }

            var csharpClasses = apexTexts.Select(c => ApexSharpParser.ConvertApexToCSharp(c)).ToArray();

            return(ProcessCSharpClasses(csharpClasses));
        }
Exemplo n.º 5
0
        public static void ConvertToCSharp(FileInfo apexFile, DirectoryInfo cSharpLocation, string nameSpace)
        {
            if (!apexFile.Exists)
            {
                throw new FileNotFoundException(apexFile.FullName);
            }

            if (!cSharpLocation.Exists)
            {
                throw new DirectoryNotFoundException(cSharpLocation.FullName);
            }

            // Convert APEX to C#
            var apexClass   = File.ReadAllText(apexFile.FullName);
            var csharpClass = ApexSharpParser.ConvertApexToCSharp(apexClass, nameSpace);

            // Write the converted file to the target directory
            var csharpClassName = Path.ChangeExtension(apexFile.Name, "cs");
            var csharpFullName  = Path.Combine(cSharpLocation.FullName, csharpClassName);

            File.WriteAllText(csharpFullName, csharpClass);
        }
 private void Check(string apex, string csharp) =>
 CompareLineByLine(ApexSharpParser.ConvertApexToCSharp(apex), csharp);