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); } }
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); } }
public override void GenerateDeserializer(StreamWriter writer, string callName) { var itemCallName = callName + "_ITEM"; writer.Write(@" public static $0 $2(JsonNode parsed) { var value = new List<$1>(); foreach(var x in parsed.ArrayItems()) { value.Add($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); } }