public override void GenerateDeserializer(StreamWriter writer, string callName)
        {
            var itemCallName = callName + "_ITEM";

            writer.Write(@"
public static $0 $2(ListTreeNode<JsonValue> parsed)
{
    var value = new $1[parsed.GetArrayCount()];
    int i=0;
    foreach(var x in parsed.ArrayItems())
    {
        value[i++] = $3;
    }
	return value;
} 
"
                         .Replace("$0", JsonSchemaAttribute.GetTypeName(ValueType))
                         .Replace("$1", m_inner.ValueType.Name)
                         .Replace("$2", callName)
                         .Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x"))
                         );

            if (!m_inner.IsInline)
            {
                m_inner.GenerateDeserializer(writer, itemCallName);
            }
        }
Exemple #2
0
        public override void GenerateDeserializer(StreamWriter writer, string callName)
        {
            var itemCallName = callName + "_ITEM";

            writer.Write(@"
 
public static $0 $2(ListTreeNode<JsonValue> parsed)
{
    var value = new Dictionary<string, $1>();
    foreach(var kv in parsed.ObjectItems())
    {
        value.Add(kv.Key.GetString(), $3);
    }
	return value;
}
"
                         .Replace("$0", JsonSchemaAttribute.GetTypeName(ValueType))
                         .Replace("$1", m_inner.ValueType.Name)
                         .Replace("$2", callName)
                         .Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "kv.Value"))
                         );

            if (!m_inner.IsInline)
            {
                m_inner.GenerateDeserializer(writer, itemCallName);
            }
        }
Exemple #3
0
        public override void GenerateDeserializer(StreamWriter writer, string callName)
        {
            var itemCallName = callName + "_LIST";

            writer.Write(@"
public static $0 $2(ListTreeNode<JsonValue> parsed)
{
    var value = new List<$1>();
    foreach(var x in parsed.ArrayItems())
    {
        value.Add($3);
    }
	return value;
}"
                         .Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType))
                         .Replace("$1", m_inner.ValueType.Name)
                         .Replace("$2", callName)
                         .Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x"))
                         );

            if (!m_inner.IsInline)
            {
                m_inner.GenerateDeserializer(writer, itemCallName);
            }
        }