Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2007

Tip: Looking for answers? Try searching our database.

Pre and post processing before a method executes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lukev123@gmail.com - 24 Jul 2007 11:08 GMT
Hi,

I have a class that has many methods and is growing all the time. In
each method I do a security check to see if the caller is allowed to
call the method. I also have a try catch block in every method for
exceptions.

This seems to be a lot of code for each method, so I'd like to know if
there's a way to apply an attribute that will allow pre and post
processing on a method. Ideally it looks something like this:

public MyClass
{
 private Exception ex = null;
 private UserSession userSession = null

// Assume that the user session is set on instantiation of the class

[PreProcessing("DoSecurityCheck")]
[PostProcessing("CheckForExceptions")]
public MyResult GetStuff()
{
  //   ... Get results
 return myResultInstance;
}

private void DoSecurityCheck()
{
 SecurityManager.IsValidSession(this.userSession);
}

private void CheckForExceptions(Object returnValue, Exception ex)  //
He he he I'm being hopeful here
{
 AuditManager.LogResult(returnValue);

 if(ex != null)
 {
   AuditManager.LogException(ex);
 }
}

}

Is this sort of thing possible?

Thanks,
Luke
Paul Wardle - 27 Jul 2007 20:04 GMT
Have a look at the policy injection block in the MS Enterprise Library.

See here: http://msdn2.microsoft.com/en-us/library/bb410104.aspx

HTH

Paul Wardle

> Hi,
>
[quoted text clipped - 44 lines]
> Thanks,
> Luke

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.