/// <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.Blob(); var serializer = PhpSerialization.PhpSerializer.Instance; // x:i:{count}; result.Append("x:"); result.Append(serializer.Serialize(_ctx, storage.Count, default)); // {item},{value}; using (var e = storage.GetFastEnumerator()) while (e.MoveNext()) { result.Append(serializer.Serialize(_ctx, e.CurrentValue.Array[Keys.Object], default)); result.Append(","); result.Append(serializer.Serialize(_ctx, e.CurrentValue.Array[Keys.Info], default)); result.Append(";"); } // m:{array of runtime members} result.Append("m:"); result.Append(serializer.Serialize(_ctx, (__peach__runtimeFields ?? PhpArray.Empty), default)); // return(new PhpString(result)); }
public virtual PhpString Serialize(PhpValue value) { _output = new PhpString.Blob(); _indent = 0; // Accept(value); return(new PhpString(_output)); }
/// <summary> /// Gets substring of this instance. /// The operation safely maintains single byte and unicode characters, and reuses existing underlaying chunks of text. /// </summary> /// <exception cref="ArgumentOutOfRangeException">The start index is less than zero.</exception> public static PhpString Substring(this PhpString str, int startIndex, int length) { if (str.IsDefault || length <= 0) { return(default(PhpString)); // FALSE } // var blob = new PhpString.Blob(); str.CopyTo(blob, startIndex, length); return(new PhpString(blob)); }
public PrettyPrintOn(PhpString.Blob output) { _output = output ?? throw new ArgumentNullException(); }