private void AppendVPack(VPackSlice value) { byte[] vpack = value.GetRawVPack(); this.EnsureCapacity(this.size + vpack.Length); Array.Copy(vpack, 0, this.buffer, this.size, vpack.Length); this.size += vpack.Length; }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (this.GetType() != obj.GetType()) { return(false); } VPackSlice other = (VPackSlice)obj; if (this.start != other.start) { return(false); } if (!this.GetRawVPack().SequenceEqual(other.GetRawVPack())) { return(false); } return(true); }
/// <exception cref="VPackBuilderException"/> private VPackBuilder AddInternal <T>(string attribute, IAppender <T> appender, T value) { if (attribute != null) { bool haveReported = false; if (this.stack.Count > 0) { byte head = this.Head(); if (head != 0x0b && head != 0x14) { throw new VPackBuilderNeedOpenObjectException(); } if (this.keyWritten) { throw new VPackBuilderKeyAlreadyWrittenException(); } this.ReportAdd(); haveReported = true; } try { if (VPackSlice.attributeTranslator != null) { VPackSlice translate = VPackSlice.attributeTranslator.Translate(attribute); if (translate != null) { byte[] trValue = translate.GetRawVPack(); this.EnsureCapacity(this.size + trValue.Length); for (int i = 0; i < trValue.Length; i++) { this.AddUnchecked(trValue[i]); } this.keyWritten = true; if (value == null) { this.AppendNull(); } else { appender.Append(this, value); } return(this); } } // otherwise fall through to regular behavior STRING.Append(this, attribute); this.keyWritten = true; if (value == null) { this.AppendNull(); } else { appender.Append(this, value); } } catch (VPackBuilderException e) { // clean up in case of an exception if (haveReported) { this.CleanupAdd(); } throw; } finally { this.keyWritten = false; } } else { this.AddInternal(appender, value); } return(this); }