Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Dispatcher / UriTemplateDispatchFormatter.cs / 1 / UriTemplateDispatchFormatter.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- #pragma warning disable 1634, 1691 namespace System.ServiceModel.Dispatcher { using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.Reflection; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.ServiceModel.Diagnostics; using System.Text; using System.Web; using System.Xml; using System.ServiceModel.Web; using System.Diagnostics; class UriTemplateDispatchFormatter : IDispatchMessageFormatter { internal DictionarypathMapping; internal Dictionary > queryMapping; Uri baseAddress; IDispatchMessageFormatter inner; string operationName; QueryStringConverter qsc; int totalNumUTVars; UriTemplate uriTemplate; public UriTemplateDispatchFormatter(OperationDescription operationDescription, IDispatchMessageFormatter inner, QueryStringConverter qsc, string contractName, Uri baseAddress) { this.inner = inner; this.qsc = qsc; this.baseAddress = baseAddress; this.operationName = operationDescription.Name; UriTemplateClientFormatter.Populate(out this.pathMapping, out this.queryMapping, out this.totalNumUTVars, out this.uriTemplate, operationDescription, qsc, contractName); } public void DeserializeRequest(Message message, object[] parameters) { object[] innerParameters = new object[parameters.Length - this.totalNumUTVars]; if (innerParameters.Length != 0) { this.inner.DeserializeRequest(message, innerParameters); } int j = 0; UriTemplateMatch utmr = null; string UTMRName = IncomingWebRequestContext.UriTemplateMatchResultsPropertyName; if (message.Properties.ContainsKey(UTMRName)) { utmr = message.Properties[UTMRName] as UriTemplateMatch; } else { if (message.Headers.To != null && message.Headers.To.IsAbsoluteUri) { utmr = this.uriTemplate.Match(this.baseAddress, message.Headers.To); } } NameValueCollection nvc = (utmr == null) ? new NameValueCollection() : utmr.BoundVariables; for (int i = 0; i < parameters.Length; ++i) { if (this.pathMapping.ContainsKey(i) && utmr != null) { parameters[i] = nvc[this.pathMapping[i]]; } else if (this.queryMapping.ContainsKey(i) && utmr != null) { string queryVal = nvc[this.queryMapping[i].Key]; parameters[i] = this.qsc.ConvertStringToValue(queryVal, this.queryMapping[i].Value); } else { parameters[i] = innerParameters[j]; ++j; } } if (DiagnosticUtility.ShouldTraceInformation) { if (utmr != null) { foreach (string key in utmr.QueryParameters.Keys) { bool isParameterIgnored = true; foreach (KeyValuePair kvp in this.queryMapping.Values) { if (String.Compare(key, kvp.Key, StringComparison.OrdinalIgnoreCase) == 0) { isParameterIgnored = false; break; } } if (isParameterIgnored) { DiagnosticUtility.DiagnosticTrace.TraceEvent(TraceEventType.Information, TraceCode.WebUnknownQueryParameterIgnored, SR2.GetString(SR2.TraceCodeWebRequestUnknownQueryParameterIgnored, key, operationName)); } } } } } public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.QueryStringFormatterOperationNotSupportedServerSide))); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataSourceXmlAttributeAttribute.cs
- GridEntryCollection.cs
- TraceSwitch.cs
- _DomainName.cs
- XmlTypeMapping.cs
- TabControlToolboxItem.cs
- BindingOperations.cs
- RTLAwareMessageBox.cs
- SetStateEventArgs.cs
- SafeThreadHandle.cs
- XamlFigureLengthSerializer.cs
- InkCanvasSelectionAdorner.cs
- LinqDataSourceHelper.cs
- TabPageDesigner.cs
- XmlReaderSettings.cs
- ReliableChannelListener.cs
- StreamGeometry.cs
- HttpInputStream.cs
- ExpressionParser.cs
- HyperLinkDataBindingHandler.cs
- TextFormatterHost.cs
- CustomAttributeFormatException.cs
- SecurityUtils.cs
- ToolStripItemRenderEventArgs.cs
- CultureInfoConverter.cs
- ResourceWriter.cs
- WpfPayload.cs
- BrushConverter.cs
- FontWeights.cs
- NullReferenceException.cs
- FileStream.cs
- WorkflowDesignerMessageFilter.cs
- TextEditor.cs
- ImplicitInputBrush.cs
- DbSetClause.cs
- QueryStoreStatusRequest.cs
- CellPartitioner.cs
- DefaultAsyncDataDispatcher.cs
- wmiprovider.cs
- CombinedGeometry.cs
- XmlDataLoader.cs
- CustomExpression.cs
- ScrollableControl.cs
- SystemGatewayIPAddressInformation.cs
- OutputCacheEntry.cs
- uribuilder.cs
- TypeConverters.cs
- TypeConstant.cs
- SqlErrorCollection.cs
- ComboBox.cs
- TextEditorSpelling.cs
- ObjectDataSourceMethodEditor.cs
- unitconverter.cs
- BaseResourcesBuildProvider.cs
- DispatcherProcessingDisabled.cs
- RoutedUICommand.cs
- GenericTransactionFlowAttribute.cs
- XmlNode.cs
- DecodeHelper.cs
- CatalogZone.cs
- DataBinder.cs
- PeerCollaborationPermission.cs
- LinqTreeNodeEvaluator.cs
- TextLineResult.cs
- DataServiceRequestOfT.cs
- FullTrustAssemblyCollection.cs
- CommonXSendMessage.cs
- HealthMonitoringSection.cs
- OutOfProcStateClientManager.cs
- DataGridViewColumn.cs
- StructuralType.cs
- ObjectSecurity.cs
- BindingsCollection.cs
- FunctionGenerator.cs
- WebPartEditorOkVerb.cs
- AutomationPropertyInfo.cs
- ImageClickEventArgs.cs
- SocketInformation.cs
- IdleTimeoutMonitor.cs
- SQLDoubleStorage.cs
- DesignerForm.cs
- OleDbRowUpdatedEvent.cs
- SimpleFieldTemplateUserControl.cs
- ImageAutomationPeer.cs
- CommunicationObject.cs
- OutOfProcStateClientManager.cs
- sqlinternaltransaction.cs
- XmlBufferReader.cs
- VirtualizedItemPattern.cs
- SessionIDManager.cs
- IPGlobalProperties.cs
- OleDbFactory.cs
- EnumConverter.cs
- LoginView.cs
- DrawListViewColumnHeaderEventArgs.cs
- QilInvoke.cs
- StreamWriter.cs
- EditorZone.cs
- StylusPointPropertyInfoDefaults.cs
- StaticSiteMapProvider.cs