Page 1 of 1

custom serialization

Posted: Fri Aug 04, 2006 12:36 pm
by sprucely
Hello,

When I serialize a report template, I serialize it as part of a larger object that contains additional serializable objects. (Some of my classes implement IXmlSerializable) Currently, my class stores the serialized template as a string. But this results in ugly and difficult-to-read XML for the section that contains the template string:


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<StiSerializer version="1.0" application="StiReport">
<Dictionary Ref="1" type="Dictionary" isKey="true">
</Dictionary>...

...</StiSerializer>








Do you have any suggestions? Is there a field in StiReport in which I may store my own serializable objects?

Thanks,

Spruce

custom serialization

Posted: Sat Aug 05, 2006 11:51 am
by Vital
I have seen only one way:

You can create class derived from StiReport.

Code: Select all

public MyReport : StiReport
{

private string myProp = string.Empty;
[StiSerializable]
[DefaultValue(string.Empty)]
[Browsable(false)]
public string MyProp 
{
	get
	{
		return myProp ;
	}
	set
	{
		myProp = value;
	}
}
after then you need assign type of your report to static property of StiReport:

Code: Select all

StiReport.ReportType = typeof(MyReport);
after then report designer will be use your type of report.

Thanks.

custom serialization

Posted: Mon Aug 07, 2006 11:07 am
by sprucely
That tip was helpful, thanks.

Will StiSerializer work on a complex object that implements IXmlSerializable?

custom serialization

Posted: Mon Aug 07, 2006 3:28 pm
by Vital
Sorry, StiSerializer does not support IXmlSerializable.

Thanks.