Extending Commerce OrderForm
We have extended the OrderForm with a Strongly-Typed property ("OrderType") via the OrderObjectMappings.xml file and run the tool to update the scripts and OrderForm table.
We have created an inherited Commerce Order Form Class which inherits from the Microsoft.CommerceServer.Runtime.Orders.OrderForm Class. The skeleton of the class is as follows:
protected CommerceOrderForm(SerializationInfo info, StreamingContext context): base(info, context)
{
m_dtmOrderDate = info.GetDateTime("OrderDate");
try
{
m_strOrderType = info.GetString("OrderType");
}
catch (SerializationException)
{
m_strOrderType = string.Empty;
}
}
When existing objects are hydrated, they of course do NOT have a property named "OrderType". Therefore, a SerializationException is thrown. To address that issue, we use a try..catch to set the the new property to a default value.
What is the correct way to handle extensions (Properties) to Commerce Server and properly hyrdrate existing objects that do not have the new Property so that a SerializationException is not thrown?
1) Use Try..Catch?
2) Use the .GetEnumerator on the SerializationInfo object and loop through each name-value pair?
3) Use Class Versioning to determine which properties are mapped based on the class properties?
Thanks for the help..
Erl

