public void SuperCallModifiedToBaseToCSharp()
        {
            var tmpClass             = @"
package org;
public final class ThreadInterruptedException extends RuntimeException {
  public ThreadInterruptedException(InterruptedException ie) {
    super(ie);
  }}";
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            }, tmpClass);

            var tmpResult = CSharpWriter.CreateClassesFromObjectInformation(tmpObjectInformation, new ConverterLucene()).ToList();

            var tmpExpectedResult = @"using System;

namespace org
{
    public sealed class ThreadInterruptedException : RuntimeException
    {
        public ThreadInterruptedException(InterruptedException inIe)
            :base(inIe)
        {
        }
    }
}
";
            var tmpResultText     = tmpResult.Last().Content;

            Assert.AreEqual(tmpExpectedResult, tmpResultText);
        }
        public void DoubleConversionExplizit()
        {
            var tmpClass             = @"
package java.lang;
public class Class1 {
public void Run(object value){
var tmpValue=(Int32)(String)value;
}
}
";
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            }, tmpClass);


            var tmpResult = CSharpWriter.CreateClassesFromObjectInformation(tmpObjectInformation, new ConverterLucene()).ToList();

            var tmpExpectedResult = @"using System;

namespace System
{
    public class Class1
    {
        public void Run(object inValue)
        {
            var tmpValue =             (Int32)(String)inValue;
        }
    }
}
";

            Assert.AreEqual(tmpExpectedResult, tmpResult.Last().Content);
        }
        public void SimpleSingleTypeConversionExplizit()
        {
            var tmpClass             = @"
package java.lang;
public class Class1 {
public void Run(object value){
var tmpValue=(String)value;
}
}
";
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            }, tmpClass);

            var tmpMethodeContent = tmpObjectInformation.ClassList.Last().MethodeList[0];

            var tmpCodeLine1 = (tmpMethodeContent.Code.CodeEntries[0] as VariableDeclaration);

            Assert.AreEqual("tmpValue", tmpCodeLine1.Name);

            var tmpFirstConversion = tmpMethodeContent.Code.CodeEntries[1] as TypeConversion;

            Assert.AreEqual("String", tmpFirstConversion.Type.ToString());
            Assert.AreEqual("inValue", ((tmpFirstConversion.PreconversionValue.CodeEntries[0] as ConstantValue).Value as FieldContainer).Name);
        }
        public void CheckMitableValueEquals()
        {
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(
                ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            },
                EqualsString);

            var tmpResult = CSharpWriter.CreateClassesFromObjectInformation(tmpObjectInformation, new ConverterLucene()).ToList().Last();

            Assert.AreEqual("MutableValue", tmpResult.FullName);

            Assert.AreEqual(true, tmpResult.Content.Contains("   return ((GetType() == inOther.GetType()) && this.equalsSameType(inOther));"));
        }
示例#5
0
        public void DoubleGenericClassReplace()
        {
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(
                ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            },
                DoubleReplacement);

            var tmpResult = CSharpWriter.CreateClassesFromObjectInformation(tmpObjectInformation, new ConverterLucene()).ToList().Last();

            Assert.AreEqual("Bits", tmpResult.FullName);

            Assert.AreEqual(CSharpResultDouble, tmpResult.Content);
        }
        public void CheckMitableValueCompareTo()
        {
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(
                ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            },
                CompareToString);

            var tmpResult = CSharpWriter.CreateClassesFromObjectInformation(tmpObjectInformation, new ConverterLucene()).ToList().Last();

            Assert.AreEqual("MutableValue", tmpResult.FullName);

            Assert.AreEqual(true, tmpResult.Content.Contains("Type c1 =             this.GetType()"));
            Assert.AreEqual(true, tmpResult.Content.Contains(" - c2.GetHashCode()"));
        }
        public void Test()
        {
            var tmpClass             = @"
package java.lang;
public class Collection<T>{
}";
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            }, tmpClass);

            var tmpResult = CSharpWriter.CreateClassesFromObjectInformation(tmpObjectInformation, new ConverterLucene()).ToList();

            ///Write to JSON to add additional Java Base Classes
            var b = ExportHelper.CreateJsonFromClassList(tmpObjectInformation.ClassList.Where(inItem => inItem.ClassType == CodeConverterCore.Enum.ClassTypeEnum.Normal).ToList());
        }
        public void SuperCallModifiedToBase()
        {
            var tmpClass             = @"
package org;
public final class ThreadInterruptedException extends RuntimeException {
  public ThreadInterruptedException(InterruptedException ie) {
    super(ie);
  }}";
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            }, tmpClass);

            var tmpMethodeContent = tmpObjectInformation.ClassList.Last().MethodeList[0];

            Assert.AreEqual("base", tmpMethodeContent.ConstructorCall.Name);
        }
示例#9
0
        public void SuperCallModifiedToBase()
        {
            var tmpClass             = @"
package org;
public final class ThreadInterruptedException extends RuntimeException {
  public ThreadInterruptedException(InterruptedException ie) {
    super(ie);
  }}";
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(new List <LanguageMappingObject>(), new ConverterBase(), new JavaLoader()
            {
                LoadDefaultData = true
            }, tmpClass);

            var tmpMethodeContent = tmpObjectInformation.ClassList.Last().MethodeList[0];

            Assert.AreEqual("ThreadInterruptedException", tmpMethodeContent.Name);
            Assert.AreEqual("super", (tmpMethodeContent.Code.CodeEntries[0] as MethodeCall).Name);
        }
示例#10
0
        public void PropertyInInterfaceWithDefaultValue()
        {
            var tmpAnalyerSettings = new AnalyzerSettings();

            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            }, JavaClass);

            var tmpResult = CSharpWriter.CreateClassesFromObjectInformation(tmpObjectInformation, new ConverterLucene())
                            .Where(inItem => inItem.FullName == "MutableValue")
                            .ToList();

            Assert.AreEqual(1, tmpResult.Count);
            Assert.AreEqual("MutableValue", tmpResult[0].FullName);

            Assert.AreEqual(CSharpResult1, tmpResult[0].Content);
        }
示例#11
0
        public void SimpleSingleTypeConversionExplizitWithCSharpWrite()
        {
            var tmpClass             = @"
package java.lang;
public abstract  class Class1 {
 public abstract boolean exists();
public abstract object toObject();
  @Override
  public String toString() {
    return exists() ? toObject().toString() : ""(null)"";
  }
    }
";
            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            }, tmpClass);

            var tmpResult = CSharpWriter.CreateClassesFromObjectInformation(tmpObjectInformation, new ConverterLucene()).ToList().Last();

            var tmpExpectedResult = @"using System;

namespace System
{
    public abstract class Class1
    {
        public abstract bool Exists();

        public abstract object ToObject();

        public override String ToString()
        {
            return Exists() ? ToObject().ToString() : ""(null)"";
        }
    }
}
";

            Assert.AreEqual(tmpExpectedResult, tmpResult.Content);
        }
示例#12
0
        public static void ConvertFiles(string inSourcePath, string inOutPath)
        {
            JavaMapperPath     = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\JavaData\\JavaMapper.ini";
            LuceneReplacerPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\JavaData\\LuceneReplacer.ini";

            var tmpObjectInformation = ProjectInformationHelper.DoFullRun(
                ImportHelper.ImportMappingList(ClassRenameJson.SystemAliasJson), new ConverterLucene(), new JavaLoader()
            {
                LoadDefaultData = true
            },
                LoadFIleContents(inSourcePath).ToArray());

            Directory.CreateDirectory(inOutPath);

            //var tmpReplacer = new IniParser.Parser.IniDataParser().Parse(File.ReadAllText(LuceneReplacerPath));

            if (tmpObjectInformation.MissingMethodes.Count > 0)
            {
                throw new Exception("Missing Methodes Class to be Implemented");
            }
            WriteCSharpCode(inOutPath, tmpObjectInformation, ImportHelper.ImportStringReplacements(StringReplacementJson.ReplacementJson));

            CreateCSharpSLNFile(tmpObjectInformation, inOutPath);
        }