using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
namespace LightWebTestFramework
{
public class DeclarativeWebTestSerializer
{
private const string tagComment = "Comment";
private const string tagCondition = "Condition";
private const string tagConditionalRule = "ConditionalRule";
private const string tagContextParameter = "ContextParameter";
private const string tagContextParameters = "ContextParameters";
private const string tagCorrelationExtractionRules = "CorrelationExtractionRules";
private const string tagDataSource = "DataSource";
private const string tagDataSources = "DataSources";
private const string tagDataSourceTable = "DataSourceTable";
private const string tagDependentRequests = "DependentRequests";
private const string tagElse = "Else";
private const string tagExtractionRule = "ExtractionRule";
private const string tagExtractionRules = "ExtractionRules";
private const string tagHeader = "Header";
private const string tagHeaders = "Headers";
private const string tagIncludedWebTest = "IncludedWebTest";
private const string tagItems = "Items";
private const string tagLoop = "Loop";
private const string tagRequest = "Request";
private const string tagRequests = "Requests";
private const string tagRuleParameter = "RuleParameter";
private const string tagRuleParameters = "RuleParameters";
private const string tagTestCase = "TestCase";
private const string tagThen = "Then";
private const string tagTransactionTimer = "TransactionTimer";
private const string tagValidationRule = "ValidationRule";
private const string tagValidationRules = "ValidationRules";
private const string tagRequestPlugins = "RequestPlugins";
private const string tagRequestPlugin = "RequestPlugin";
private const string tagWebTest = "WebTest";
private const string tagWebTestPlugin = "WebTestPlugin";
private const string tagWebTestPlugins = "WebTestPlugins";
private const string tagStringHttpBody = "StringHttpBody";
private const string tagBinaryHttpBody = "BinaryHttpBody";
private const string tagFormPostHttpBody = "FormPostHttpBody";
private const string tagFormPostParameter = "FormPostParameter";
private const string tagFileUploadParameter = "FileUploadParameter";
private const string tagQueryStringParameter = "QueryStringParameter";
private const string tagQueryStringParameters = "QueryStringParameters";
private const string tagXmlns = "xmlns";
private const string tagAccessMethod = "AccessMethod";
private const string tagSelectColumns = "SelectColumns";
private const string tagEncoding = "Encoding";
private const string tagCache = "Cache";
private const string tagClassname = "Classname";
private const string tagCommentText = "CommentText";
private const string tagCredentialUserName = "CredentialUserName";
private const string tagCredentialPassword = "CredentialPassword";
private const string tagDescription = "Description";
private const string tagExpectedHttpStatusCode = "ExpectedHttpStatusCode";
private const string tagPreAuthenticate = "PreAuthenticate";
private const string tagProxy = "Proxy";
private const string tagProvider = "Provider";
private const string tagStopOnError = "StopOnError";
private const string tagRecordedResultFile = "RecordedResultFile";
private const string tagConnection = "Connection";
private const string tagConnectionDisplayValue = "ConnectionDisplayValue";
private const string tagLevel = "Level";
private const string tagExectuionOrder = "ExectuionOrder";
internal const string tagId = "Id";
private const string tagInheritWebTestSettings = "InheritWebTestSettings";
private const string tagIsCodedWebTest = "IsCodedWebTest";
private const string tagMethod = "Method";
private const string tagName = "Name";
private const string tagPath = "Path";
private const string tagOwner = "Owner";
private const string tagParseDependentRequests = "ParseDependentRequests";
private const string tagFollowRedirects = "FollowRedirects";
private const string tagExpectedResponseUrl = "ExpectedResponseUrl";
private const string tagReportingName = "ReportingName";
private const string tagRecordedResponseUrl = "RecordedResponseUrl";
private const string tagRecordResult = "RecordResult";
private const string tagResponseTimeGoal = "ResponseTimeGoal";
private const string tagRequestCallbackClass = "RequestCallbackClass";
private const string tagTables = "Tables";
private const string tagTestCaseCallbackClass = "TestCaseCallbackClass";
private const string tagThinkTime = "ThinkTime";
private const string tagTimeout = "Timeout";
private const string tagUrl = "Url";
private const string tagUseToGroupResults = "UseToGroupResults";
private const string tagValue = "Value";
private const string tagVariableName = "VariableName";
private const string tagVersion = "Version";
private const string tagPriority = "Priority";
private const string tagEnabled = "Enabled";
private const string tagCssProjectStructure = "CssProjectStructure";
private const string tagCssIteration = "CssIteration";
private const string tagDeploymentItemsEditable = "DeploymentItemsEditable";
private const string tagTestCategories = "TestCategories";
private const string tagWorkItemIds = "WorkItemIds";
private const string tagUrlEncode = "UrlEncode";
private const string tagContentType = "ContentType";
private const string tagInsertByteOrderMark = "InsertByteOrderMark";
private const string tagFileName = "FileName";
private const string tagRecordedValue = "RecordedValue";
private const string tagDisplayName = "DisplayName";
private const string tagCorrelationBinding = "CorrelationBinding";
private const string tagUniqueStringId = "UniqueStringId";
private const string tagMaxIterations = "MaxIterations";
private const string tagAdvanceDataCursors = "AdvanceDataCursors";
private const string tagGenerateUniqueName = "GenerateUniqueName";
private const string c_currentXmlns = "http://microsoft.com/schemas/VisualStudio/TeamTest/2010";
private const string c_orcasXmlns = "http://microsoft.com/schemas/VisualStudio/TeamTest/2006";
private string m_fileName;
private DeclarativeWebTestSerializer(string fileName)
{
this.m_fileName = fileName;
}
public static DeclarativeWebTest Open(string fileName)
{
DeclarativeWebTestSerializer declarativeWebTestSerializer = new DeclarativeWebTestSerializer(fileName);
DeclarativeWebTest declarativeWebTest;
try
{
declarativeWebTest = declarativeWebTestSerializer.DomToModel(DomHelpers.DomFromFile(fileName));
declarativeWebTest.TestElementProperties.Storage = fileName;
declarativeWebTest.TestElementProperties.Name = WebTestFrameworkHelperMethods.GetNameFromPath(fileName);
}
catch (WebTestException)
{
throw;
}
catch (Exception)
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.WebTestCannotBeOpened, new object[]
{
fileName
}));
}
if (declarativeWebTest != null)
{
declarativeWebTest.FilePath = fileName;
}
return declarativeWebTest;
}
public static DeclarativeWebTest Open(Stream stream)
{
DeclarativeWebTestSerializer declarativeWebTestSerializer = new DeclarativeWebTestSerializer(null);
return declarativeWebTestSerializer.DomToModel(DomHelpers.DomFromStream(stream));
}
internal static DeclarativeWebTest Open(XmlDocument document)
{
DeclarativeWebTestSerializer declarativeWebTestSerializer = new DeclarativeWebTestSerializer(null);
return declarativeWebTestSerializer.DomToModel(document);
}
public static void Save(DeclarativeWebTest declarativeWebTest, string fileName)
{
DeclarativeWebTestSerializer declarativeWebTestSerializer = new DeclarativeWebTestSerializer(fileName);
declarativeWebTest.TestElementProperties.Storage = fileName;
declarativeWebTest.FilePath = fileName;
DomHelpers.DomToFile(declarativeWebTestSerializer.ModelToDom(declarativeWebTest), fileName);
}
public static void Save(DeclarativeWebTest declarativeWebTest, Stream stream)
{
DeclarativeWebTestSerializer declarativeWebTestSerializer = new DeclarativeWebTestSerializer(null);
DomHelpers.DomToStream(declarativeWebTestSerializer.ModelToDom(declarativeWebTest), stream);
}
internal static XmlDocument Save(DeclarativeWebTest declarativeWebTest)
{
DeclarativeWebTestSerializer declarativeWebTestSerializer = new DeclarativeWebTestSerializer(null);
return declarativeWebTestSerializer.ModelToDom(declarativeWebTest);
}
internal static bool ElementIsWebTest(XmlElement element)
{
return string.Equals(element.Name, "WebTest", StringComparison.Ordinal) || string.Equals(element.Name, "TestCase", StringComparison.Ordinal);
}
private static string GetFilename(XmlElement elem)
{
string result = string.Empty;
XmlDocument ownerDocument = elem.OwnerDocument;
if (elem.OwnerDocument != null)
{
result = ownerDocument.BaseURI;
}
return result;
}
private DeclarativeWebTest DomToModel(XmlDocument doc)
{
return this.CreateTestCase(DomHelpers.GetRootElement(doc));
}
private XmlDocument ModelToDom(DeclarativeWebTest declarativeWebTest)
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.AppendChild(this.CreateTestCaseElement(xmlDocument, declarativeWebTest));
return xmlDocument;
}
private DeclarativeWebTest CreateTestCase(XmlElement elem)
{
if (!DeclarativeWebTestSerializer.ElementIsWebTest(elem))
{
throw new WebTestException(string.Format(CultureInfo.CurrentCulture, Resources.WebTestCannotBeOpened, new object[]
{
DeclarativeWebTestSerializer.GetFilename(elem)
}));
}
string stringAttribute = DomHelpers.GetStringAttribute(elem, "xmlns", "http://microsoft.com/schemas/VisualStudio/TeamTest/2010");
if (!string.Equals(stringAttribute, "http://microsoft.com/schemas/VisualStudio/TeamTest/2010", StringComparison.Ordinal) && !string.Equals(stringAttribute, "http://microsoft.com/schemas/VisualStudio/TeamTest/2006", StringComparison.Ordinal))
{
throw new WebTestException(string.Format(CultureInfo.CurrentCulture, Resources.WebTestFileCreatedByLaterRelease, new object[]
{
DeclarativeWebTestSerializer.GetFilename(elem)
}));
}
DeclarativeWebTest declarativeWebTest = new DeclarativeWebTest();
declarativeWebTest.Name = DomHelpers.GetStringAttribute(elem, "Name");
string stringAttribute2 = DomHelpers.GetStringAttribute(elem, "Id");
if (!string.IsNullOrEmpty(stringAttribute2))
{
declarativeWebTest.Guid = new Guid(stringAttribute2);
}
else
{
declarativeWebTest.IsNewTest = true;
declarativeWebTest.Guid = Guid.NewGuid();
}
declarativeWebTest.TestElementProperties.Owner = DomHelpers.GetStringAttribute(elem, "Owner");
declarativeWebTest.TestElementProperties.Priority = DomHelpers.GetIntAttribute(elem, "Priority", 2147483647);
declarativeWebTest.TestElementProperties.Enabled = DomHelpers.GetBoolAttribute(elem, "Enabled", true);
declarativeWebTest.TestElementProperties.Timeout = DomHelpers.GetIntAttribute(elem, "Timeout", 0);
declarativeWebTest.TestElementProperties.CssProjectStructure = DomHelpers.GetStringAttribute(elem, "CssProjectStructure");
declarativeWebTest.TestElementProperties.CssIteration = DomHelpers.GetStringAttribute(elem, "CssIteration");
string[] stringArrayAttribute = DomHelpers.GetStringArrayAttribute(elem, "DeploymentItemsEditable");
if (stringArrayAttribute != null && stringArrayAttribute.Length > 0 && (stringArrayAttribute.Length != 1 || !string.IsNullOrEmpty(stringArrayAttribute[0])))
{
declarativeWebTest.TestElementProperties.DeploymentItemsEditable = stringArrayAttribute;
}
string[] stringArrayAttribute2 = DomHelpers.GetStringArrayAttribute(elem, "TestCategories");
if (stringArrayAttribute2 != null && stringArrayAttribute2.Length > 0 && (stringArrayAttribute2.Length != 1 || !string.IsNullOrEmpty(stringArrayAttribute2[0])))
{
declarativeWebTest.TestElementProperties.TestCategories = stringArrayAttribute2;
}
List<int> intListAttribute = DomHelpers.GetIntListAttribute(elem, "WorkItemIds");
if (intListAttribute != null)
{
declarativeWebTest.TestElementProperties.WorkItemIds = intListAttribute;
}
declarativeWebTest.UserName = DomHelpers.GetStringAttribute(elem, "CredentialUserName");
string text = DomHelpers.GetStringAttribute(elem, "CredentialPassword");
try
{
text = Cryptography.DecodeString(text);
}
catch
{
}
declarativeWebTest.Password = text;
declarativeWebTest.Description = DomHelpers.GetStringAttribute(elem, "Description");
declarativeWebTest.PreAuthenticate = DomHelpers.GetBoolAttribute(elem, "PreAuthenticate", true);
declarativeWebTest.Proxy = DomHelpers.GetStringAttribute(elem, "Proxy");
declarativeWebTest.StopOnError = DomHelpers.GetBoolAttribute(elem, "StopOnError", false);
declarativeWebTest.RecordedResultFile = DomHelpers.GetStringAttribute(elem, "RecordedResultFile", string.Empty);
string stringAttribute3 = DomHelpers.GetStringAttribute(elem, "RequestCallbackClass");
string stringAttribute4 = DomHelpers.GetStringAttribute(elem, "TestCaseCallbackClass");
if (!string.IsNullOrEmpty(stringAttribute3))
{
WebTestPluginReference webTestPluginReference = new WebTestPluginReference();
webTestPluginReference.Class = new WebTestClassName(typeof(WebTestRequestPluginConverter).FullName);
webTestPluginReference.Properties.Add(new PluginOrRuleProperty("ClassName", stringAttribute3));
declarativeWebTest.WebTestPluginReferences.Add(webTestPluginReference);
}
if (!string.IsNullOrEmpty(stringAttribute4))
{
WebTestPluginReference webTestPluginReference2 = new WebTestPluginReference();
webTestPluginReference2.Class = new WebTestClassName(stringAttribute4);
declarativeWebTest.WebTestPluginReferences.Add(webTestPluginReference2);
}
string[] itemTagNames = new string[]
{
"Request",
"IncludedWebTest",
"TransactionTimer",
"Comment",
"Loop",
"Condition"
};
this.GetCollection(elem, "Items", itemTagNames, typeof(WebTestItem), declarativeWebTest.Items);
if (declarativeWebTest.Items.Count == 0)
{
this.GetCollection(elem, "Requests", "Request", typeof(WebTestRequest), declarativeWebTest.Items);
}
this.GetCollection(elem, "DataSources", "DataSource", typeof(DataSource), declarativeWebTest.DataSources);
this.GetCollection(elem, "ContextParameters", "ContextParameter", typeof(ContextParameter), declarativeWebTest.ContextParameters);
this.GetCollection(elem, "ValidationRules", "ValidationRule", typeof(ValidationRuleReference), declarativeWebTest.ValidationRuleReferences);
this.GetCollection(elem, "WebTestPlugins", "WebTestPlugin", typeof(WebTestPluginReference), declarativeWebTest.WebTestPluginReferences);
declarativeWebTest.UpdateItemIds();
return declarativeWebTest;
}
private WebTestRequest CreateRequest(XmlElement elem)
{
WebTestRequest webTestRequest = new WebTestRequest();
webTestRequest.Method = DomHelpers.GetStringAttribute(elem, "Method");
webTestRequest.Version = DomHelpers.GetStringAttribute(elem, "Version");
webTestRequest.Url = DomHelpers.GetStringAttribute(elem, "Url");
webTestRequest.ThinkTime = DomHelpers.GetIntAttribute(elem, "ThinkTime", 0);
webTestRequest.Timeout = DomHelpers.GetIntAttribute(elem, "Timeout", 300);
webTestRequest.ParseDependentRequests = DomHelpers.GetBoolAttribute(elem, "ParseDependentRequests", true);
webTestRequest.FollowRedirects = DomHelpers.GetBoolAttribute(elem, "FollowRedirects", true);
webTestRequest.RecordResult = DomHelpers.GetBoolAttribute(elem, "RecordResult", true);
webTestRequest.Cache = DomHelpers.GetBoolAttribute(elem, "Cache", false);
webTestRequest.ResponseTimeGoal = DomHelpers.GetFloatAttribute(elem, "ResponseTimeGoal", 0f);
webTestRequest.ExpectedHttpStatusCode = DomHelpers.GetIntAttribute(elem, "ExpectedHttpStatusCode", 0);
webTestRequest.ExpectedResponseUrl = DomHelpers.GetStringAttribute(elem, "ExpectedResponseUrl", string.Empty);
webTestRequest.ReportingName = DomHelpers.GetStringAttribute(elem, "ReportingName", string.Empty);
if (string.IsNullOrEmpty(webTestRequest.ExpectedResponseUrl))
{
webTestRequest.ExpectedResponseUrl = DomHelpers.GetStringAttribute(elem, "RecordedResponseUrl", string.Empty);
}
try
{
string stringAttribute = DomHelpers.GetStringAttribute(elem, "Encoding");
webTestRequest.Encoding = Encoding.GetEncoding(stringAttribute);
}
catch (Exception)
{
}
this.GetCollection(elem, "DependentRequests", "Request", typeof(WebTestRequest), webTestRequest.DependentRequests);
this.GetCollection(elem, "Headers", "Header", typeof(WebTestRequestHeader), webTestRequest.Headers);
this.GetCollection(elem, "QueryStringParameters", "QueryStringParameter", typeof(QueryStringParameter), webTestRequest.QueryStringParameters);
this.GetCollection(elem, "ValidationRules", "ValidationRule", typeof(ValidationRuleReference), webTestRequest.ValidationRuleReferences);
this.GetCollection(elem, "ExtractionRules", "ExtractionRule", typeof(ExtractionRuleReference), webTestRequest.ExtractionRuleReferences);
this.GetCollection(elem, "CorrelationExtractionRules", "ExtractionRule", typeof(ExtractionRuleReference), webTestRequest.CorrelationExtractionRuleReferences);
this.GetCollection(elem, "RequestPlugins", "RequestPlugin", typeof(WebTestRequestPluginReference), webTestRequest.WebTestRequestPluginReferences);
XmlElement firstChildElement = DomHelpers.GetFirstChildElement(elem, "FormPostHttpBody");
XmlElement firstChildElement2 = DomHelpers.GetFirstChildElement(elem, "StringHttpBody");
XmlElement firstChildElement3 = DomHelpers.GetFirstChildElement(elem, "BinaryHttpBody");
if (firstChildElement != null)
{
FormPostHttpBody formPostHttpBody = new FormPostHttpBody();
foreach (XmlElement elem2 in DomHelpers.GetChildElements(firstChildElement, "FormPostParameter"))
{
string stringAttribute2 = DomHelpers.GetStringAttribute(elem2, "Name");
string stringAttribute3 = DomHelpers.GetStringAttribute(elem2, "Value");
FormPostParameter formPostParameter = new FormPostParameter(stringAttribute2, stringAttribute3);
formPostParameter.RecordedValue = DomHelpers.GetStringAttribute(elem2, "RecordedValue");
formPostParameter.CorrelationBinding = DomHelpers.GetStringAttribute(elem2, "CorrelationBinding");
formPostParameter.UrlEncode = DomHelpers.GetBoolAttribute(elem2, "UrlEncode", true);
formPostHttpBody.FormPostParameters.Add(formPostParameter);
}
foreach (XmlElement elem3 in DomHelpers.GetChildElements(firstChildElement, "FileUploadParameter"))
{
string stringAttribute4 = DomHelpers.GetStringAttribute(elem3, "Name");
string stringAttribute5 = DomHelpers.GetStringAttribute(elem3, "FileName");
string stringAttribute6 = DomHelpers.GetStringAttribute(elem3, "ContentType");
bool boolAttribute = DomHelpers.GetBoolAttribute(elem3, "GenerateUniqueName", false);
FileUploadParameter fileUploadParameter = new FileUploadParameter(stringAttribute4, stringAttribute5);
fileUploadParameter.ContentType = stringAttribute6;
fileUploadParameter.GenerateUniqueName = boolAttribute;
formPostHttpBody.FormPostParameters.Add(fileUploadParameter);
}
webTestRequest.Body = formPostHttpBody;
}
else
{
if (firstChildElement2 != null)
{
webTestRequest.Body = new StringHttpBody
{
ContentType = DomHelpers.GetStringAttribute(firstChildElement2, "ContentType"),
InsertByteOrderMark = DomHelpers.GetBoolAttribute(firstChildElement2, "InsertByteOrderMark", false),
BodyString = Encoding.Unicode.GetString(Convert.FromBase64String(firstChildElement2.InnerText))
};
}
else
{
if (firstChildElement3 != null)
{
webTestRequest.Body = new BinaryHttpBody
{
ContentType = DomHelpers.GetStringAttribute(firstChildElement3, "ContentType"),
Data = Convert.FromBase64String(firstChildElement3.InnerText)
};
}
}
}
return webTestRequest;
}
private static Comment CreateComment(XmlElement elem)
{
return new Comment(DomHelpers.GetStringAttribute(elem, "CommentText"));
}
private TransactionTimer CreateTransactionTimer(XmlElement elem)
{
TransactionTimer transactionTimer = new TransactionTimer();
transactionTimer.Name = DomHelpers.GetStringAttribute(elem, "Name");
string[] itemTagNames = new string[]
{
"Request",
"IncludedWebTest",
"TransactionTimer",
"Comment",
"Loop",
"Condition"
};
this.GetCollection(elem, "Items", itemTagNames, typeof(WebTestItem), transactionTimer.Items);
return transactionTimer;
}
private IncludedWebTest CreateIncludedWebTest(XmlElement elem)
{
IncludedWebTest includedWebTest = new IncludedWebTest();
includedWebTest.Name = DomHelpers.GetStringAttribute(elem, "Name");
includedWebTest.Path = DomHelpers.GetStringAttribute(elem, "Path");
includedWebTest.TestId = DomHelpers.GetStringAttribute(elem, "Id");
includedWebTest.IsCodedWebTest = DomHelpers.GetBoolAttribute(elem, "IsCodedWebTest", false);
includedWebTest.InheritWebTestSettings = DomHelpers.GetBoolAttribute(elem, "InheritWebTestSettings", false);
if (!string.IsNullOrEmpty(this.m_fileName))
{
includedWebTest.Path = WebTestFrameworkHelperMethods.MakePathAbsolute(includedWebTest.Path, this.m_fileName);
}
return includedWebTest;
}
private WebTestConditionalConstruct CreateLoop(XmlElement elem)
{
XmlElement firstChildElement = DomHelpers.GetFirstChildElement(elem, "ConditionalRule");
LoopConditionalRuleReference conditionalRuleReference = this.CreateLoopConditionalRule(firstChildElement);
WebTestLoop webTestLoop = new WebTestLoop(conditionalRuleReference);
webTestLoop.UniqueStringId = DomHelpers.GetStringAttribute(elem, "UniqueStringId");
string[] itemTagNames = new string[]
{
"Request",
"IncludedWebTest",
"TransactionTimer",
"Comment",
"Loop",
"Condition"
};
this.GetCollection(elem, "Items", itemTagNames, typeof(WebTestItem), webTestLoop.Items);
return webTestLoop;
}
private WebTestConditionalConstruct CreateCondition(XmlElement elem)
{
XmlElement firstChildElement = DomHelpers.GetFirstChildElement(elem, "ConditionalRule");
ConditionConditionalRuleReference conditionalRuleReference = this.CreateConditionConditionalRule(firstChildElement);
WebTestCondition webTestCondition = new WebTestCondition(conditionalRuleReference);
webTestCondition.UniqueStringId = DomHelpers.GetStringAttribute(elem, "UniqueStringId");
string[] itemTagNames = new string[]
{
"Request",
"IncludedWebTest",
"TransactionTimer",
"Comment",
"Loop",
"Condition"
};
XmlElement firstChildElement2 = DomHelpers.GetFirstChildElement(elem, "Then");
if (firstChildElement2 != null)
{
this.GetCollection(firstChildElement2, "Items", itemTagNames, typeof(WebTestItem), webTestCondition.Items);
}
XmlElement firstChildElement3 = DomHelpers.GetFirstChildElement(elem, "Else");
if (firstChildElement3 != null)
{
this.GetCollection(firstChildElement3, "Items", itemTagNames, typeof(WebTestItem), webTestCondition.ElseItems);
}
return webTestCondition;
}
private DataSource CreateDataSource(XmlElement elem)
{
DataSource dataSource = new DataSource();
dataSource.Name = DomHelpers.GetStringAttribute(elem, "Name");
dataSource.BaseDirectory = Path.GetDirectoryName(this.m_fileName);
string stringAttribute = DomHelpers.GetStringAttribute(elem, "Provider", "System.Data.OleDb");
string stringAttribute2 = DomHelpers.GetStringAttribute(elem, "Connection");
try
{
dataSource.SetConnection(stringAttribute, Cryptography.DecodeString(stringAttribute2), DomHelpers.GetStringAttribute(elem, "ConnectionDisplayValue"));
}
catch
{
dataSource.SetConnection(stringAttribute, stringAttribute2);
}
this.GetCollection(elem, "Tables", "DataSourceTable", typeof(DataSourceTable), dataSource.Tables);
return dataSource;
}
private static DataSourceTable CreateDataSourceTable(XmlElement elem)
{
return new DataSourceTable
{
Name = DomHelpers.GetStringAttribute(elem, "Name"),
SelectColumns = (DataBindingSelectColumns)DomHelpers.GetEnumIntAttribute(elem, "SelectColumns", typeof(DataBindingSelectColumns), 1),
AccessMethod = (DataBindingAccessMethod)DomHelpers.GetEnumIntAttribute(elem, "AccessMethod", typeof(DataBindingAccessMethod), 1)
};
}
private static ContextParameter CreateContextParameter(XmlElement elem)
{
return new ContextParameter
{
Name = DomHelpers.GetStringAttribute(elem, "Name"),
Value = DomHelpers.GetStringAttribute(elem, "Value")
};
}
private static WebTestRequestHeader CreateRequestHeader(XmlElement elem)
{
return new WebTestRequestHeader
{
Name = DomHelpers.GetStringAttribute(elem, "Name"),
Value = DomHelpers.GetStringAttribute(elem, "Value")
};
}
private static QueryStringParameter CreateRequestQueryStringParameter(XmlElement elem)
{
return new QueryStringParameter
{
Name = DomHelpers.GetStringAttribute(elem, "Name"),
Value = DomHelpers.GetStringAttribute(elem, "Value"),
RecordedValue = DomHelpers.GetStringAttribute(elem, "RecordedValue"),
CorrelationBinding = DomHelpers.GetStringAttribute(elem, "CorrelationBinding"),
UrlEncode = DomHelpers.GetBoolAttribute(elem, "UrlEncode", true),
UseToGroupResults = DomHelpers.GetBoolAttribute(elem, "UseToGroupResults", false)
};
}
private ValidationRuleReference CreateValidationRule(XmlElement elem)
{
ValidationRuleReference validationRuleReference = new ValidationRuleReference();
validationRuleReference.Class = new WebTestClassName(SerializerUtilities.UpgradeVisualStudioVersionInAssemblyName(DomHelpers.GetStringAttribute(elem, "Classname")));
validationRuleReference.DisplayName = DomHelpers.GetStringAttribute(elem, "DisplayName");
validationRuleReference.Description = DomHelpers.GetStringAttribute(elem, "Description");
validationRuleReference.ValidationLevel = (ValidationLevel)DomHelpers.GetEnumIntAttribute(elem, "Level", typeof(ValidationLevel), 2);
validationRuleReference.ExecutionOrder = (RuleExecutionOrder)DomHelpers.GetEnumIntAttribute(elem, "ExectuionOrder", typeof(RuleExecutionOrder), 1);
this.GetCollection(elem, "RuleParameters", "RuleParameter", typeof(PluginOrRuleProperty), validationRuleReference.Properties);
return validationRuleReference;
}
private ExtractionRuleReference CreateExtractionRule(XmlElement elem)
{
ExtractionRuleReference extractionRuleReference = new ExtractionRuleReference();
extractionRuleReference.Class = new WebTestClassName(SerializerUtilities.UpgradeVisualStudioVersionInAssemblyName(DomHelpers.GetStringAttribute(elem, "Classname")));
extractionRuleReference.DisplayName = DomHelpers.GetStringAttribute(elem, "DisplayName");
extractionRuleReference.Description = DomHelpers.GetStringAttribute(elem, "Description");
extractionRuleReference.ContextParameterName = DomHelpers.GetStringAttribute(elem, "VariableName");
this.GetCollection(elem, "RuleParameters", "RuleParameter", typeof(PluginOrRuleProperty), extractionRuleReference.Properties);
return extractionRuleReference;
}
private ConditionConditionalRuleReference CreateConditionConditionalRule(XmlElement elem)
{
ConditionConditionalRuleReference conditionConditionalRuleReference = new ConditionConditionalRuleReference();
conditionConditionalRuleReference.Class = new WebTestClassName(SerializerUtilities.UpgradeVisualStudioVersionInAssemblyName(DomHelpers.GetStringAttribute(elem, "Classname")));
conditionConditionalRuleReference.DisplayName = DomHelpers.GetStringAttribute(elem, "DisplayName");
conditionConditionalRuleReference.Description = DomHelpers.GetStringAttribute(elem, "Description");
this.GetCollection(elem, "RuleParameters", "RuleParameter", typeof(PluginOrRuleProperty), conditionConditionalRuleReference.Properties);
return conditionConditionalRuleReference;
}
private LoopConditionalRuleReference CreateLoopConditionalRule(XmlElement elem)
{
LoopConditionalRuleReference loopConditionalRuleReference = new LoopConditionalRuleReference();
loopConditionalRuleReference.Class = new WebTestClassName(SerializerUtilities.UpgradeVisualStudioVersionInAssemblyName(DomHelpers.GetStringAttribute(elem, "Classname")));
loopConditionalRuleReference.DisplayName = DomHelpers.GetStringAttribute(elem, "DisplayName");
loopConditionalRuleReference.Description = DomHelpers.GetStringAttribute(elem, "Description");
loopConditionalRuleReference.MaxIterations = DomHelpers.GetIntAttribute(elem, "MaxIterations", -1);
loopConditionalRuleReference.AdvanceDataCursors = DomHelpers.GetBoolAttribute(elem, "AdvanceDataCursors", false);
this.GetCollection(elem, "RuleParameters", "RuleParameter", typeof(PluginOrRuleProperty), loopConditionalRuleReference.Properties);
return loopConditionalRuleReference;
}
private WebTestRequestPluginReference CreateWebTestRequestPlugin(XmlElement elem)
{
WebTestRequestPluginReference webTestRequestPluginReference = new WebTestRequestPluginReference();
webTestRequestPluginReference.Class = new WebTestClassName(DomHelpers.GetStringAttribute(elem, "Classname"));
webTestRequestPluginReference.DisplayName = DomHelpers.GetStringAttribute(elem, "DisplayName");
webTestRequestPluginReference.Description = DomHelpers.GetStringAttribute(elem, "Description");
this.GetCollection(elem, "RuleParameters", "RuleParameter", typeof(PluginOrRuleProperty), webTestRequestPluginReference.Properties);
return webTestRequestPluginReference;
}
private WebTestPluginReference CreateWebTestPlugin(XmlElement elem)
{
WebTestPluginReference webTestPluginReference = new WebTestPluginReference();
webTestPluginReference.Class = new WebTestClassName(DomHelpers.GetStringAttribute(elem, "Classname"));
webTestPluginReference.DisplayName = DomHelpers.GetStringAttribute(elem, "DisplayName");
webTestPluginReference.Description = DomHelpers.GetStringAttribute(elem, "Description");
this.GetCollection(elem, "RuleParameters", "RuleParameter", typeof(PluginOrRuleProperty), webTestPluginReference.Properties);
return webTestPluginReference;
}
private static PluginOrRuleProperty CreateRuleProperty(XmlElement elem)
{
return new PluginOrRuleProperty
{
Name = DomHelpers.GetStringAttribute(elem, "Name"),
Value = DomHelpers.GetStringAttribute(elem, "Value")
};
}
private XmlElement CreateTestCaseElement(XmlDocument doc, DeclarativeWebTest declarativeWebTest)
{
XmlElement xmlElement = doc.CreateElement("WebTest");
xmlElement.SetAttribute("Name", declarativeWebTest.TestElementProperties.Name);
if (declarativeWebTest.Guid == Guid.Empty)
{
declarativeWebTest.Guid = Guid.NewGuid();
}
string value = declarativeWebTest.Guid.ToString();
if (!string.IsNullOrEmpty(value))
{
xmlElement.SetAttribute("Id", value);
}
xmlElement.SetAttribute("Owner", declarativeWebTest.TestElementProperties.Owner);
xmlElement.SetAttribute("Priority", declarativeWebTest.TestElementProperties.Priority.ToString(CultureInfo.InvariantCulture));
xmlElement.SetAttribute("Enabled", declarativeWebTest.TestElementProperties.Enabled.ToString());
xmlElement.SetAttribute("CssProjectStructure", declarativeWebTest.TestElementProperties.CssProjectStructure);
xmlElement.SetAttribute("CssIteration", declarativeWebTest.TestElementProperties.CssIteration);
xmlElement.SetAttribute("Timeout", declarativeWebTest.TestElementProperties.Timeout.ToString(CultureInfo.InvariantCulture));
if (declarativeWebTest.TestElementProperties.DeploymentItemsEditable != null && declarativeWebTest.TestElementProperties.DeploymentItemsEditable.Length != 0)
{
DomHelpers.SetStringArrayAttribute(xmlElement, "DeploymentItemsEditable", declarativeWebTest.TestElementProperties.DeploymentItemsEditable);
}
if (declarativeWebTest.TestElementProperties.TestCategories != null && declarativeWebTest.TestElementProperties.TestCategories.Length != 0)
{
DomHelpers.SetStringArrayAttribute(xmlElement, "TestCategories", declarativeWebTest.TestElementProperties.TestCategories);
}
if (declarativeWebTest.TestElementProperties.WorkItemIds != null)
{
DomHelpers.SetIntListAttribute(xmlElement, "WorkItemIds", declarativeWebTest.TestElementProperties.WorkItemIds);
}
xmlElement.SetAttribute("xmlns", "http://microsoft.com/schemas/VisualStudio/TeamTest/2010");
xmlElement.SetAttribute("Description", declarativeWebTest.Description);
xmlElement.SetAttribute("CredentialUserName", declarativeWebTest.UserName);
xmlElement.SetAttribute("CredentialPassword", Cryptography.EncodeString(declarativeWebTest.Password));
xmlElement.SetAttribute("PreAuthenticate", declarativeWebTest.PreAuthenticate.ToString());
xmlElement.SetAttribute("Proxy", declarativeWebTest.Proxy);
xmlElement.SetAttribute("StopOnError", declarativeWebTest.StopOnError.ToString());
xmlElement.SetAttribute("RecordedResultFile", declarativeWebTest.RecordedResultFile);
this.CreateCollection(doc, xmlElement, "Items", declarativeWebTest.Items);
this.CreateCollection(doc, xmlElement, "DataSources", declarativeWebTest.DataSources);
this.CreateCollection(doc, xmlElement, "ContextParameters", declarativeWebTest.ContextParameters);
this.CreateCollection(doc, xmlElement, "ValidationRules", declarativeWebTest.ValidationRuleReferences);
this.CreateCollection(doc, xmlElement, "WebTestPlugins", declarativeWebTest.WebTestPluginReferences);
return xmlElement;
}
private XmlElement CreateTransactionTimerElement(XmlDocument doc, TransactionTimer transactionTimer)
{
XmlElement xmlElement = doc.CreateElement("TransactionTimer");
xmlElement.SetAttribute("Name", transactionTimer.Name);
this.CreateCollection(doc, xmlElement, "Items", transactionTimer.Items);
return xmlElement;
}
private XmlElement CreateIncludedWebTestElement(XmlDocument doc, IncludedWebTest includedWebTest)
{
XmlElement xmlElement = doc.CreateElement("IncludedWebTest");
string text = includedWebTest.Path;
if (!string.IsNullOrEmpty(this.m_fileName))
{
text = WebTestFrameworkHelperMethods.MakePathRelative(text, Path.GetDirectoryName(this.m_fileName));
}
xmlElement.SetAttribute("Name", includedWebTest.Name);
xmlElement.SetAttribute("Path", text);
xmlElement.SetAttribute("Id", includedWebTest.TestId);
xmlElement.SetAttribute("IsCodedWebTest", includedWebTest.IsCodedWebTest.ToString());
xmlElement.SetAttribute("InheritWebTestSettings", includedWebTest.InheritWebTestSettings.ToString());
return xmlElement;
}
private XmlElement CreateLoopElement(XmlDocument doc, WebTestLoop loop)
{
XmlElement xmlElement = doc.CreateElement("Loop");
xmlElement.SetAttribute("UniqueStringId", loop.UniqueStringId);
xmlElement.AppendChild(this.CreateLoopConditionalRuleElement(doc, loop.LoopConditionalRuleReference));
this.CreateCollection(doc, xmlElement, "Items", loop.Items);
return xmlElement;
}
private XmlElement CreateConditionElement(XmlDocument doc, WebTestCondition condition)
{
XmlElement xmlElement = doc.CreateElement("Condition");
xmlElement.SetAttribute("UniqueStringId", condition.UniqueStringId);
xmlElement.AppendChild(this.CreateConditionConditionalRuleElement(doc, condition.ConditionConditionalRuleReference));
XmlElement xmlElement2 = doc.CreateElement("Then");
this.CreateCollection(doc, xmlElement2, "Items", condition.Items);
xmlElement.AppendChild(xmlElement2);
XmlElement xmlElement3 = doc.CreateElement("Else");
this.CreateCollection(doc, xmlElement3, "Items", condition.ElseItems);
xmlElement.AppendChild(xmlElement3);
return xmlElement;
}
private XmlElement CreateRequestElement(XmlDocument doc, WebTestRequest request)
{
XmlElement xmlElement = doc.CreateElement("Request");
xmlElement.SetAttribute("Method", request.Method);
xmlElement.SetAttribute("Version", request.Version);
xmlElement.SetAttribute("Url", request.Url.ToString());
xmlElement.SetAttribute("ThinkTime", request.ThinkTime.ToString(CultureInfo.InvariantCulture));
xmlElement.SetAttribute("Timeout", request.Timeout.ToString(CultureInfo.InvariantCulture));
xmlElement.SetAttribute("ParseDependentRequests", request.ParseDependentRequests.ToString());
xmlElement.SetAttribute("FollowRedirects", request.FollowRedirects.ToString());
xmlElement.SetAttribute("RecordResult", request.RecordResult.ToString());
xmlElement.SetAttribute("Cache", request.Cache.ToString());
xmlElement.SetAttribute("ResponseTimeGoal", request.ResponseTimeGoal.ToString(CultureInfo.InvariantCulture));
xmlElement.SetAttribute("Encoding", request.Encoding.WebName);
xmlElement.SetAttribute("ExpectedHttpStatusCode", request.ExpectedHttpStatusCode.ToString(CultureInfo.InvariantCulture));
xmlElement.SetAttribute("ExpectedResponseUrl", request.ExpectedResponseUrl);
xmlElement.SetAttribute("ReportingName", request.ReportingName);
this.CreateCollection(doc, xmlElement, "DependentRequests", request.DependentRequests);
this.CreateCollection(doc, xmlElement, "Headers", request.Headers);
this.CreateCollection(doc, xmlElement, "ValidationRules", request.ValidationRuleReferences);
this.CreateCollection(doc, xmlElement, "ExtractionRules", request.ExtractionRuleReferences);
this.CreateCollection(doc, xmlElement, "CorrelationExtractionRules", request.CorrelationExtractionRuleReferences);
this.CreateCollection(doc, xmlElement, "RequestPlugins", request.WebTestRequestPluginReferences);
this.CreateCollection(doc, xmlElement, "QueryStringParameters", request.QueryStringParameters);
if (request.Body != null)
{
if (request.Body is FormPostHttpBody)
{
FormPostHttpBody formPostHttpBody = (FormPostHttpBody)request.Body;
XmlElement xmlElement2 = doc.CreateElement("FormPostHttpBody");
foreach (FormPostParameter current in formPostHttpBody.FormPostParameters)
{
FileUploadParameter fileUploadParameter = current as FileUploadParameter;
if (fileUploadParameter != null)
{
XmlElement xmlElement3 = doc.CreateElement("FileUploadParameter");
xmlElement3.SetAttribute("Name", fileUploadParameter.Name);
xmlElement3.SetAttribute("FileName", fileUploadParameter.FileName);
xmlElement3.SetAttribute("ContentType", fileUploadParameter.ContentType);
xmlElement3.SetAttribute("GenerateUniqueName", fileUploadParameter.GenerateUniqueName.ToString());
xmlElement2.AppendChild(xmlElement3);
}
else
{
XmlElement xmlElement4 = doc.CreateElement("FormPostParameter");
xmlElement4.SetAttribute("Name", current.Name);
xmlElement4.SetAttribute("Value", current.Value);
xmlElement4.SetAttribute("RecordedValue", current.RecordedValue);
xmlElement4.SetAttribute("CorrelationBinding", current.CorrelationBinding);
xmlElement4.SetAttribute("UrlEncode", current.UrlEncode.ToString());
xmlElement2.AppendChild(xmlElement4);
}
}
xmlElement.AppendChild(xmlElement2);
}
else
{
if (request.Body is StringHttpBody)
{
StringHttpBody stringHttpBody = (StringHttpBody)request.Body;
XmlElement xmlElement5 = doc.CreateElement("StringHttpBody");
xmlElement5.SetAttribute("ContentType", stringHttpBody.ContentType);
xmlElement5.SetAttribute("InsertByteOrderMark", stringHttpBody.InsertByteOrderMark.ToString());
if (stringHttpBody.BodyString != null)
{
xmlElement5.InnerText = Convert.ToBase64String(Encoding.Unicode.GetBytes(stringHttpBody.BodyString));
}
xmlElement.AppendChild(xmlElement5);
}
else
{
if (request.Body is BinaryHttpBody)
{
BinaryHttpBody binaryHttpBody = (BinaryHttpBody)request.Body;
XmlElement xmlElement6 = doc.CreateElement("BinaryHttpBody");
xmlElement6.SetAttribute("ContentType", binaryHttpBody.ContentType);
if (binaryHttpBody.Data != null)
{
xmlElement6.InnerText = Convert.ToBase64String(binaryHttpBody.Data);
}
xmlElement.AppendChild(xmlElement6);
}
}
}
}
return xmlElement;
}
private XmlElement CreateDataSourceElement(XmlDocument doc, DataSource dataSource)
{
XmlElement xmlElement = doc.CreateElement("DataSource");
xmlElement.SetAttribute("Name", dataSource.Name);
xmlElement.SetAttribute("Provider", dataSource.Provider);
if (dataSource.Connection != dataSource.ConnectionDisplayValue)
{
xmlElement.SetAttribute("Connection", Cryptography.EncodeString(dataSource.Connection));
xmlElement.SetAttribute("ConnectionDisplayValue", dataSource.ConnectionDisplayValue);
}
else
{
xmlElement.SetAttribute("Connection", dataSource.Connection);
}
this.CreateCollection(doc, xmlElement, "Tables", dataSource.Tables);
return xmlElement;
}
private static XmlElement CreateDataSourceTableElement(XmlDocument doc, DataSourceTable table)
{
XmlElement xmlElement = doc.CreateElement("DataSourceTable");
xmlElement.SetAttribute("Name", table.Name);
xmlElement.SetAttribute("SelectColumns", table.SelectColumns.ToString());
xmlElement.SetAttribute("AccessMethod", table.AccessMethod.ToString());
return xmlElement;
}
private static XmlElement CreateCommentElement(XmlDocument doc, Comment comment)
{
XmlElement xmlElement = doc.CreateElement("Comment");
xmlElement.SetAttribute("CommentText", comment.CommentText);
return xmlElement;
}
private static XmlElement CreateContextParameterElement(XmlDocument doc, ContextParameter parameter)
{
XmlElement xmlElement = doc.CreateElement("ContextParameter");
xmlElement.SetAttribute("Name", parameter.Name);
xmlElement.SetAttribute("Value", parameter.Value);
return xmlElement;
}
private static XmlElement CreateRequestHeaderElement(XmlDocument doc, WebTestRequestHeader header)
{
XmlElement xmlElement = doc.CreateElement("Header");
xmlElement.SetAttribute("Name", header.Name);
xmlElement.SetAttribute("Value", header.Value);
return xmlElement;
}
private static XmlElement CreateRequestQueryStringParameterElement(XmlDocument doc, QueryStringParameter parameter)
{
XmlElement xmlElement = doc.CreateElement("QueryStringParameter");
xmlElement.SetAttribute("Name", parameter.Name);
xmlElement.SetAttribute("Value", parameter.Value);
xmlElement.SetAttribute("RecordedValue", parameter.RecordedValue);
xmlElement.SetAttribute("CorrelationBinding", parameter.CorrelationBinding);
xmlElement.SetAttribute("UrlEncode", parameter.UrlEncode.ToString());
xmlElement.SetAttribute("UseToGroupResults", parameter.UseToGroupResults.ToString());
return xmlElement;
}
private XmlElement CreateValidationRuleElement(XmlDocument doc, ValidationRuleReference rule)
{
XmlElement xmlElement = doc.CreateElement("ValidationRule");
xmlElement.SetAttribute("Classname", rule.Class.FullClassName);
xmlElement.SetAttribute("DisplayName", rule.DisplayName);
xmlElement.SetAttribute("Description", rule.Description);
xmlElement.SetAttribute("Level", rule.ValidationLevel.ToString());
xmlElement.SetAttribute("ExectuionOrder", rule.ExecutionOrder.ToString());
this.CreateCollection(doc, xmlElement, "RuleParameters", rule.Properties);
return xmlElement;
}
private XmlElement CreateExtractionRuleElement(XmlDocument doc, ExtractionRuleReference rule)
{
XmlElement xmlElement = doc.CreateElement("ExtractionRule");
xmlElement.SetAttribute("Classname", rule.Class.FullClassName);
xmlElement.SetAttribute("VariableName", rule.ContextParameterName);
xmlElement.SetAttribute("DisplayName", rule.DisplayName);
xmlElement.SetAttribute("Description", rule.Description);
this.CreateCollection(doc, xmlElement, "RuleParameters", rule.Properties);
return xmlElement;
}
private XmlElement CreateConditionConditionalRuleElement(XmlDocument doc, ConditionConditionalRuleReference rule)
{
XmlElement xmlElement = doc.CreateElement("ConditionalRule");
xmlElement.SetAttribute("Classname", rule.Class.FullClassName);
xmlElement.SetAttribute("DisplayName", rule.DisplayName);
xmlElement.SetAttribute("Description", rule.Description);
this.CreateCollection(doc, xmlElement, "RuleParameters", rule.Properties);
return xmlElement;
}
private XmlElement CreateLoopConditionalRuleElement(XmlDocument doc, LoopConditionalRuleReference rule)
{
XmlElement xmlElement = doc.CreateElement("ConditionalRule");
xmlElement.SetAttribute("Classname", rule.Class.FullClassName);
xmlElement.SetAttribute("DisplayName", rule.DisplayName);
xmlElement.SetAttribute("Description", rule.Description);
xmlElement.SetAttribute("MaxIterations", rule.MaxIterations.ToString(CultureInfo.CurrentCulture));
xmlElement.SetAttribute("AdvanceDataCursors", rule.AdvanceDataCursors.ToString(CultureInfo.CurrentCulture));
this.CreateCollection(doc, xmlElement, "RuleParameters", rule.Properties);
return xmlElement;
}
private XmlElement CreateWebTestRequestPluginElement(XmlDocument doc, WebTestRequestPluginReference plugin)
{
XmlElement xmlElement = doc.CreateElement("RequestPlugin");
xmlElement.SetAttribute("Classname", plugin.Class.FullClassName);
xmlElement.SetAttribute("DisplayName", plugin.DisplayName);
xmlElement.SetAttribute("Description", plugin.Description);
this.CreateCollection(doc, xmlElement, "RuleParameters", plugin.Properties);
return xmlElement;
}
private XmlElement CreateWebTestPluginElement(XmlDocument doc, WebTestPluginReference plugin)
{
XmlElement xmlElement = doc.CreateElement("WebTestPlugin");
xmlElement.SetAttribute("Classname", plugin.Class.FullClassName);
xmlElement.SetAttribute("DisplayName", plugin.DisplayName);
xmlElement.SetAttribute("Description", plugin.Description);
this.CreateCollection(doc, xmlElement, "RuleParameters", plugin.Properties);
return xmlElement;
}
private static XmlElement CreateRulePropertyElement(XmlDocument doc, PluginOrRuleProperty property)
{
XmlElement xmlElement = doc.CreateElement("RuleParameter");
xmlElement.SetAttribute("Name", property.Name);
xmlElement.SetAttribute("Value", property.Value);
return xmlElement;
}
private void GetCollection(XmlElement elem, string collectionTagName, string itemTagName, Type itemType, IList collection)
{
this.GetCollection(elem, collectionTagName, new string[]
{
itemTagName
}, itemType, collection);
}
private void GetCollection(XmlElement elem, string collectionTagName, string[] itemTagNames, Type itemType, IList collection)
{
XmlElement firstChildElement = DomHelpers.GetFirstChildElement(elem, collectionTagName);
if (firstChildElement != null)
{
ArrayList childElements = DomHelpers.GetChildElements(firstChildElement, itemTagNames);
if (childElements.Count > 0)
{
foreach (XmlElement xmlElement in childElements)
{
if (itemType == typeof(WebTestItem))
{
if (xmlElement.Name == "Request")
{
collection.Add(this.CreateRequest(xmlElement));
}
else
{
if (xmlElement.Name == "IncludedWebTest")
{
collection.Add(this.CreateIncludedWebTest(xmlElement));
}
else
{
if (xmlElement.Name == "TransactionTimer")
{
collection.Add(this.CreateTransactionTimer(xmlElement));
}
else
{
if (xmlElement.Name == "Loop")
{
collection.Add(this.CreateLoop(xmlElement));
}
else
{
if (xmlElement.Name == "Condition")
{
collection.Add(this.CreateCondition(xmlElement));
}
else
{
if (xmlElement.Name == "Comment")
{
collection.Add(DeclarativeWebTestSerializer.CreateComment(xmlElement));
}
}
}
}
}
}
}
else
{
if (itemType == typeof(WebTestRequest))
{
collection.Add(this.CreateRequest(xmlElement));
}
else
{
if (itemType == typeof(DataSource))
{
collection.Add(this.CreateDataSource(xmlElement));
}
else
{
if (itemType == typeof(WebTestRequestHeader))
{
collection.Add(DeclarativeWebTestSerializer.CreateRequestHeader(xmlElement));
}
else
{
if (itemType == typeof(QueryStringParameter))
{
collection.Add(DeclarativeWebTestSerializer.CreateRequestQueryStringParameter(xmlElement));
}
else
{
if (itemType == typeof(ContextParameter))
{
collection.Add(DeclarativeWebTestSerializer.CreateContextParameter(xmlElement));
}
else
{
if (itemType == typeof(DataSourceTable))
{
collection.Add(DeclarativeWebTestSerializer.CreateDataSourceTable(xmlElement));
}
else
{
if (itemType == typeof(PluginOrRuleProperty))
{
collection.Add(DeclarativeWebTestSerializer.CreateRuleProperty(xmlElement));
}
else
{
if (itemType == typeof(ValidationRuleReference))
{
collection.Add(this.CreateValidationRule(xmlElement));
}
else
{
if (itemType == typeof(ExtractionRuleReference))
{
collection.Add(this.CreateExtractionRule(xmlElement));
}
else
{
if (itemType == typeof(WebTestRequestPluginReference))
{
collection.Add(this.CreateWebTestRequestPlugin(xmlElement));
}
else
{
if (itemType == typeof(WebTestPluginReference))
{
collection.Add(this.CreateWebTestPlugin(xmlElement));
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
private void CreateCollection(XmlDocument doc, XmlElement elem, string collectionTagName, IList collection)
{
if (collection.Count == 0)
{
return;
}
XmlElement xmlElement = doc.CreateElement(collectionTagName);
elem.AppendChild(xmlElement);
foreach (object current in collection)
{
if (current is WebTestRequest)
{
xmlElement.AppendChild(this.CreateRequestElement(doc, (WebTestRequest)current));
}
else
{
if (current is IncludedWebTest)
{
xmlElement.AppendChild(this.CreateIncludedWebTestElement(doc, (IncludedWebTest)current));
}
else
{
if (current is TransactionTimer)
{
xmlElement.AppendChild(this.CreateTransactionTimerElement(doc, (TransactionTimer)current));
}
else
{
if (current is WebTestLoop)
{
xmlElement.AppendChild(this.CreateLoopElement(doc, (WebTestLoop)current));
}
else
{
if (current is WebTestCondition)
{
xmlElement.AppendChild(this.CreateConditionElement(doc, (WebTestCondition)current));
}
else
{
if (current is DataSource)
{
xmlElement.AppendChild(this.CreateDataSourceElement(doc, (DataSource)current));
}
else
{
if (current is WebTestRequestHeader)
{
xmlElement.AppendChild(DeclarativeWebTestSerializer.CreateRequestHeaderElement(doc, (WebTestRequestHeader)current));
}
else
{
if (current is QueryStringParameter)
{
xmlElement.AppendChild(DeclarativeWebTestSerializer.CreateRequestQueryStringParameterElement(doc, (QueryStringParameter)current));
}
else
{
if (current is ContextParameter)
{
xmlElement.AppendChild(DeclarativeWebTestSerializer.CreateContextParameterElement(doc, (ContextParameter)current));
}
else
{
if (current is DataSourceTable)
{
xmlElement.AppendChild(DeclarativeWebTestSerializer.CreateDataSourceTableElement(doc, (DataSourceTable)current));
}
else
{
if (current is PluginOrRuleProperty)
{
xmlElement.AppendChild(DeclarativeWebTestSerializer.CreateRulePropertyElement(doc, (PluginOrRuleProperty)current));
}
else
{
if (current is ValidationRuleReference)
{
xmlElement.AppendChild(this.CreateValidationRuleElement(doc, (ValidationRuleReference)current));
}
else
{
if (current is ExtractionRuleReference)
{
xmlElement.AppendChild(this.CreateExtractionRuleElement(doc, (ExtractionRuleReference)current));
}
else
{
if (current is WebTestRequestPluginReference)
{
xmlElement.AppendChild(this.CreateWebTestRequestPluginElement(doc, (WebTestRequestPluginReference)current));
}
else
{
if (current is WebTestPluginReference)
{
xmlElement.AppendChild(this.CreateWebTestPluginElement(doc, (WebTestPluginReference)current));
}
else
{
if (current is Comment)
{
xmlElement.AppendChild(DeclarativeWebTestSerializer.CreateCommentElement(doc, (Comment)current));
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}