Code to Invoke a Single Pipeline Component

The MicroPipe object is generally created and used on a per page basis. The steps to invoke the MicroPipe object are similar to those used to run any other pipeline:

  1. Create instances of the necessary dictionaries, the MicroPipe object, and the pipeline component.
  2. Set up the Order and Context dictionaries, and the Configuration dictionary (if necessary).
  3. Configure the component with either the Configuration dictionary or by setting component properties. The method used depends on the specific component.
  4. Load and run the MicroPipe object.
  5. Clean up objects created on the page.

The following examples show the MicroPipe object used with components configured with a dictionary and with properties.

Example of a component configured with a dictionary

The following example shows how to use the MicroPipe object with the SendSMTP pipeline component, which is configured with a dictionary:

' Create Order, Context, and Configuration dictionaries.
Set dOrder = Server.CreateObject("Commerce.Dictionary")
Set dContext = Server.CreateObject("Commerce.Dictionary")
Set dConfig    = Server.CreateObject("Commerce.Dictionary")

' Set values in the Configuration dictionary.
' Not all required values are shown.
dConfig("SubjectField") = "subject_field" 
dConfig("BodyField") = "We will no longer accept bruised papayas" _
                       & " or mushy melons."
dConfig("BodyType") = 1

' Set values in the Order dictionary.
' Not all required values are shown.
dOrder("subject_field") = "To All Suppliers"

' Create an instance of the SendSMTP pipeline component.
Set pSMTP = Server.CreateObject("Commerce.SendSMTP")

' Create an instance of the MicroPipe object.
Set oMicropipe = Server.CreateObject("Commerce.MicroPipe")

' Configure the SendSMTP component with the Configuration dictionary.
pSMTP.SetConfigData dConfig

' Tell the MicroPipe which component to run, and run it.
oMicropipe.SetComponent pSMTP
errVal = oMicropipe.Execute(dOrder,dContext,lFlags)

' Checking for pipeline errors would be done here.

' Clean everything up.
Set dOrder = Nothing
Set dContext = Nothing
Set dConfig = Nothing
Set pSMTP = Nothing
Set oMicropipe = Nothing

Example of a component configured by setting properties

The following example shows how to use the MicroPipe object with a pipeline component, CopyValue3, configured by setting a property. The component is written as a Microsoft Visual Basic ActiveX control. The property, KeytoCopy, has as its value a key in the Order dictionary. The component creates a new key by copying the old key name, prefixing it with copy_, and then assigning to it the value of the original key:

' Create Order and Context dictionaries.
Set dOrder = Server.CreateObject("Commerce.Dictionary")
Set dContext = Server.CreateObject("Commerce.Dictionary")

' Create an instance of the CopyValue3 pipeline component.
Set pCopyValue = Server.CreateObject("My.CopyValue3")

' Set the dictionary key to copy - a property.
pCopyValue.KeytoCopy = "this_key"

' Set up the order dictionary - give the key to copy a value.
dOrder("this_key") = "...on the light fantastic toe"

' Create an instance of the MicroPipe object.
Set oMicropipe = Server.CreateObject("Commerce.MicroPipe")

' Tell the MicroPipe which component to run, and then run it.
oMicropipe.SetComponent pCopyValue
errVal = oMicropipe.Execute(dictOrder,dictContext,lFlags)

' Checking for pipeline errors would be done here.

' Clean everything up.
Set dOrder = Nothing
Set dContext = Nothing
Set pValue = Nothing
Set oMicropipe = Nothing

Copyright © 2005 Microsoft Corporation.
All rights reserved.