halitpeker / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 0 forks source link

Changes to build JSON serializer with Silverlight #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I made some changes to the code to be able to build with Silverlight (see files 
attached). I haven't tested it yet. I haven't been able to find how to convert 
from UTF-32 to UTF-16 and there are also these 2 points I'm not sure about:

return value => char.Parse(value);
(is equivalent to)?
char cValue;
return (value) => char.TryParse(value, out cValue)? cValue : '\0';

var unicodeCharArray = json.ToCharArray(index, 4);
(is equivalent to)?
var unicodeCharArray = json.Substring(index, 4).ToCharArray();

Thank you,
Eric.

Original issue reported on code.google.com by i...@hushmail.me on 18 Aug 2010 at 8:11

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Eric,

Thanks for the updates! 

I've decided to refactor the current code-base to incorporate your changes 
rather than maintaining multiple #if/defs everywhere since it makes the code 
cleaner, no need for special build flags and the same code paths get tested etc.

Yeah I consider both snippets to be effectively equivalent - my guess is the 
first one would've thrown an exception if the parsed failed. 

I ended up copying mono's ConvertFromUtf32 implementation so unicode escaping 
should now hopefully work in Silveright.

I believe I've incorporated and checked in all of your changes let me know if 
I've missed any.

Cheers,
Demis

Original comment by demis.be...@gmail.com on 19 Aug 2010 at 2:00

GoogleCodeExporter commented 9 years ago
Thank you for updating your code. However there's a static class, 
FormatterServices in System.Runtime.Serialization, that is not accessible in 
Silverlight and that you use at line 283 in file ReflectionExtensions.cs.

Original comment by i...@hushmail.me on 19 Aug 2010 at 5:41

GoogleCodeExporter commented 9 years ago
Yeah that's a problem as I need that to support anonymous types. So I've had to 
put a #if/def around it.

Original comment by demis.be...@gmail.com on 19 Aug 2010 at 3:58

GoogleCodeExporter commented 9 years ago

Original comment by demis.be...@gmail.com on 28 Aug 2010 at 8:53