/// <summary> /// Calls the base class method to process the instance collection. /// </summary> /// <param name="payloadElement">The complex instance collection to process.</param> public override void Visit(ComplexInstanceCollection payloadElement) { ODataCollectionStart collectionStart = new ODataCollectionStart(); this.items.Push(collectionStart); var annotation = new ODataCollectionItemsObjectModelAnnotation(); foreach (var complex in payloadElement) { this.items.Push(new ODataComplexValue() { TypeName = complex.FullTypeName }); this.Recurse(complex); annotation.Add(this.items.Pop()); } collectionStart.SetAnnotation<ODataCollectionItemsObjectModelAnnotation>(annotation); }
/// <summary> /// Calls the base class method to process the primitive collection. /// </summary> /// <param name="payloadElement">The primitive collection to process.</param> public override void Visit(PrimitiveCollection payloadElement) { ODataCollectionStart collectionStart = new ODataCollectionStart(); var annotation = new ODataCollectionItemsObjectModelAnnotation(); foreach (var primitive in payloadElement) { annotation.Add(primitive.ClrValue); } collectionStart.SetAnnotation<ODataCollectionItemsObjectModelAnnotation>(annotation); }
/// <summary> /// Creates a default parameter payload. /// </summary> /// <returns>The created <see cref="ODataParameters"/> instance.</returns> public static ODataParameters CreateDefaultParameter() { var complexValue = new ODataComplexValue() { TypeName = "My.NestedAddressType", Properties = new[] { new ODataProperty() { Name = "Street", Value = new ODataComplexValue() { TypeName = "My.StreetType", Properties = new [] { new ODataProperty { Name = "StreetName", Value = "One Redmond Way" }, new ODataProperty { Name = "Number", Value = 1234 }, } } }, new ODataProperty() { Name = "City", Value = "Redmond " }, } }; var primitiveCollectionValue = new ODataCollectionStart(); primitiveCollectionValue.SetAnnotation(new ODataCollectionItemsObjectModelAnnotation() { "Value1", "Value2", "Value3" }); var complexCollectionValue = new ODataCollectionStart(); complexCollectionValue.SetAnnotation(new ODataCollectionItemsObjectModelAnnotation() { complexValue }); return new ODataParameters() { new KeyValuePair<string, object>("primitiveParameter", "StringValue"), new KeyValuePair<string, object>("complexParameter", complexValue), new KeyValuePair<string, object>("primitiveCollectionParameter", primitiveCollectionValue), new KeyValuePair<string, object>("complexCollectionParameter", complexCollectionValue), }; }