本文整理汇总了C#中Configuration.BuildFromXml方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.BuildFromXml方法的具体用法?C# Configuration.BuildFromXml怎么用?C# Configuration.BuildFromXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.BuildFromXml方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Integrity
/// <summary>
/// Creates a new Integrity instance to query upon. Entry point to the API
/// </summary>
/// <param name="user">Username</param>
/// <param name="password">Password</param>
/// <param name="service_url">URL For Integrity instance, eg "http://integrity.myhost.com"</param>
///
public Integrity(string user, string password, string service_url)
{
_integrity_service = new IntegrityHttpService(service_url, user, password);
_configuration = new Configuration();
_configuration.BuildFromXml(_integrity_service.GetConfiguration());
_integrity_interface = new IntegrityInterface(ref _integrity_service);
}
示例2: GetDatasetViaInvalidName
public void GetDatasetViaInvalidName()
{
Configuration configuration = new Configuration();
string xmlConfig = @"<user-access-group-authorisation><datasets type=""array"">
<dataset><id>9</id>
<name>people</name>
<is-bulk-allowed>false</is-bulk-allowed>
<is-incremental-allowed>true</is-incremental-allowed>
<table-name>dataset_name</table-name>
<qualifiers type=""array""/></dataset>
</datasets></user-access-group-authorisation>";
configuration.BuildFromXml(xmlConfig);
configuration.GetDataset("staff");
}
示例3: GetDatasetViaId
public void GetDatasetViaId()
{
Configuration configuration = new Configuration();
string xmlConfig = @"<user-access-group-authorisation><datasets type=""array"">
<dataset><id>9</id>
<name>people</name>
<is-bulk-allowed>false</is-bulk-allowed>
<is-incremental-allowed>true</is-incremental-allowed>
<table-name>dataset_name</table-name>
<qualifiers type=""array""/></dataset>
</datasets></user-access-group-authorisation>";
configuration.BuildFromXml(xmlConfig);
IntegrityDataset dataset = configuration.GetDataset("people");
Assert.AreEqual(9, dataset.m_id);
}
示例4: UploadAttemptIncrementalTest
public void UploadAttemptIncrementalTest()
{
string xml = @"<user-access-group-authorisation><name>beyond sync</name><datasets type=""array""><dataset><id>45</id><name>accreditation type</name><is-bulk-allowed>false</is-bulk-allowed><is-incremental-allowed>true</is-incremental-allowed><table-name>ct_accreditation_type</table-name><qualifiers type=""array""><qualifier><dataset-attribute-name>rtp</dataset-attribute-name><valid-values type=""array""><valid-value>83</valid-value><valid-value>90</valid-value></valid-values></qualifier></qualifiers><dataset-formats type=""array""><dataset-format><name>xml</name><parser-type>xml</parser-type></dataset-format></dataset-formats></dataset><dataset><id>12</id><name>accreditation level</name><is-bulk-allowed>false</is-bulk-allowed><is-incremental-allowed>false</is-incremental-allowed><table-name>ct_accreditation_level</table-name><qualifiers type=""array""></qualifiers><dataset-formats type=""array""><dataset-format><name>csv</name><parser-type>csv</parser-type></dataset-format></dataset-formats></dataset><dataset><id>11</id><name>accreditation</name><is-bulk-allowed>false</is-bulk-allowed><is-incremental-allowed>false</is-incremental-allowed><table-name>ct_accreditation_level</table-name><qualifiers type=""array""></qualifiers><dataset-formats type=""array""><dataset-format><name>xml</name><parser-type>xml</parser-type></dataset-format></dataset-formats></dataset><dataset><id>31</id><name>ds 01</name><is-bulk-allowed>false</is-bulk-allowed><is-incremental-allowed>true</is-incremental-allowed><table-name>ct_accreditation_level</table-name><qualifiers type=""array""><qualifier><dataset-attribute-name>qual</dataset-attribute-name><valid-values type=""array""><valid-value>11</valid-value><valid-value>54</valid-value></valid-values></qualifier><qualifier><dataset-attribute-name>qual2</dataset-attribute-name><valid-values type=""array""><valid-value>1</valid-value><valid-value>5</valid-value></valid-values></qualifier></qualifiers><dataset-formats type=""array""><dataset-format><name>xml</name><parser-type>xml</parser-type></dataset-format></dataset-formats></dataset></datasets></user-access-group-authorisation>";
Configuration configuration = new Configuration();
configuration.BuildFromXml(xml);
string fileXml = null;
fileXml = "<rows><row><id>12</id><control_code>110</control_code></row></rows>";
IntegrityDataset _dataset = configuration.GetDataset(45);
DatasetFormat _format = _dataset.m_dataset_formats.Find(c => c.name == "xml");
UploadAttempt _uploadAttempt = new UploadAttempt(_dataset, configuration.GetQualifiersForDataset(45), ref fileXml, _format, UploadAttempt.Type.Incremental);
string resultXml = null;
resultXml = _uploadAttempt.BuildAttemptXml();
StringAssert.AreEqualIgnoringCase("RTP", ((Qualifier)_uploadAttempt.Qualifiers.ToArray().GetValue(0)).AttributeName);
string expectedXML = null;
expectedXML = "<upload-attempt><dataset-name>Accreditation Type</dataset-name><format-name>XML</format-name><bulk-or-incremental>incremental</bulk-or-incremental><qualifiers type=\"array\"><qualifier><dataset-attribute-name>RTP</dataset-attribute-name><qualifier-values type=\"array\"><qualifier-value>83</qualifier-value><qualifier-value>90</qualifier-value></qualifier-values></qualifier></qualifiers><file><![CDATA[<rows><row><id>12</id><control_code>110</control_code></row></rows>]]></file></upload-attempt>";
StringAssert.AreEqualIgnoringCase(expectedXML, resultXml);
}
示例5: EmptyConfiguration
public void EmptyConfiguration()
{
Configuration _configuration = new Configuration();
_configuration.BuildFromXml("<user-access-group-authorisation><datasets type=\"array\"/></user-access-group-authorisation>");
Assert.AreEqual(_configuration.m_Datasets.Count, 0);
}
示例6: SingleDatasetConfiguration
public void SingleDatasetConfiguration()
{
Configuration _configuration = new Configuration();
_configuration.BuildFromXml("<user-access-group-authorisation><datasets type=\"array\">" + "<dataset><id>9</id><name>Dataset name</name><is-bulk-allowed>false</is-bulk-allowed>" + "<is-incremental-allowed>true</is-incremental-allowed><table-name>dataset_name</table-name>" + "<qualifiers type=\"array\"/></dataset></datasets></user-access-group-authorisation>");
Assert.AreEqual(_configuration.m_Datasets.Count, 1);
}
示例7: GetDatasetWithFormatsWithLowercaseParserTypes
public void GetDatasetWithFormatsWithLowercaseParserTypes()
{
Configuration _configuration = new Configuration();
string xmlConfig = @"<user-access-group-authorisation>
<datasets type=""array"">
<dataset><id>9</id>
<name>people</name>
<is-bulk-allowed>false</is-bulk-allowed>
<is-incremental-allowed>true</is-incremental-allowed>
<table-name>dataset_name</table-name>
<qualifiers type=""array""/>
<dataset-formats type=""array"">
<dataset-format>
<name>Countries CSV</name>
<parser-type>csv</parser-type>
</dataset-format>
<dataset-format>
<name>Countries XML</name>
<parser-type>xml</parser-type>
</dataset-format>
</dataset-formats>
</dataset>
</datasets>
</user-access-group-authorisation>";
_configuration.BuildFromXml(xmlConfig);
IntegrityDataset _dataset = _configuration.GetDataset(9);
Assert.AreEqual(_dataset.m_dataset_formats.Count, 2);
DatasetFormat csv_format = (DatasetFormat)_dataset.m_dataset_formats.Find(c => c.name == "Countries CSV");
Assert.NotNull(csv_format);
Assert.AreEqual(csv_format.type, DatasetFormat.Type.CSV);
DatasetFormat xml_format = (DatasetFormat)_dataset.m_dataset_formats.Find(c => c.name == "Countries XML");
Assert.NotNull(xml_format);
Assert.AreEqual(xml_format.type, DatasetFormat.Type.XML);
}