Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • brinck10 24 posts 55 karma points
    Dec 31, 2012 @ 13:58
    brinck10
    0

    Pipeline CreateCostumerTask Decompilation Request

    Hi there, uCommerce experts.

    I'm currently developing a costumized webshop where I have to assign a purchaseOrder automatically to some users. Therefore, I dug into the world of pipelines and together with dotPeek (a decompilation program) I managed to get my hands on the code of the CreateCostumerTask pipeline function in the checkout() pipeline.

    The decompiled code looks like the following:

    public PipelineExecutionResult Execute(PurchaseOrder purchaseOrder)

        {

          if (purchaseOrder.Customer == null)

          {

            // ISSUE: object of a compiler-generated type is created

            // ISSUE: variable of a compiler-generated type

            CreateCustomerTask.<>c__DisplayClass0 cDisplayClass0 = new CreateCustomerTask.<>c__DisplayClass0();

            // ISSUE: reference to a compiler-generated field

            cDisplayClass0.billingAddress = purchaseOrder.GetBillingAddress();

            // ISSUE: reference to a compiler-generated field

            if (cDisplayClass0.billingAddress == null)

              throw new InvalidOperationException(string.Format("No billing address is set for order {0}. Please add an OrderAddress and set that as the billing address of the order.", (object) purchaseOrder.OrderGuid));

            ParameterExpression parameterExpression = Expression.Parameter(typeof (Customer), "x");

            // ISSUE: method reference

            // ISSUE: field reference

            // ISSUE: method reference

            // ISSUE: method reference

            // ISSUE: reference to a compiler-generated field

            Customer customer = Customer.SingleOrDefault(Expression.Lambda<Func<Customer, bool>>((Expression) Expression.Equal((Expression) Expression.Property((Expression) parameterExpression, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Customer.get_EmailAddress))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) cDisplayClass0), FieldInfo.GetFieldFromHandle(__fieldref (CreateCustomerTask.<>c__DisplayClass0.billingAddress))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderAddress.get_EmailAddress))), false, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (string.op_Equality))), new ParameterExpression[1]

            {

              parameterExpression

            })) ?? Customer.Create(cDisplayClass0.billingAddress);

            purchaseOrder.Customer = customer;

          }

          return PipelineExecutionResult.Success;

        }

     

    I would like to hear, if you could elaborate on the code where it initiates a new class containing the <> symbol. That is, to say, to be able to create my costum pipeline with a costumized "CreateCostumer" function. My final aim is to be able to create a new costumer with a dummy billing address assigned to him.

     

    Thanks in advance, and a happy new year to everyone!

    Brinck10

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jan 02, 2013 @ 14:31
    Søren Spelling Lund
    0

    Hi Brinck10,

    Instead of changing the default CreateCustomer task you could just create a new task from scratch and add that after the CreateCustomer task completes.

    Basically you can just override the information already stored on the Customer and the associated address. It would be much easier to do.

    Hope this helps.

Please Sign in or register to post replies

Write your reply to:

Draft