source: trunk/Include/Classes/System/Delegate.ab@ 356

Last change on this file since 356 was 352, checked in by dai, 17 years ago

System.Collections.Generic.List.RemoveAtメソッドを追加
デリゲート型に対する"-"演算子を追加

File size: 1.8 KB
Line 
1Namespace System
2
3
4Class _SimpleDelegate
5Public
6 hasThisPtr As Boolean
7 object As Object
8 methodPtr As VoidPtr
9
10 Sub _SimpleDelegate( object As Object, methodPtr As VoidPtr )
11 This.hasThisPtr = True
12 This.object = object
13 This.methodPtr = methodPtr
14 End Sub
15 Sub _SimpleDelegate( methodPtr As VoidPtr )
16 This.hasThisPtr = False
17 This.object = Nothing
18 This.methodPtr = methodPtr
19 End Sub
20
21 Function IsEqual( sd As _SimpleDelegate ) As Boolean
22 Return ( This.hasThisPtr = sd.hasThisPtr and ObjPtr(This.object) = ObjPtr(sd.object) and This.methodPtr = sd.methodPtr )
23 End Function
24End Class
25
26Class DelegateBase
27Protected
28 simpleDelegates As System.Collections.Generic.List<_SimpleDelegate>
29
30 Sub _Add( dg As DelegateBase )
31 Dim i As Long
32 For i=0 To ELM(dg.simpleDelegates.Count)
33 simpleDelegates.Add( dg.simpleDelegates[i] )
34 Next
35 End Sub
36
37 Sub _Delete( dg As DelegateBase )
38 Dim i As Long
39 For i=0 To ELM(This.simpleDelegates.Count)
40 Dim i2 As Long
41 Dim isExist = False
42 For i2=0 To ELM(dg.simpleDelegates.Count)
43 If This.simpleDelegates[i].IsEqual( dg.simpleDelegates[i2] ) Then
44 isExist = True
45 End If
46 Next
47 If isExist Then
48 This.simpleDelegates.RemoveAt( i )
49 End If
50 Next
51 End Sub
52
53Public
54 Sub DelegateBase()
55 simpleDelegates = New System.Collections.Generic.List<_SimpleDelegate>()
56 End Sub
57
58/*
59 Sub Operator + ( sd As System._SimpleDelegate )
60 Add( sd )
61 End Sub*/
62Public
63End Class
64
65
66End Namespace
67
68
69Function _System_CreateSimpleDynamicDelegate( object As Object, methodPtr As VoidPtr ) As System._SimpleDelegate
70 Return New System._SimpleDelegate( object, methodPtr )
71End Function
72Function _System_CreateSimpleStaticDelegate( methodPtr As VoidPtr ) As System._SimpleDelegate
73 Return New System._SimpleDelegate( methodPtr )
74End Function
Note: See TracBrowser for help on using the repository browser.