Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Aspect Oriented Programing in C#

Aspect Oriented Programing in C#

Scheduled Pinned Locked Moved C#
csharphelpcomdesignai-testing
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Kinnett
    wrote on last edited by
    #1

    I am trying to implement state verification as part of our automated testing framework. I want to use aspects to run a pre check and post check of any particular method call and only have an attribute indicating that that would be a verifiable method. This would be transparent to both the called and client code, performance is not an issue. There are two articles i have fond on the code project that touch on aspects in C#: http://www.codeproject.com/cs/design/aopsimplestscenario.asp?msg=2160427&mode=all&userid=3765364#xx2160427xx http://www.codeproject.com/csharp/aspectintercept.asp?msg=2145384&mode=all&userid=3765364#xx2145384xx Both use ContextBoundObject in their implementations. It seems that both solutions suffer from the same problem. Method injection does not work when a method is called from inside its own class. Something like this. /***Will properly call pre and post methods*****/ MyClass myClass = new MyClass(); myClass.CallMethod(); /***Will not call pre and post methods*****/ this.CallMethod() Has anyone else run into this problem? Am i going down the wrong path? Is there a better solution to the problem?

    N 1 Reply Last reply
    0
    • K Kevin Kinnett

      I am trying to implement state verification as part of our automated testing framework. I want to use aspects to run a pre check and post check of any particular method call and only have an attribute indicating that that would be a verifiable method. This would be transparent to both the called and client code, performance is not an issue. There are two articles i have fond on the code project that touch on aspects in C#: http://www.codeproject.com/cs/design/aopsimplestscenario.asp?msg=2160427&mode=all&userid=3765364#xx2160427xx http://www.codeproject.com/csharp/aspectintercept.asp?msg=2145384&mode=all&userid=3765364#xx2145384xx Both use ContextBoundObject in their implementations. It seems that both solutions suffer from the same problem. Method injection does not work when a method is called from inside its own class. Something like this. /***Will properly call pre and post methods*****/ MyClass myClass = new MyClass(); myClass.CallMethod(); /***Will not call pre and post methods*****/ this.CallMethod() Has anyone else run into this problem? Am i going down the wrong path? Is there a better solution to the problem?

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Not sure if it's what you are looking for, but have you looked at the Policy Injection Block in the latest Enterprise Library release? http://www.codeplex.com/entlib[^]


      only two letters away from being an asset

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups