diff --git a/CS2JLibrary/NetFramework/System/EventHandler.xml b/CS2JLibrary/NetFramework/System/EventHandler.xml new file mode 100644 index 0000000..c54411b --- /dev/null +++ b/CS2JLibrary/NetFramework/System/EventHandler.xml @@ -0,0 +1,83 @@ + + + + + CS2JNet.System.EventHandler + + EventHandler*[${TEventArgs}]* + System.EventHandler + + TEventArgs + + + + System.Object + + + + + CS2JNet.System.__MultiEventHandler + + __MultiEventHandler.Combine(${a},${b}) + + + System.EventHandler*[TEventArgs]* + a + + + System.EventHandler*[TEventArgs]* + b + + + Combine + + T + + System.EventHandler*[TEventArgs]* + + + + CS2JNet.System.__MultiEventHandler + + __MultiEventHandler.Remove(${a},${b}) + + + System.EventHandler*[TEventArgs]* + a + + + System.EventHandler*[TEventArgs]* + b + + + Remove + + T + + System.EventHandler*[TEventArgs]* + + + + ${this:16}.Invoke(${sender}, ${e}) + + + System.Object + sender + + + TEventArgs + e + + + Invoke + + void + +10gQjwZURfUiWRQQZHHLhjzvyao=LqaNkGhL5G8I7kNkIqKGWaU1y3aQS1NNeLnUK0bAhiQDk2aatsldV3RvSyA+sUyHJ/La+jYz5chPUmZusenax1EoM9CvvOoP9Uzpz4V4VtpWWBJr65Hc9rLhyfkgxoGgSnuvFOxxLVd/t1LqzE+SHlfgaxYTttwwIoSqHksEsAc= + diff --git a/CS2JLibrary/src/CS2JNet/System/EventHandler.java b/CS2JLibrary/src/CS2JNet/System/EventHandler.java new file mode 100644 index 0000000..cc52f06 --- /dev/null +++ b/CS2JLibrary/src/CS2JNet/System/EventHandler.java @@ -0,0 +1,30 @@ +/* + 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; + +import java.util.List; + +public interface EventHandler { + void Invoke(Object sender, TEventArgs value) throws Exception ; + + List> GetInvocationList() throws Exception ; + +} diff --git a/CS2JLibrary/src/CS2JNet/System/__MultiEventHandler.java b/CS2JLibrary/src/CS2JNet/System/__MultiEventHandler.java new file mode 100644 index 0000000..ca77ff6 --- /dev/null +++ b/CS2JLibrary/src/CS2JNet/System/__MultiEventHandler.java @@ -0,0 +1,78 @@ +/* + 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; + +import java.util.ArrayList; +import java.util.List; + +import CS2JNet.JavaSupport.util.ListSupport; + +/** + * @author keving + * + */ +public class __MultiEventHandler implements EventHandler { + + public void Invoke(Object other, TEventArgs e) throws Exception { + for (EventHandler d : this.GetInvocationList()) + { + d.Invoke(other, e); + } + } + + private List> _invocationList = new ArrayList>(); + public static EventHandler Combine(EventHandler a, EventHandler b) throws Exception { + if (a == null) + return b; + + if (b == null) + return a; + + __MultiEventHandler ret = new __MultiEventHandler(); + ret._invocationList = a.GetInvocationList(); + ret._invocationList.addAll(b.GetInvocationList()); + return ret; + } + + public static EventHandler Remove(EventHandler a, EventHandler b) throws Exception { + if (a == null || b == null) + return a; + + List> aInvList = a.GetInvocationList(); + List> newInvList = ListSupport.removeFinalStretch(aInvList, b.GetInvocationList()); + if (aInvList == newInvList) + { + return a; + } + else + { + __MultiEventHandler ret = new __MultiEventHandler(); + ret._invocationList = newInvList; + return ret; + } + } + + public List> GetInvocationList() throws Exception { + return _invocationList; + } + + +}