Note that there are some explanatory texts on larger screens.

plurals
  1. POC# xml serialization - multiple choices for a property
    primarykey
    data
    text
    <p>I've got a variable failure, that can have three values: passed, failure, or error. What I want to happen during serialization is to create an element based on the value. For passed, I want to ignore the element. For failure I want a failure element. For error, I want an error element. How can this be done?</p> <p>In the class Test, there is a list of Steps called m_steps. In Step there is a variable called m_failure, which holds passed, failure or error. I want the element created by m_steps to be non-element(passed), failure, or error. </p> <pre><code>[XmlRoot("testsuite")] public class Suite { [XmlAttribute("name")] public string m_name; [XmlElement("testcase")] public List&lt;Test&gt; m_tests; [XmlIgnore] public string m_timestamp; public class Test { [XmlAttribute("name")] public string m_name; [XmlElement("failure")] // want to be ignore, failure or error instead of just failure public List&lt;Step&gt; m_steps; [XmlAttribute("assertions")] public int m_assertions; } public class Step { [XmlIgnore] public string m_failure; // holds passed, failure, or error [XmlTextAttribute] public string m_message; [XmlIgnore] public string m_image; [XmlAttribute("type")] public string m_type; } </code></pre> <p>Looking for:</p> <p>To:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; -&lt;testsuite name=" SimpleCalculationsSuite" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; -&lt;testcase name="Add 3+4" assertions="1"&gt;&lt;/testcase&gt; -&lt;testcase name="Fail 3-4" assertions="1"&gt; &lt;failure type="Text"&gt;The control text is not correct. Expected-7 Actual--1&lt;/failure&gt; &lt;/testcase&gt; -&lt;testcase name="Error 3*4" assertions="1"&gt; &lt;error type="Click"&gt;The * button was not found&lt;/error&gt; &lt;/testsuite&gt; </code></pre> <p>From:</p> <pre><code>Suite: SimpleCalculationsSuite Test:Add 3+4 Passed:Text:The control text, 7, is correct. Test:Fail 3-4 Failed:Text:The control text is not correct. Expected-7 Actual--1 Test:Error 3*4 Error:Click: The * button was not found </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload