Creating an object data type with the UserControlWrapper
Hi,
I need to create my own datatype and I've read the following articles that have allowed me to get started, but in these examples a List<string> is serialized to XML and stored in Umbraco. I need to store a List<object> where object is my own custom class.
I'm trying to create a multiple choice "Question" document type that has question text as a property and then multiple possible answers, some will be be marked as correct and some will be incorrect. It's the answer part that I want to create as a custom datatype that will sit in my Question document type.
The sample source code from http://www.nibble.be/?p=100 is almost exactly what I need but I don't understand how I could serialize and store a custom answer class with two properties, a string "answer" property and a boolean "isCorrect" property. The source code stores a List of strings.
Has anyone come across a tutorial or blog post that demonstrates this type of approach, or can anyone offer some help?
Hi. List<object> can be serialised-deserialised without problems providing several conditions. Each element of the list should be XML-serialisable itself (i.e. has a public type + a public parameterless constructor) and also the types of the elements should be made known to the serialiser in advance while creating it, e.g.:
var xmlSerializer = new XmlSerializer(typeof(List<object>), new [] { typeof(ElementType1), typeof(ElementType2) });
Creating an object data type with the UserControlWrapper
Hi,
I need to create my own datatype and I've read the following articles that have allowed me to get started, but in these examples a List<string> is serialized to XML and stored in Umbraco. I need to store a List<object> where object is my own custom class.
http://www.nibble.be/?p=24
http://www.nibble.be/?p=100
I'm trying to create a multiple choice "Question" document type that has question text as a property and then multiple possible answers, some will be be marked as correct and some will be incorrect. It's the answer part that I want to create as a custom datatype that will sit in my Question document type.
The sample source code from http://www.nibble.be/?p=100 is almost exactly what I need but I don't understand how I could serialize and store a custom answer class with two properties, a string "answer" property and a boolean "isCorrect" property. The source code stores a List of strings.
Has anyone come across a tutorial or blog post that demonstrates this type of approach, or can anyone offer some help?
Hi. List<object> can be serialised-deserialised without problems providing several conditions. Each element of the list should be XML-serialisable itself (i.e. has a public type + a public parameterless constructor) and also the types of the elements should be made known to the serialiser in advance while creating it, e.g.:
is working on a reply...