I have some code in some parts of an HTTP request processor when some web requests occur, for example PUT, attached With XML or JSN, I have to convert the payload into different types (or anyway) to see which registered method matches the URL / provider pair.
I VS 2010 and XML, it was straight forward because in the form of a parameter the diasurization method was used. I have the type that I am trying to match in realtime, however, for the JSON conversion, the method is templatized (can be normal - I do not know that well, I usually C ++ I am). Anyway, I can not put variables in type & lt;> expression where there is a time type of compilation.
In addition to this, however, MSDN () shows that JavaScriptSerializer has a Deserialize (string, type) method (), in VS2010, that method does not exist.
The code for JavaScriptSerializer that comes up when I right click and ask for "Go to Definition"
# field assembly system. Web.Extensions.dll, v4.0.30319 // C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework \ .NETFramework \ v4.0 \ Profile \ Mono \ System.Web.Extensions.dll #Using System Tax ingestion; Using System.Collections.Generic; Using System.Text; Namespace System. Web. Script Serialization {public class javascript serializer {public JavaScriptSlIizer ()); Public JavaScript Serializer (JavaScriptTipRostOver Resolver); Public Get MaxJsonLength {Inc.; Set; } Public int recursion limit (get; set;) public T. convertretto type & lt; T & gt; (object obj); Public T Deserialize & lt; T & gt; (String input); Public object DeserializeObject (string input) ; Public Zero RegisterConverter (IEnumerable & lt; JavaScriptConverter & gt; Converters); Public String Serialize (object obj); Public Zero Serialize (object obj, stringbuilder output);}}
I What would you like to do:
The actual type of Jason encoded data is stored in the resource. PayloadType and if I print the resource. PayloadType.Name I see this is correct, however, this desiilize method is not present (for some reason) and I have left this one.
JavaScriptSerializer json_serializer = new JavaScriptSerializer (); Obj payload = json_serializer Deserialize & lt; Resources. Payment Type & gt; (Payload STR);
This is definitely not compiled because you can not enter the variable where the compile time type goes. When I convert using a deserillize object, I hope that instead of typing, I get some kind of generic dictionary class out and there is no conversion between the dictionary and my expectation.
Is the MSDN website wrong? Do other people have a detaerial method that is in .NET 4.0? Do I need to make some updates to get another patch or something?
I am converting my string into a stream and using the DataContractJsonSerializer to replace it, but I think my setup may be incorrect or something it struggles with the MSDN website Or to change one type of variable to one type and & lt;>?
MSDN is correct and the VS2010 setup is incorrect (instead of Mono for installation .NET 4.0). Mono 2.10.8 apparently does not apply to .NET 4 completely and that method is missing.
Switch to the .NET Framework 4. Target Framework for each project. Mono directories can remove DLL references and then add them after changing their structure.
No comments:
Post a Comment