private void AddValue(NamedValue value) { if (this.valuesByName.ContainsKey(value.Name)) { this.orderedNames.Remove(value.Name); } this.orderedNames.Add(value.Name); this.valuesByName[value.Name] = value; }
private IEnumerable<NamedValue> ExtractNamedValues(ODataRequest request) { bool isProperty = request.Uri.IsProperty(); bool isValue = request.Uri.IsPropertyValue(); string prefix = null; if (isProperty || isValue) { // get the uri for the last entity var entityUri = request.Uri.ScopeToEntity(); // get the property names following the entity var propertyNamesToPrepend = request.Uri.Segments .Skip(entityUri.Segments.Count) .OfType<PropertySegment>() .Select(p => p.Property.Name) .ToList(); // for property uri's the last property name is also in the payload, so we shouldnt add it if (isProperty) { propertyNamesToPrepend.RemoveAt(propertyNamesToPrepend.Count - 1); } if (propertyNamesToPrepend.Count > 0) { prefix = string.Join(".", propertyNamesToPrepend.ToArray()); } } if (request.Body.RootElement.ElementType == ODataPayloadElementType.PrimitiveValue) { return new[] { new NamedValue(prefix, ((PrimitiveValue)request.Body.RootElement).ClrValue) }; } else { this.MetadataResolver.ResolveMetadata(request.Body.RootElement, request.Uri); var payload = ReinterpretRequestPayloadIfNeeded(request); var namedValues = this.PayloadConverter.ConvertToNamedValues(payload).ToList(); if (prefix != null) { for (int i = 0; i < namedValues.Count; i++) { var original = namedValues[i]; namedValues[i] = new NamedValue(prefix + '.' + original.Name, original.Value); } } return namedValues; } }
private void AddValue(object value) { var namedValue = new NamedValue(string.Join(".", this.currentPath.Reverse().ToArray()), value); this.AddValue(namedValue); }