//------------------------------------------------------------------------ void SerializeArray(SLJsonWriter writer) { writer.BeginArray(); foreach (SLJsonNode n in this) { n.Serialize(writer); } writer.EndArray(); }
void SerializeArray(SLJsonWriter writer, Type type, object array, bool asObject) { if (type.IsArray && type.GetArrayRank() != 1) { throw new NotSupportedException("Multi-dimensional arrays are not supported"); } if (!typeof(IEnumerable).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) { throw new NotSupportedException("Type " + type.FullName + " does not implement IEnumerable"); } if (array == null) { writer.WriteValue(null); return; } writer.BeginArray(); var helper = (IEnumerable)array; foreach (object value in helper) { if (asObject) { SerializeObject(writer, value); } else { SerializeValue(writer, type, value); } } writer.EndArray(); }