示例#1
0
 private void TestActionHandler( object requestingSender, ActionRequestEventArgs e )
 {
 }
示例#2
0
        protected internal void BufferActionRequest( object sender, ActionRequestEventArgs e )
        {
            // exception handling not needed, this has to be fast
            // also buffer NULL
            // will be checked on dequeue later on

            lock ( this.actionRequestBufferLock )
            {
                this.actionRequestBuffer.Enqueue( e );
            }
        }
示例#3
0
        internal void AddMessageToBuffer( ActionRequestEventArgs args )
        {
            if ( args == null )
            {
                ArgumentNullException argnEx = new ArgumentNullException( "args", "The given event args must not be null." );
                this.LogManager.Trace( Namespace.LoggerName, LogLevel.Fatal, argnEx, argnEx.Message );
                throw argnEx;
            }

            lock ( this.messageBufferLock )
            {
                this.messageBuffer.Enqueue( args );
            }
        }
示例#4
0
        public void SendMessage( object requestingSender, string actionKey, params object[] actionParameters )
        {
            if ( actionKey == null )
            {
                ArgumentNullException argnEx = new ArgumentNullException( "actionKey" );
                this.LogManager.Trace( Namespace.LoggerName, LogLevel.Fatal, argnEx, argnEx.Message );
                throw argnEx;
            }

            DateTime requestTime = DateTime.Now;
            EventHandler<ActionRequestEventArgs> handlerDelegate = null;
            ActionRequestEventArgs args = new ActionRequestEventArgs( requestingSender, actionKey, requestTime, actionParameters );

            lock ( this.messageHandlersLockObject )
            {
                if ( this.messageHandlers.TryGetValue( actionKey, out handlerDelegate ) )
                {
                    this.AddMessageToBuffer( args );
                }
                else
                {
                    // handler unknown, ignore
                    this.LogManager.Trace( Namespace.LoggerName, LogLevel.Debugging, "No handler for message type {0}.", actionKey );
                }
            }

            lock ( this.messageHandlerAllMessagesLock )
            {
                if ( this.messageHandlerAllMessages != null )
                {
                    this.messageHandlerAllMessages( requestingSender, args );
                }
            }
        }
示例#5
0
 private void TestActionHandler( object requestingSender, ActionRequestEventArgs e )
 {
     //this.LogManager.Trace( Namespace.LoggerName, LogLevel.Debugging, "TestExtension: HANDLING action request: " + e.ActionKey );
     foreach ( object param in e.ActionParameters )
     {
         //this.LogManager.Trace(Namespace.LoggerName, LogLevel.Debugging, "Param: " + param.ToString() );
     }
 }
示例#6
0
文件: Entity.cs 项目: galaktor/ngin
        public void RequestAction( object requestingSender, string actionKey, params object[] actionParameters )
        {
            DateTime requestTime = DateTime.Now;
            EventHandler<ActionRequestEventArgs> handlerDelegate = null;

            lock ( this.actionHandlersLockObject )
            {
                try
                {
                    this.actionHandlers.TryGetValue( actionKey, out handlerDelegate );
                }
                catch ( ArgumentNullException )
                {
                    // TODO: ERROR
                    // LOG?
                    // actionKey was null
                    throw;
                }

            }

            if ( handlerDelegate != null )
            {
                ActionRequestEventArgs args = new ActionRequestEventArgs( requestingSender, actionKey, requestTime, actionParameters );
                handlerDelegate.Invoke( requestingSender, args );
            }
        }