c# - Unity 3.0 and Exception Logging -


need sample project unity exception logging.

my requirement putting putting class attribute return parameter class , let unity work.

such want method logged in customexceptionhandler , return -1

  [customexceptionhandler(-1)]   public static int process(){    throw new exception("test");    } 

firstly, not able intercept static method using unity.

take @ developer's guide dependency injection using unity. specifically, chapter on interception using unity. modifying , tailoring code in guide might end like:

class customexceptionhandler : icallhandler {   public imethodreturn invoke(imethodinvocation input,     getnexthandlerdelegate getnext)   {     writelog(string.format("invoking method {0} @ {1}",       input.methodbase, datetime.now.tolongtimestring()));      // invoke next handler in chain     var result = getnext().invoke(input, getnext);      // after invoking method on original target     if (result.exception != null)     {       // cause exception if type invalid       result.returnvalue = -1;       result.exception = null;         }      return result;   }    public int order   {     get;     set;   } }   class customexceptionhandlerattribute : handlerattribute {   private readonly int order;    public customexceptionhandlerattribute(int order)   {     this.order = order;   }    public override icallhandler createhandler(iunitycontainer container)   {     return new customexceptionhandler() { order = order };   } }  class tenantstore : itenantstore {     [customexceptionhandler(1)]     public int process()     {         throw new exception("test");     } }  container.registertype<itenantstore, tenantstore>(     new interceptionbehavior<policyinjectionbehavior>(),     new interceptor<interfaceinterceptor>()); 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -