calling extension methods and calling them in data contracts

Hi,
I have using a 3 party payment cart provided by chase.
below is a extension method. Irequest is the object provided by chase for sending them a request.
String ordernumber is anything string.

Suppose , i want to call this SetMerchantOrderNumber(this IRequest request, string orderNumber)  in another class, how do i call it. i know i have to using this class using using in class file.

also, how do i mport this into datacontracts for sending the request to chase using wcf.
using System;
using System.Collections.Generic;
using System.Linq;
using ChasePaymentech.Spectrum;
using Vertrue.Core.String;
using Vertrue.Core.PaymenTech.Exceptions;
using Vertrue.Core.PaymenTech.Extensions.CreditCardVendors;
using Vertrue.Core.PaymenTech.Interfaces;

namespace Vertrue.Core.PaymenTech.Extensions.Request
{
    public static class IRequestExtensions
    {
        /// <summary>
        /// Validates the value passed in does not contain invalid characters and sets the MerchantOrderNumber property on the request.
        /// </summary>
        /// <param name="request">Any Paymentech request.</param>
        /// <param name="orderNumber">A string value must not contaion |,^,%,\,/,[,],`,~ characters and must be less than 23 characters.</param>
        public static void SetMerchantOrderNumber(this IRequest request, string orderNumber)
        {
            if (!string.IsNullOrWhiteSpace(orderNumber))
            {
                var invalidCharacters = new HashSet<char> { '|', '^', '%', '\\', '/', '[', ']', '~', '`' };
                const int merchantOrderNumbermaxLength = 22;

                //check for invalid characters
                if (orderNumber.ToCharArray().Any(invalidCharacters.Contains))
                    throw new ArgumentContainsInvalidCharacterException("value", invalidCharacters);

                //check for invalid length
                if (!orderNumber.IsValidLength(merchantOrderNumbermaxLength))
                    throw new ArgumentToLongException("value", merchantOrderNumbermaxLength);

                //should be left aligned and padded with spaces.
                orderNumber = orderNumber.Trim().Length == 0 ? null : orderNumber.PadRight(22, ' ');
            }
            else
                orderNumber = null;

            const string merchantOrderNumberKey = "MerchantOrderNumber";
            request[merchantOrderNumberKey] = orderNumber;
        }
DattuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
You would call it as:
IRequest someRequest = new IRequest();  // I know this isn't correct and is only for illustration

someRequest.SetMerchantOrderNumber("12345");

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DattuAuthor Commented:
hi,
i am looking for the exact syntax, pleasee....
Irequest is an interface.
0
tovvenkiCommented:
if you want to access the extension you need to have the implementation of IRequest.
for e.g

namespace MyInterface
{
    interface IRequest
    {
        string DoRequest();
    }
    public class Request : IRequest
    {
        #region IRequest Members

        public string DoRequest()
        {
            return "Welcome";
           
        }

        #endregion
    }
}

using MyInterface;

namespace MyExtensions
{
    static class MyExtension
    {
        public static string ExtendMe(this IRequest req, string name)
        {
            string test = req.DoRequest();
            return test + " " + name;
       
        }
    }
}


usage in other classes
using MyInterface;
using MyExtensions

  IRequest myReq = new Request();
  Console.WriteLine(myReq.ExtendMe("Tom"));

this will output Welcome, Tom.

I hope that this helps you

Thanks and regards,
Venki
 
0
käµfm³d 👽Commented:
>>   i am looking for the exact syntax, pleasee....


I gave you the syntax in line 3 of my post. You asked for the syntax to call an extension method, not how to declare an interface. And I stated in my post that the variable declaration was not proper.

To make the declaration proper, set it equal to a new instance of any class which implements IRequest.
0
DattuAuthor Commented:
Sorry, it tok me so long to close this questiona and had to give points to both of you. I wish I give each of you 250 points. Sorry again for the delay.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.