private List <KeyValuePair <String, Object> > GetParameters(OperationImportSegment importSegment, Stream requestStream, String contentType) { var parameters = new List <KeyValuePair <String, Object> >(); foreach (OperationSegmentParameter segmentParameter in importSegment.Parameters) { Object value; var constantNode = segmentParameter.Value as ConstantNode; if (constantNode == null) { value = OeEdmClrHelper.GetValue(_model, segmentParameter.Value); } else { value = OeEdmClrHelper.GetValue(_model, constantNode.Value); } parameters.Add(new KeyValuePair <String, Object>(segmentParameter.Name, value)); } var operation = (EdmOperation)importSegment.OperationImports.Single().Operation; if (parameters.Count == 0 && requestStream != null) { FillParameters(parameters, requestStream, operation, contentType); } OrderParameters(operation.Parameters, parameters); return(parameters); }
private void FillParameters(List <KeyValuePair <String, Object> > parameters, Stream requestStream, IEdmOperation operation, String contentType) { if (!operation.Parameters.Any()) { return; } IODataRequestMessage requestMessage = new OeInMemoryMessage(requestStream, contentType); var settings = new ODataMessageReaderSettings() { EnableMessageStreamDisposal = false }; using (var messageReader = new ODataMessageReader(requestMessage, settings, _model)) { ODataParameterReader parameterReader = messageReader.CreateODataParameterReader(operation); while (parameterReader.Read()) { Object value; switch (parameterReader.State) { case ODataParameterReaderState.Value: { value = OeEdmClrHelper.GetValue(_model, parameterReader.Value); break; } case ODataParameterReaderState.Collection: { ODataCollectionReader collectionReader = parameterReader.CreateCollectionReader(); value = OeEdmClrHelper.GetValue(_model, ReadCollection(collectionReader)); break; } case ODataParameterReaderState.Resource: { ODataReader reader = parameterReader.CreateResourceReader(); value = OeEdmClrHelper.GetValue(_model, ReadResource(reader)); break; } case ODataParameterReaderState.ResourceSet: { ODataReader reader = parameterReader.CreateResourceSetReader(); value = OeEdmClrHelper.GetValue(_model, ReadResourceSet(reader)); break; } default: continue; } parameters.Add(new KeyValuePair <String, Object>(parameterReader.Name, value)); } } }