/// <summary>Create a formatter that just add or remove a prefix to values</summary> public static ITupleFormatter <T> CreateAppender(IFdbTuple prefix) { if (prefix == null) { throw new ArgumentNullException("prefix"); } return(new FdbAnonymousTupleFormatter <T>( (value) => prefix.Append <T>(value), (tuple) => { if (tuple.Count != prefix.Count + 1) { throw new ArgumentException("Tuple size is invalid", "tuple"); } if (!FdbTuple.StartsWith(tuple, prefix)) { throw new ArgumentException("Tuple does not start with the expected prefix", "tuple"); } return tuple.Last <T>(); } )); }
/// <summary>Returns the key of a specific field of an HashSet: (subspace, id, field, )</summary> /// <param name="id"></param> /// <param name="field"></param> /// <returns></returns> protected virtual Slice GetFieldKey(IFdbTuple id, string field) { //REVIEW: should the id be encoded as a an embedded tuple or not? return this.Subspace.Keys.Pack(id.Append(field)); }
public FdbPrefixedTuple Append <R>(R value) { return(new FdbPrefixedTuple(m_prefix, m_items.Append <R>(value))); }
/// <summary>Returns the key of a specific field of an HashSet: (subspace, id, field, )</summary> /// <param name="id"></param> /// <param name="field"></param> /// <returns></returns> protected virtual Slice GetFieldKey(IFdbTuple id, string field) { //REVIEW: should the id be encoded as a an embedded tuple or not? return(this.Subspace.Keys.Pack(id.Append(field))); }