Used EventHandler<T> delegate because the event signature is the same for all. Changed the call of the event so that the indexes are not used. Action<ManagerEvent> allows you to use the delegate value at the current real time
This commit is contained in:
		
							parent
							
								
									fd6cdce95c
								
							
						
					
					
						commit
						5e738cdd3c
					
				
					 4 changed files with 1545 additions and 2187 deletions
				
			
		| 
						 | 
					@ -138,13 +138,13 @@ Ctrl-C to exit");
 | 
				
			||||||
			manager.RegisterUserEventClass(typeof(UserAgentLoginEvent));
 | 
								manager.RegisterUserEventClass(typeof(UserAgentLoginEvent));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Add or Remove events
 | 
								// Add or Remove events
 | 
				
			||||||
			manager.UserEvents += new UserEventHandler(dam_UserEvents);
 | 
								manager.UserEvents += dam_UserEvents;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Dont't display this event
 | 
								// Dont't display this event
 | 
				
			||||||
			manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent);
 | 
								manager.NewExten += manager_IgnoreEvent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Display all other
 | 
								// Display all other
 | 
				
			||||||
			manager.UnhandledEvent += new ManagerEventHandler(dam_Events);
 | 
								manager.UnhandledEvent += dam_Events;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// +++ Only to debug purpose
 | 
								// +++ Only to debug purpose
 | 
				
			||||||
			manager.FireAllEvents = true;
 | 
								manager.FireAllEvents = true;
 | 
				
			||||||
| 
						 | 
					@ -288,7 +288,7 @@ Ctrl-C to exit");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC.");
 | 
								Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC.");
 | 
				
			||||||
			// Wait for Dial Event from ORIGINATE_CHANNEL
 | 
								// Wait for Dial Event from ORIGINATE_CHANNEL
 | 
				
			||||||
			DialEventHandler de = new DialEventHandler(dam_Dial);
 | 
								EventHandler<DialEvent> de = dam_Dial;
 | 
				
			||||||
			manager.Dial += de;
 | 
								manager.Dial += de;
 | 
				
			||||||
			while (transferChannel == null)
 | 
								while (transferChannel == null)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					@ -323,7 +323,7 @@ Ctrl-C to exit");
 | 
				
			||||||
			//	Link event used to define monitor channel
 | 
								//	Link event used to define monitor channel
 | 
				
			||||||
			Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC.");
 | 
								Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC.");
 | 
				
			||||||
			// Wait for Link event
 | 
								// Wait for Link event
 | 
				
			||||||
			LinkEventHandler le = new LinkEventHandler(dam_Link);
 | 
								EventHandler<LinkEvent> le = dam_Link;
 | 
				
			||||||
			manager.Link += le;
 | 
								manager.Link += le;
 | 
				
			||||||
			while (monitorChannel == null)
 | 
								while (monitorChannel == null)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ namespace AsterNET.WinForm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			btnConnect.Enabled = false;
 | 
								btnConnect.Enabled = false;
 | 
				
			||||||
			manager = new ManagerConnection(address, port, user, password);
 | 
								manager = new ManagerConnection(address, port, user, password);
 | 
				
			||||||
			manager.UnhandledEvent += new ManagerEventHandler(manager_Events);
 | 
								manager.UnhandledEvent += manager_Events;
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				// Uncomment next 2 line comments to Disable timeout (debug mode)
 | 
									// Uncomment next 2 line comments to Disable timeout (debug mode)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -872,14 +872,15 @@ namespace AsterNET
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region RegisterEventHandler(Dictionary<int, int> list, int index, Type eventType) 
 | 
					        #region RegisterEventHandler(Dictionary<int, Action<ManagerEvent>> list, Type eventType, Action<ManagerEvent> action)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        internal static void RegisterEventHandler(Dictionary<int, int> list, int index, Type eventType)
 | 
					        internal static void RegisterEventHandler(Dictionary<int, Action<ManagerEvent>> list, Type eventType, Action<ManagerEvent> action)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            int eventHash = eventType.Name.GetHashCode();
 | 
					            var eventTypeName = eventType.Name;
 | 
				
			||||||
 | 
					            int eventHash = eventTypeName.GetHashCode();
 | 
				
			||||||
            if (list.ContainsKey(eventHash))
 | 
					            if (list.ContainsKey(eventHash))
 | 
				
			||||||
                throw new ArgumentException("Event class already registered : " + eventType.Name);
 | 
					                throw new ArgumentException("Event class already registered : " + eventTypeName);
 | 
				
			||||||
            list.Add(eventHash, index);
 | 
					            list.Add(eventHash, action);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
		Loading…
	
		Reference in a new issue