Beispiel #1
0
        /// <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));
        }
Beispiel #2
0
 protected void NewLine() => _output.Append(_nl);
Beispiel #3
0
 void Write(string str) => _result.Append(str);