Serialize properties
This commit is contained in:
1 parent
1698c1b027
commit
af88bb2161
3 files changed
+163
-87
No files matched your search
@@ -56,6 +56,21 @@ namespace VocaluxeTests
|
||||
[XmlElement("Entry")] public SEntry[] Ints;
|
||||
public int J;
|
||||
}
|
||||
|
||||
private struct SProperty
|
||||
{
|
||||
[XmlIgnore] public int Private;
|
||||
// ReSharper disable UnusedMember.Local
|
||||
public int Public
|
||||
{
|
||||
get { return Private - 1; }
|
||||
set { Private = value + 1; }
|
||||
}
|
||||
// ReSharper restore UnusedMember.Local
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||
public int Auto { get; set; }
|
||||
// ReSharper restore UnusedAutoPropertyAccessor.Local
|
||||
}
|
||||
#pragma warning restore 169
|
||||
#pragma warning restore 649
|
||||
|
||||
@@ -285,6 +300,22 @@ namespace VocaluxeTests
|
||||
_AssertFail<XmlException>(() => xml.DeserializeString<SArrayEmb>(_Empty));
|
||||
}
|
||||
|
||||
private const string _XmlProperty = _Head + @"<root>
|
||||
<Public>2</Public>
|
||||
<Auto>3</Auto>
|
||||
</root>";
|
||||
|
||||
[TestMethod]
|
||||
public void TestProperty()
|
||||
{
|
||||
var xml = new CXmlSerializer();
|
||||
SProperty foo = xml.DeserializeString<SProperty>(_XmlProperty);
|
||||
Assert.AreEqual(3, foo.Private);
|
||||
Assert.AreEqual(3, foo.Auto);
|
||||
string newXml = xml.Serialize(foo);
|
||||
Assert.AreEqual(_XmlProperty, newXml);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestRealFiles()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user