Msbin1MessageEditor.cs
2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//*************************************************************************************************
// Msbin1MessageEditor.cs
// Owner: Mahipal Kante
//
// Web Test Plugin for editing 'application/soap+msbin1' content type Web Service Requests
// (used by Silverlight application with WCF RIA)
//
// Copyright(c) Microsoft Corporation, 2010
//*************************************************************************************************
using Microsoft.VisualStudio.TestTools.WebTesting;
using WebTest.WebService.Plugin.ResultTab;
using WebTest.WebService.Plugin.Runtime;
namespace WebTest.WebService.Plugin.MessageEditors
{
/// <summary>
/// Editor for MSBin1 content type (WCF messages)
/// </summary>
public class Msbin1MessageEditor : IBinaryHttpBodyEditorPlugin
{
/// <summary>
///
/// </summary>
public Msbin1MessageEditor()
{
}
/// <summary>
/// Determine if this plugin supports a content type.
/// </summary>
/// <param name="contentType">The content type to test.</param>
/// <returns>Returns true if the plugin supports the specified content type.</returns>
public bool SupportsContentType(string contentType)
{
return contentType.ToLower().Contains("msbin1");
}
/// <summary>
/// Create a UserControl to edit the specified bytes. This control will be hosted in the
/// plugin dialog which provides OK and Cancel buttons.
/// </summary>
/// <param name="contentType">The content type of the BinaryHttpBody.</param>
/// <param name="initialValue">
/// The bytes to edit. The bytes are the payload of a BinaryHttpBody.
/// </param>
/// <returns>
/// A UserControl capable of displaying and editing the byte array value of
/// the specified content type.
/// </returns>
public object CreateEditor(string contentType, byte[] initialValue)
{
contentHandler = new Msbin1ContentHandler(contentType.ToLower().Contains("soap"));
contentHandler.MessageBytes = initialValue;
messageEditor = new MessageEditor(contentHandler);
return messageEditor;
}
/// <summary>
/// Gets the edited bytes after the OK button is clicked on the plugin dialog.
/// </summary>
public byte[] GetNewValue()
{
messageEditor.UpdateContent();
return contentHandler.MessageBytes;
}
private MessageEditor messageEditor = null;
private Msbin1ContentHandler contentHandler = null;
}
}