I have the following class structure. If I use the same assembly of contracts (assembly with all data classes n other stuff) used by api, I am unable to deserialize it in my application.
But I need to remove the dependency of that assembly. So I created another assembly with same namespace and contracts.
Example: I have many parts, and I can have a car out of those parts or a motorcycle.
public class Car
{
public string Name {get; set;}
public Dictionary<string,Part> SpareParts {get; set;}
}
public class Part
{
public string PartName {get; set;}
public object Value {get;set;}
public string Type {get;set}
}
Now, I have a Generic Query request and response
public class QueryRequest
{
//Stuff.. Request works fine.. i get a response
}
public class QueryResponse
{
public QueryResult[] Result;
}
public classs QueryResult
{
//Other details like entity name n stuff for car or motorcycle etc.
public Part[] Parts;
}
Remember that Part Class with Value field, that contains List It goes like this
public class abstract Spoke
{
}
public class Spoke1 : Spoke
{
}
public class Spoke2 : Spoke
{
}
In my response I get this weird serialized string
"Value": {
"$type": "System.Collections.Generic.List`1[[namespace.Spoke, namespace]], mscorlib",
"$values": [
{
"$type": "namespace.spoke2, namespace",
//Other Properties of spoke2
}]
}
EDIT: I get the data in format of QueryResponse
which contains QueryResult
n Parts
I m using Newtonsoft.Json, Any ideas how to deserialize that into my namespace2.Spoke I have the whole contract copied in another assembly. I have tried changing the namespace same as in response but doesn't work.
Any suggestions of help please.