Using Json Serializer, how do i create an instance factory for the ArrayList of Pixels?
Deseriaize:
public static Matrix DeserializeMatrix(string data)
{
if (data.Length > 0)
{
Matrix matrix = (Matrix)JsonConverter.DeserializeObject(data, typeof(Matrix), CreateInstance);
return matrix;
}
return null;
}
Instance
private static object CreateInstance(string instancePath, JToken token, Type baseType, string fieldName, int length)
{
}
Class
public class Matrix : Base
{
public string Name { get; set; }
public ArrayList Pixels { get; set; }
}
public struct Pixel
{
public int Index;
public byte Red;
public byte Green;
public byte Blue;
}