#namespace_begin#
	Class Delegate #name#
		Inherits System.DelegateBase

	Public
		Sub #name#()
		End Sub
		Sub #name#( dg As #name# )
			_Add( dg )
		End Sub

		#call_method_begin#
		'Sub Call(...)
			Dim i As Long
			For i = 0 To ELM(simpleDelegates.Count)
				Dim sd = simpleDelegates[i]
				If sd.hasThisPtr Then
					#result# __delegate_dynamicmethod_call(sd.methodPtr, sd.object, #params#)
				Else
					#result# __delegate_staticmethod_call(sd.methodPtr, #params#)
				End If
			Next
		'End Sub
		#call_method_end#

		Function Operator+ ( dg As #name# ) As #name#
			Dim result = New #name#( This )
			result._Add( dg )
			Return result
		End Function

		Function Operator- ( dg As #name# ) As #name#
			Dim result = New #name#( This )
			result._Delete( dg )
			Return result
		End Function

		Static Function _CreateDynamicDelegate( object As Object, methodPtr As VoidPtr ) As #name#
			Dim dg = New #name#
			dg.simpleDelegates.Add( New System._SimpleDelegate( object, methodPtr ) )
			Return dg
		End Function

		Static Function _CreateStaticDelegate( methodPtr As VoidPtr ) As #name#
			Dim dg = New #name#
			dg.simpleDelegates.Add( New System._SimpleDelegate( methodPtr ) )
			Return dg
		End Function
	End Class
#namespace_end#
