/// <summary> /// Encode the changes in the IPofValue hierarchy recursively. /// </summary> /// <param name="writer"> /// DataWriter to write changes into. /// </param> /// <param name="value"> /// POF value to encode. /// </param> /// <param name="pos"> /// Current position in the original POF stream. /// </param> /// <returns> /// Current position in the original POF stream. /// </returns> protected virtual int EncodeValue(DataWriter writer, AbstractPofValue value, int pos) { if (value.IsDirty) { int of = value.Offset; if (pos < of) { CopyFromOriginal(writer, pos, of - pos); } value.GetSerializedValue().WriteTo(writer); pos = of + value.Size; } else if (value is ComplexPofValue) { IEnumerator en = ((ComplexPofValue)value).GetChildrenEnumerator(); while (en.MoveNext()) { var entry = (DictionaryEntry)en.Current; pos = EncodeValue(writer, (AbstractPofValue)entry.Value, pos); } } // else if SimplePofValue: handled by IsDirty block return(pos); }
/// <summary> /// Encode the changes in the IPofValue hierarchy recursively. /// </summary> /// <param name="writer"> /// DataWriter to write changes into. /// </param> /// <param name="value"> /// POF value to encode. /// </param> /// <param name="pos"> /// Current position in the original POF stream. /// </param> /// <returns> /// Current position in the original POF stream. /// </returns> protected virtual int EncodeValue(DataWriter writer, AbstractPofValue value, int pos) { if (value.IsDirty) { int of = value.Offset; if (pos < of) { WriteExtract(writer, 0, pos, of - pos); } byte[] ab = value.GetSerializedValue().ToByteArray(); WriteAppend(writer, 0, ab, 0, ab.Length); pos = of + value.Size; } else if (value is ComplexPofValue) { IEnumerator en = ((ComplexPofValue)value).GetChildrenEnumerator(); while (en.MoveNext()) { var entry = (DictionaryEntry)en.Current; pos = EncodeValue(writer, (AbstractPofValue)entry.Value, pos); } } // else if SimplePofValue: handled by isDirty block return(pos); }