forked from IronLanguages/ironpython3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConversions.cs
More file actions
79 lines (64 loc) · 1.92 KB
/
Conversions.cs
File metadata and controls
79 lines (64 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
using IronPython.Runtime;
using System.Collections;
using System.Collections.Generic;
namespace IronPythonTest {
/// <summary>
/// Base used for implicit operator tests where the operator is defined
/// on the "derived" class
/// </summary>
public class Base {
public int value;
public Base(int value) {
this.value = value;
}
}
public class Derived {
public Derived(int value) {
this.value = value;
}
public int value;
public static implicit operator Base(Derived d) {
return new Base(d.value);
}
}
/// <summary>
/// Base class used where the implicit operator is defined on the
/// "base" class
/// </summary>
public class Base2 {
public int value;
public Base2(int value) {
this.value = value;
}
public static implicit operator Base2(Derived2 d) {
return new Base2(d.value);
}
}
public class Derived2 {
public int value;
public Derived2(int value) {
this.value = value;
}
}
public class ConversionStorage {
public Base Base;
public Derived Derived;
public Base2 Base2;
public Derived2 Derived2;
}
public class DoubleToFloat {
public static float ToFloat(double val) { return (float)val; }
}
public class DictConversion {
public static IList<object> ToIDictionary(IDictionary dict) {
List<object> res = new List<object>();
foreach (DictionaryEntry de in dict) {
res.Add(PythonTuple.MakeTuple(de.Key, de.Value));
}
return res;
}
}
}