本文整理汇总了C#中ICSharpCode.PythonBinding.NRefactoryToPythonConverter.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# NRefactoryToPythonConverter.Convert方法的具体用法?C# NRefactoryToPythonConverter.Convert怎么用?C# NRefactoryToPythonConverter.Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.PythonBinding.NRefactoryToPythonConverter
的用法示例。
在下文中一共展示了NRefactoryToPythonConverter.Convert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertedPythonCode
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
"\tdef __init__(self):\r\n" +
"\t\tself._count = 0\r\n" +
"\t\tself._i = 0\r\n" +
"\r\n" +
"\tdef get_Count(self):\r\n" +
"\t\tif self._i == 0:\r\n" +
"\t\t\treturn 10\r\n" +
"\t\telse:\r\n" +
"\t\t\treturn self._count\r\n" +
"\r\n" +
"\tdef set_Count(self, value):\r\n" +
"\t\tif self._i == 1:\r\n" +
"\t\t\tself._count = value\r\n" +
"\t\telse:\r\n" +
"\t\t\tself._count = value + 5\r\n" +
"\r\n" +
"\tCount = property(fget=get_Count, fset=set_Count)";
Assert.AreEqual(expectedPython, python);
}
示例2: ConvertedPythonCode
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
" \"\"\" <summary>\r\n" +
" Class Foo\r\n" +
" </summary>\r\n" +
" \"\"\"\r\n" +
" def Run(self):\r\n" +
" \"\"\" <summary>\r\n" +
" Run\r\n" +
" </summary>\r\n" +
" \"\"\"\r\n" +
" pass\r\n" +
"\r\n" +
" def Stop(self):\r\n" +
" \"\"\" <summary> Stop </summary>\"\"\"\r\n" +
" pass\r\n" +
"\r\n" +
" def __init__(self):\r\n" +
" \"\"\" <summary> Initialize.</summary>\"\"\"\r\n" +
" # Initialize j.\r\n" +
" j = 0 # Set to zero\r\n" +
" # test\r\n" +
" if j == 0:\r\n" +
" j = 2";
Assert.AreEqual(expectedPython, python, python);
}
示例3: ConvertedPythonCode
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Class1(object):\r\n" +
"\tdef __init__(self):\r\n" +
"\t\tself._name = String.Empty\r\n" +
"\t\tself._lastName = String.Empty\r\n" +
"\r\n" +
"\tdef get_Name(self):\r\n" +
"\t\treturn self._name\r\n" +
"\r\n" +
"\tdef set_Name(self, value):\r\n" +
"\t\tself._name = value\r\n" +
"\r\n" +
"\tName = property(fget=get_Name, fset=set_Name)\r\n" +
"\r\n" +
"\tdef get_LastName(self):\r\n" +
"\t\treturn self._lastName\r\n" +
"\r\n" +
"\tdef set_LastName(self, value):\r\n" +
"\t\tself._lastName = value\r\n" +
"\r\n" +
"\tLastName = property(fget=get_LastName, fset=set_LastName)\r\n" +
"\r\n" +
"\tdef Clone(self):\r\n" +
"\t\treturn Class1(Name = \"First\", LastName = \"Last\")";
Assert.AreEqual(expectedPython, python);
}
示例4: ConvertedPythonCode
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
"\tdef __init__(self):\r\n" +
"\t\tself._i = 0\r\n" +
"\r\n" +
"\tdef GetCount(self):\r\n" +
"\t\tif self._i == 0:\r\n" +
"\t\t\tif self._i == 0:\r\n" +
"\t\t\t\tself._i = 10\r\n" +
"\t\t\t\treturn 10\r\n" +
"\t\t\telse:\r\n" +
"\t\t\t\tself._i = 4\r\n" +
"\t\t\t\treturn 4\r\n" +
"\t\telse:\r\n" +
"\t\t\tif self._i == 0:\r\n" +
"\t\t\t\tself._i = 10\r\n" +
"\t\t\t\treturn 10\r\n" +
"\t\t\telse:\r\n" +
"\t\t\t\tself._i = 4\r\n" +
"\t\t\t\treturn 4";
Assert.AreEqual(expectedPython, python);
}
示例5: GeneratedMainMethodCallWithNoParametersCode
public void GeneratedMainMethodCallWithNoParametersCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
converter.Convert(mainMethodWithNoParametersCode);
string code = converter.GenerateMainMethodCall(converter.EntryPointMethods[0]);
Assert.AreEqual("Foo.Main()", code);
}
示例6: DivideOperator
public void DivideOperator()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(GetCode(csharp, "/="));
string expectedPython = GetCode(pythonCodeTemplate, "/=");
Assert.AreEqual(expectedPython, python);
}
示例7: GeneratedPythonSourceCode
public void GeneratedPythonSourceCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n\tpass";
Assert.AreEqual(expectedPython, python);
}
示例8: GeneratedPythonSourceCode
public void GeneratedPythonSourceCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
string python = converter.Convert(vb);
string expectedPython = "class Class1(object):\r\n" +
"\tpass";
Assert.AreEqual(expectedPython, python);
}
示例9: ConvertedPythonCode
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
"\tdef __init__(self):\r\n" +
"\t\tSystem.Console.WriteLine(\"Test\")";
Assert.AreEqual(expectedPython, python);
}
示例10: ConvertedPythonCode
public void ConvertedPythonCode()
{
string expectedCode = "class Foo(object):\r\n" +
"\tdef Run(self):\r\n" +
"\t\treturn self.ToString()";
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string code = converter.Convert(csharp);
Assert.AreEqual(expectedCode, code);
}
示例11: ConvertedPythonCode
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
"\tdef GetCount(self):\r\n" +
"\t\treturn 10";
Assert.AreEqual(expectedPython, python);
}
示例12: ConvertedPythonCodeUsingFourSpacesAsIndent
public void ConvertedPythonCodeUsingFourSpacesAsIndent()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = new String(' ', 4);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
" pass";
Assert.AreEqual(expectedPython, python);
}
示例13: ConvertedPythonCode
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
"\tdef TestMe(self, test):\r\n" +
"\t\ta = \"Ape\" if test else \"Monkey\"\r\n" +
"\t\treturn a";
Assert.AreEqual(expectedPython, python);
}
示例14: ConvertedPythonCode
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
" def IsEqual(self, o):\r\n" +
" return Object.ReferenceEquals(o, None)";
Assert.AreEqual(expectedPython, python, python);
}
示例15: GeneratedPythonSourceCode
public void GeneratedPythonSourceCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string python = converter.Convert(csharp);
string expectedPython = "class Foo(object):\r\n" +
"\tdef Print(self):\r\n" +
"\t\ti = 0\r\n" +
"\t\tself.PrintInt(i)";
Assert.AreEqual(expectedPython, python);
}