/// <summary> /// Returns a string representation of the storage. /// </summary> public virtual PhpString serialize() { // x:{count_int};{item0},{value0};;...;;m:{members_array} var result = new PhpString(); var serializer = PhpSerialization.PhpSerializer.Instance; // x:i:{count}; result.Append("x:"); result.Append(serializer.Serialize(_ctx, (PhpValue)storage.Count, default(RuntimeTypeHandle))); // {item},{value}; using (var e = storage.GetFastEnumerator()) while (e.MoveNext()) { result.Append(serializer.Serialize(_ctx, e.CurrentValue.Array[Keys.Object], default(RuntimeTypeHandle))); result.Append(","); result.Append(serializer.Serialize(_ctx, e.CurrentValue.Array[Keys.Info], default(RuntimeTypeHandle))); result.Append(";"); } // m:{array of runtime members} result.Append("m:"); result.Append(serializer.Serialize(_ctx, (PhpValue)(__peach__runtimeFields ?? PhpArray.Empty), default(RuntimeTypeHandle))); // return(result); }
public PhpString Serialize(PhpValue value) { _output = new PhpString(); _indent = 0; // Accept(value); _output.Append(_nl); return(_output); }
void Write(string str) => _result.Append(str);
void OutputIndent() { if (_indent > 0) { _output.Append(new string(' ', _indent * IndentSize)); } }
protected void NewLine() => _output.Append(_nl);