Beispiel #1
0
 /// <summary>
 /// Applies the XSL transformation specified by <paramref name="map"/> to the specified <paramref
 /// name="sourceMessage"/> and adds the result as a part named <paramref name="destinationPartName"/> to the
 /// <paramref name="destinationMessage"/> message.
 /// </summary>
 /// <param name="sourceMessage">
 /// The <see cref="XLANGMessage"/> to be transformed.
 /// </param>
 /// <param name="map">
 /// The type of the BizTalk map class containing the transform to apply.
 /// </param>
 /// <param name="destinationMessage">
 /// Message to hold the transformation results.
 /// </param>
 /// <param name="destinationPartName">
 /// Name of the message part that will be added to <paramref name="destinationMessage"/> and that contains the
 /// results of the transformation.
 /// </param>
 public static void TransformAndAddPart(XLANGMessage sourceMessage, Type map, XLANGMessage destinationMessage, string destinationPartName)
 {
     if (sourceMessage == null)
     {
         throw new ArgumentNullException("sourceMessage");
     }
     if (map == null)
     {
         throw new ArgumentNullException("map");
     }
     if (destinationMessage == null)
     {
         throw new ArgumentNullException("destinationMessage");
     }
     try
     {
         using (var xmlReader = new XmlTextReader(sourceMessage.AsStream()))
         {
             var response = Transform(xmlReader, map, null);
             destinationMessage.AddPart(string.Empty, destinationPartName);
             destinationMessage[destinationPartName].LoadFrom(response);
         }
     }
     finally
     {
         sourceMessage.Dispose();
     }
 }