|
using System;
using System.Xml;
using System.Xml.Serialization;
using System.Collections;
using System.Collections.Specialized;
namespace NDocBook.Test
{
using TestWrapper;
/// <summary>
/// Summary description for testclass.
/// </summary>
public class dummyclass
{
public string testfield = null;
public int intfield = 1;
public dummyclasssecond second = null;
}
public class dummyclasssecond
{
public int id;
}
public class DummyClassSecond
{
private dummyclasssecond wrapped;
public DummyClassSecond()
{
wrapped = new dummyclasssecond();
}
public dummyclasssecond Wrapped
{
get
{
if (this.wrapped==null)
this.wrapped = new dummyclasssecond();
return this.wrapped;
}
}
}
/// <summary>
/// Summary description for testclass.
/// </summary>
public class DummyClass
{
private dummyclass wrapped;
public DummyClass(dummyclass wrapped)
{
if (wrapped==null)
throw new ArgumentNullException("wrapped");
this.wrapped = wrapped;
}
public DummyClass(string testfield, DummyClassSecond second)
{
if (testfield==null)
throw new ArgumentNullException("testfield");
if (second==null)
throw new ArgumentNullException("second");
this.wrapped = new dummyclass();
this.wrapped.testfield = testfield;
this.wrapped.second = second.Wrapped;
}
public dummyclass Wrapped
{
get
{
return this.wrapped;
}
}
public string TestField
{
get
{
return this.wrapped.testfield;
}
set
{
if (value==null)
throw new ArgumentException();
this.wrapped.testfield = value;
}
}
public int IntField
{
get
{
return this.wrapped.intfield;
}
set
{
this.wrapped.intfield = value;
}
}
}
public class ilTests
{
public static void SimpleTest()
{
XmlSerializer ser = new XmlSerializer(typeof(TestClass));
TestClassSecond second = new TestClassSecond();
TestClass ts = new TestClass();
ts.IntField = 10;
int i = ts.IntField;
ts.StringField = "hello";
string s=ts.StringField;
ts.NonNullStringField = "non null";
s = ts.NonNullStringField;
for (int j=0;j<10;++j)
ts.Ints.Add(j);
ts.Multi = 10;
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
Console.WriteLine();
ser.Serialize(writer,ts);
Console.WriteLine();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).