The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Osherove.Interception 1.04 - Change return values and incoming parameter values at runtime easily

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Roy Osherove

Posts: 1807
Nickname: royo
Registered: Sep, 2003

Roy Osherove is a .Net consultant based in Israel
Osherove.Interception 1.04 - Change return values and incoming parameter values at runtime easily Posted: Oct 19, 2004 10:06 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Roy Osherove.
Original Post: Osherove.Interception 1.04 - Change return values and incoming parameter values at runtime easily
Feed Title: ISerializable
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/rosherove/Rss.aspx
Feed Description: Roy Osherove's persistent thoughts
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Roy Osherove
Latest Posts From ISerializable

Advertisement
I just love the idea of interception. It lets you do stuff like this:

using Osherove.Interception.Framework;

 

namespace Osherove.Interception.Samples.AutoEncryption

{

      public class CryptTestedClass:InterceptableObject

      {

            [EncryptOutput]

            public string GetEncprytedValue(string someValue)

            {

                  //after this line someValue will be automatically

                  //encrypted and returned to the called in its new form

                  return someValue;

            }

 

            [DecryptInput("encrypted")]

            public string ReturnUnEncryptedString (string noChangeableValue,

                                                   string encrypted)

            {

                  //'encrypted' should already be in its unencrypted form in this stage

                  //so we just return it.

                  return encrypted;

            }

      }

}

 


and here are the tests(notice the the ecryption example is just a simple string concatenation - for demo purposes.

            [Test]

            public void TestEncrypt()

            {

               CryptTestedClass myClass = new CryptTestedClass();

               string output  = myClass.GetEncprytedValue("SomeValue");

               Assert.AreEqual("SomeValue*SomeEncryptStuffHere*",output);

            }

 

            [Test]

            public void TestDecrypt()

            {

                  string encrypted = "SomeValue*SomeEncryptStuffHere";

                 

                  string decryptedOutput =

                     new CryptTestedClass().

                        ReturnUnEncryptedString("some string",encrypted);

                 

                  Assert.AreEqual("SomeValue",decryptedOutput);

            }
 

If you want to be able to create such a feature, you'll need to download the latest version of my interception framework, version 1.0.4 from here.

Read: Osherove.Interception 1.04 - Change return values and incoming parameter values at runtime easily

Topic: Study predicts Microsft to overtake Symbian Previous Topic   Next Topic Topic: Notes from Digital Entertainment Everywhere event

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use