Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - Intercepting method called from a method of the same object -


here's situation:

/// <summary> /// business logic class. /// </summary> public class businessclasswithinterceptor : businessclass, ibusinessclass {     /// <summary>     /// initializes new instance of <see cref="businessclasswithoutinterceptor"/> class.     /// </summary>     /// <param name="logger">the logger.</param>     public businessclasswithinterceptor(logger logger)         : base(logger)     {     }      /// <summary>     /// displays cows.     /// </summary>     public void displayallcows()     {         this.logger.write("displaying cows:");         var repository = new cowrepository();         foreach (cowentity cow in repository.getallcows())         {             this.logger.write("    " + cow);         }     }      /// <summary>     /// inserts normande.     /// </summary>     public void insertnormande(int id, string name)     {         this.displayallcows();          var repository = new cowrepository();         repository.insertcow(new cowentity { id = id, name = name, origin = coworigin.normandie });     } } 

with castle windsor, class configured intercepted interceptor:

/// <summary> /// interceptor logging business methods. /// </summary> public class businessloginterceptor : iinterceptor {     /// <summary>     /// intercepts specified invocation.     /// </summary>     /// <param name="invocation">the invocation.</param>     public void intercept(iinvocation invocation)     {         logger logger = ((ibusinessclass)invocation.invocationtarget).logger;          var parameters = new stringbuilder();         parameterinfo[] methodparameters = invocation.method.getparameters();         (int index = 0; index < methodparameters.length; index++)         {             parameters.appendformat("{0} = {1}", methodparameters[index].name, invocation.arguments[index]);             if (index < methodparameters.length - 1)             {                 parameters.append(", ");             }         }          logger.format("calling {0}( {1} )", invocation.method.name, parameters.tostring());         invocation.proceed();         logger.format("exiting {0}", invocation.method.name);     } } 

the issue takes place during call insertnormande. call insertnormande intercepted, call displayallcows in insertnormande not intercepted...

it bothers me.

is there way achieve interception in scenario ?

i don't think there's easy way of doing it... method calls internal class can't intercepted, since don't go through proxy.

you achieve logging of methods other means, such aop framework postsharp


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -