mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Closes #20; Build lists from IEnumerables
This commit is contained in:
parent
d928e3c7bf
commit
882da155ca
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
This file is
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
This file is
|
||||
@ -192,11 +192,13 @@
|
||||
</Params>
|
||||
</Constructor>
|
||||
<Constructor>
|
||||
<Imports />
|
||||
<Java>new ArrayList*[${T}]*(${collection})</Java>
|
||||
<Imports>
|
||||
<Import>CS2JNet.System.Collections.Generic.GenArrayListSupport</Import>
|
||||
</Imports>
|
||||
<Java>GenArrayListSupport.*[${T}]*toList(${collection})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>System.IEnumerable[T]</Type>
|
||||
<Type>System.Collections.Generic.IEnumerable*[T]*</Type>
|
||||
<Name>collection</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
|
37
CS2JLibrary/src/CS2JNet/System/Collections/Generic/GenArrayListSupport.java
Executable file
37
CS2JLibrary/src/CS2JNet/System/Collections/Generic/GenArrayListSupport.java
Executable file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author(s):
|
||||
|
||||
Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
*/
|
||||
|
||||
package CS2JNet.System.Collections.Generic;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class GenArrayListSupport<T> {
|
||||
|
||||
|
||||
public static <T> ArrayList<T> toList(Iterable<T> iter)
|
||||
{
|
||||
ArrayList<T> ret = new ArrayList<T>();
|
||||
for (T o : iter) {
|
||||
ret.add(o);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ namespace Tester
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
|
||||
Tester.DelegateUser.DelegateTest<int>.DelMain(args);
|
||||
//Tester.DelegateUser.DelegateTest<int>.DelMain(args);
|
||||
|
||||
//Tester.RefOut.RefOutTest.RefOutMain(args);
|
||||
|
||||
@ -14,6 +14,8 @@ namespace Tester
|
||||
|
||||
//Tester.Delegates.EventHandler.Sample.EHMain();
|
||||
|
||||
Tester.Misc.RenameTest.RNMain("hello world");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace Tester.Misc
|
||||
{
|
||||
|
||||
public class Misc
|
||||
{
|
||||
public Misc ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void GroupConfiguration(IEnumerable<Misc> groups)
|
||||
{
|
||||
IList<Misc> Groups = new List<Misc>(groups);
|
||||
}
|
||||
|
||||
private int TestProperty
|
||||
{
|
||||
get;set;
|
||||
|
25
CSharpTranslator/tests/Tester/Misc/RenameTest.cs
Normal file
25
CSharpTranslator/tests/Tester/Misc/RenameTest.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
namespace Tester.Misc
|
||||
{
|
||||
public class RenameTest
|
||||
{
|
||||
public RenameTest ()
|
||||
{
|
||||
}
|
||||
|
||||
public string AMethod(object x) {
|
||||
return "AMethod has arg " + x.ToString();
|
||||
}
|
||||
|
||||
public string aMethod(string s) {
|
||||
return "aMethod has string arg \"" + s + "\"";
|
||||
}
|
||||
|
||||
public static void RNMain(string arg) {
|
||||
RenameTest rnObj = new RenameTest();
|
||||
Console.Out.WriteLine(rnObj.AMethod(arg));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
30
CSharpTranslator/tests/Tester/Misc/newmodifier.cs
Normal file
30
CSharpTranslator/tests/Tester/Misc/newmodifier.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Tester.NewModifier
|
||||
{
|
||||
class B {
|
||||
public virtual void foo() {
|
||||
Console.WriteLine("B:foo");
|
||||
}
|
||||
}
|
||||
class D : B {
|
||||
public new void foo() {
|
||||
Console.WriteLine("D:foo");
|
||||
}
|
||||
}
|
||||
|
||||
public class Test5 {
|
||||
public static void T5Main(){
|
||||
B b = new D();
|
||||
b.foo();
|
||||
Console.WriteLine("Done");
|
||||
}
|
||||
}
|
||||
/*
|
||||
Output:
|
||||
B:foo
|
||||
*/
|
||||
}
|
@ -56,6 +56,8 @@
|
||||
<Compile Include="Misc\Misc.cs" />
|
||||
<Compile Include="Delegates\DelegateUser.cs" />
|
||||
<Compile Include="Delegates\EventHandler.cs" />
|
||||
<Compile Include="Misc\RenameTest.cs" />
|
||||
<Compile Include="Misc\newmodifier.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user