PageRenderTime 33ms CodeModel.GetById 29ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/IronPython_2_0/Src/IronPythonTest/OperatorTest.cs

#
C# | 58 lines | 37 code | 7 blank | 14 comment | 0 complexity | 44aa43acdf27f431aef60829eae8f92e MD5 | raw file
 1/* ****************************************************************************
 2 *
 3 * Copyright (c) Microsoft Corporation. 
 4 *
 5 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 6 * copy of the license can be found in the License.html file at the root of this distribution. If 
 7 * you cannot locate the  Microsoft Public License, please send an email to 
 8 * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 9 * by the terms of the Microsoft Public License.
10 *
11 * You must not remove this notice, or any other, from this software.
12 *
13 *
14 * ***************************************************************************/
15using System; using Microsoft;
16
17
18using System.Runtime.CompilerServices;
19using Microsoft.Runtime.CompilerServices;
20
21using Microsoft.Scripting.Runtime;
22
23[assembly: ExtensionType(typeof(IronPythonTest.ExtendedClass), typeof(IronPythonTest.ExtensionClass))]
24namespace IronPythonTest {
25    public class OperatorTest {
26        public object Value;
27        public string Name;
28
29        [SpecialName]
30        public object GetBoundMember(string name) {
31            Name = name;
32            return 42;
33        }
34        [SpecialName]
35        public void SetMember(string name, object value) {
36            Name = name;
37            Value = value;
38        }
39    }
40
41    public class ExtendedClass {
42        public object Value;
43        public string Name;
44    }
45
46    public class ExtensionClass {
47        [SpecialName]
48        public static object GetBoundMember(ExtendedClass self, string name) {
49            self.Name = name;
50            return 42;
51        }
52        [SpecialName]
53        public static void SetMember(ExtendedClass self, string name, object value) {
54            self.Name = name;
55            self.Value = value;
56        }
57    }
58}