/// <summary> /// Creates a line item of a particular type for a shipment rate quote /// </summary> /// <typeparam name="T">The type of the line item to create</typeparam> /// <param name="shipmentRateQuote">The <see cref="ShipmentRateQuote"/> to be translated to a line item</param> /// <returns>A <see cref="LineItemBase"/> of type T</returns> public static T AsLineItemOf <T>(this IShipmentRateQuote shipmentRateQuote) where T : LineItemBase { var extendedData = new ExtendedDataCollection(); extendedData.AddShipment(shipmentRateQuote.Shipment); var ctrValues = new object[] { EnumTypeFieldConverter.LineItemType.Shipping.TypeKey, shipmentRateQuote.ShimpentLineItemName(), shipmentRateQuote.ShipMethod.ServiceCode, // TODO this may not be unique (SKU) once multiple shipments are exposed 1, shipmentRateQuote.Rate, extendedData }; var attempt = ActivatorHelper.CreateInstance <LineItemBase>(typeof(T).FullName, ctrValues); if (!attempt.Success) { LogHelper.Error <ILineItem>("Failed instiating a line item from shipmentRateQuote", attempt.Exception); throw attempt.Exception; } return(attempt.Result as T); }
private void WriteShipRateQuote(IShipmentRateQuote srq) { Console.WriteLine("---------- Shipment Rate Quote ---------------------"); Console.WriteLine("Name: {0}", srq.ShimpentLineItemName()); Console.WriteLine("Rate Quote: {0}", srq.Rate); }