3 Answers, 1 is accepted
0
Hello Anthony,
I have tried to reproduce the reported issue on our side but with no success. As i am not sure what is your exact scenario for saving the data I would like to ask you to provide us with more information.
I have attached a sample project demonstrating how I am using the CustomPropertyProvider to save the content of a button containing the \r\n Text.
Looking forward to hearing from you.
Kind regards,
Kiril Vandov
Telerik
I have tried to reproduce the reported issue on our side but with no success. As i am not sure what is your exact scenario for saving the data I would like to ask you to provide us with more information.
I have attached a sample project demonstrating how I am using the CustomPropertyProvider to save the content of a button containing the \r\n Text.
Looking forward to hearing from you.
Kind regards,
Kiril Vandov
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items
0
Anthony
Top achievements
Rank 1
answered on 04 Jan 2016, 02:13 PM
(ar.. can't attach zip file here?)
Feel free to use either value1 or value2 in the CustomValueProvider and you will hit an assertion failure
Use the following code
01.
using
System.Diagnostics;
02.
03.
using
Telerik.Windows.Persistence.Services;
04.
05.
namespace
Persistance_CustomIValueProvider
06.
{
07.
public
class
CustomPropertyProvider : IValueProvider
08.
{
09.
private
string
value1 =
"a\r\nb"
;
10.
private
string
value2 =
"\r\n"
;
11.
12.
public
string
ProvideValue(
object
context)
13.
{
14.
return
value1;
15.
}
16.
17.
public
void
RestoreValue(
object
context,
string
savedValue)
18.
{
19.
Debug.Assert(savedValue == value1);
20.
}
21.
}
22.
}
0
Hello Anthony,
Thank you for the provided codesnippet it helped us reproduce the issue on our side. You are not able to attach zip files as this is a forum thread.
We have investigate the issue and we have isolated the problem to how the XmlSerializer saves its date if it is used a StringWriter (it ignores the NewLines) and that is why they are lost during serialization. We have logged that issue in or system and you could track its progress via our feedbackportal. I have also updated your Telerik points as a small appreciation for your cooperation.
The code that the persistance uses internaly is like follows and you can reproduce that issue only using XmlSeruializer and StringWrite:
Please excuse us for any inconvenience caused.
Kind regards,
Kiril Vandov
Telerik
Thank you for the provided codesnippet it helped us reproduce the issue on our side. You are not able to attach zip files as this is a forum thread.
We have investigate the issue and we have isolated the problem to how the XmlSerializer saves its date if it is used a StringWriter (it ignores the NewLines) and that is why they are lost during serialization. We have logged that issue in or system and you could track its progress via our feedbackportal. I have also updated your Telerik points as a small appreciation for your cooperation.
The code that the persistance uses internaly is like follows and you can reproduce that issue only using XmlSeruializer and StringWrite:
...
this
.SerializeAndDeserialize();
}
private
void
SerializeAndDeserialize()
{
Test testClass =
new
Test();
testClass.Header =
"a\r\nb"
;
XmlSerializer serializer =
new
XmlSerializer(
typeof
(Test));
Stream stream =
new
MemoryStream();
stream.Position = 0L;
StreamWriter streamwriter =
new
StreamWriter(stream);
streamwriter.Write(testClass);
serializer.Serialize(stream, testClass);
stream.Position = 0L;
XmlSerializer rawDataSerializer =
new
XmlSerializer(
typeof
(Test));
var rawData2 = rawDataSerializer.Deserialize(stream)
as
Test;
if
(rawData2.Header != testClass.Header)
{
;
}
}
}
public
class
Test
{
private
object
header;
public
object
Header
{
get
{
return
this
.header;
}
set
{
this
.header = value;
}
}
}
}
Please excuse us for any inconvenience caused.
Kind regards,
Kiril Vandov
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items