/// <summary> /// Deserializes and returns the object's value, using the provided deserializer. /// </summary> /// <typeparam name="T">The value's target type.</typeparam> /// <param name="deserializeObject">A delegate to handle deserialization of an byte[] serialized object to it's original type.</param> /// <param name="resolveConflict"> /// A delegate to handle resolution of sibling objects. /// Takes all the sibling objects as input and returns one "resolved" object. /// </param> /// <returns>The deserialized value.</returns> public T GetObject <T>(DeserializeObject <T> deserializeObject, ResolveConflict <T> resolveConflict = null) { if (deserializeObject == null) { throw new ArgumentException("deserializeObject must not be null"); } if (Siblings.Count > 1 && resolveConflict != null) { var conflictedObjects = Siblings.Select(s => deserializeObject(s.Value, ContentType)).ToList(); return(resolveConflict(conflictedObjects)); } return(deserializeObject(Value, ContentType)); }
public async Task <IHttpActionResult> Get(HttpRequestMessage req, string key) { try { Siblings siblings = await _node.GetAsync(key); // Only return the values (strip-off the clocks) List <JToken> values = siblings.Select(s => s.Value).ToList(); HttpResponseMessage res = req.CreateResponse(values); VersionVector context = _node.Kernel.Join(siblings); res.Headers.Add("X-Context", context.ToContextString()); return(ResponseMessage(res)); } catch (KeyNotFoundException e) { return(NotFound()); } }
public override string ToString() { return($"{Number}: {string.Join(",", Siblings.Select(n => n.Number))}"); }