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 / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

Newbie: How to extend a class?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Terry Carnes - 21 May 2007 20:49 GMT
I have a dotnet assembly which includes classes RequestType, Response,
Transaction, and TransactionElement.

To use this I would normally create a new Transaction passing it a parameter
of RequestType and receive a Transaction object of the right type in return.

Paymentech.Transaction transaction = new
Paymentech.Transaction(Paymentech.RequestType.CC_AUTHORIZE);

I now find myself having to access this assembly in an environment that does
not allow me to pass the RequestType parameter when I create the object
(PHP). To work around this limitation, I would like to create another dotnet
assembly which will basically be way to call all the different types of
Transactions without passing parameters. In other words, I want to create a
separate class for each type of Transaction I need.

So I will end up with a CC_AuthorizeTransaction class, a
CC_CaptureTransaction class, an Ecommerce_RefundTransaction class, etc.

I envision all these classes sitting in my own dotnet assembly.

I think I need to have each of my classes inherit/extend from the
Paymentech.Transaction class only needing to change the constructor.

Here is where I'm lost (not having done this before).  How do I do this? Do
I need to do something with all the other members/methods of
Paymentech.Transaction as well?

I apologize that this question is so basic.

Terry
PS - 21 May 2007 21:27 GMT
>I have a dotnet assembly which includes classes RequestType, Response,
>Transaction, and TransactionElement.
[quoted text clipped - 25 lines]
> Do I need to do something with all the other members/methods of
> Paymentech.Transaction as well?

public class CC_AuthorizeTransaction : Paymentech.Transaction
{
   public CC_AuthorizeTransaction()
{
   base.RequestType = Paymentech.RequestType.CC_AUTHORIZE;
}
}

> I apologize that this question is so basic.
>
> Terry
Terry Carnes - 21 May 2007 21:44 GMT
base.RequestType = Paymentech.RequestType.CC_AUTHORIZE;

Isn't working. I get the error that 'Paymentech.Transaction' does not
contain a definition for 'RequestType'.

I was expecting something like (in pseudocode):

return object = new
Paymentech.Transaction(Paymentech.RequestType.CC_AUTHORIZE);

The assembly doesn't allow the changing of a RequestType after
instantiation. It needs to know the requested type in its constructor so it
builds the right type of Transaction to begin with.

Terry
PS - 21 May 2007 22:35 GMT
>    base.RequestType = Paymentech.RequestType.CC_AUTHORIZE;
>
[quoted text clipped - 9 lines]
> instantiation. It needs to know the requested type in its constructor so
> it builds the right type of Transaction to begin with.

I was just taking a guess at the internals of the class as an example. Jon's
calling of the base constructor is the only way to do it based on this
knowledge.

> Terry
Jon Skeet [C# MVP] - 21 May 2007 21:51 GMT
> > Here is where I'm lost (not having done this before).  How do I do this?
> > Do I need to do something with all the other members/methods of
[quoted text clipped - 7 lines]
> }
> }

Or even (to keep in line with the previously posted code):

public class CC_AuthorizeTransaction : Paymentech.Transaction
{
   public CC_AuthorizeTransaction()
       : base (Paymentech.RequestType.CC_AUTHORIZE)
   {
   }
}

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Terry Carnes - 21 May 2007 21:59 GMT
Thanks, Jon! That worked!

> Or even (to keep in line with the previously posted code):
>
[quoted text clipped - 5 lines]
>    }
> }

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.