Have you ever wanted to get the Commerce Server managed OrderForm transformed into the Dictionary key pair values? If the answer is yes then keep reading.
There are some scenarios where you just want the OrderForm in Dictionary format so you can call the pipeline components directly or execute the managed pipelines. Please be aware that you can execute the pipeline components outside ASP.NET. For more info please read the following link.
If you have read my pipeline posts then you know that when executing a pipeline, Commerce Server under the covers will transform your managed OrderForm(s) into Commerce Server Dictionary object(s). For whatever reason, the Commerce Server Product Group did not make the PipelineAdapter public. The PipelineAdapter object is responsible for transformation of the OrderForm. So how can you do this if the class is not public? Reflection.
The following code will show you how to transform the OrderForm. You will need to reference the Microsoft.CommerceServer.Runtime.dll and Microsoft.CommerceServer.Interop.dll. You will also need to make sure that you have an app.config with the order node.
// Get an order context to work with
// Get the value of the PipelineAdapterMap property
object orderform = new object;
// Method 15 has is what we want and pass it our managed OrderForm
// Do something with the Dictionary OrderForm