Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Dispatcher / UriTemplateDispatchFormatter.cs / 1305376 / 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.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) { TraceUtility.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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TypeUsage.cs
- HttpApplicationFactory.cs
- WorkflowInlining.cs
- UpdateCompiler.cs
- ResourcesBuildProvider.cs
- PagedDataSource.cs
- MappingMetadataHelper.cs
- Point4D.cs
- OutputCacheModule.cs
- Int16.cs
- SemanticValue.cs
- ToolStripPanelSelectionBehavior.cs
- HtmlAnchor.cs
- VerificationException.cs
- ControlBindingsCollection.cs
- DeclarationUpdate.cs
- PrefixQName.cs
- ProcessInputEventArgs.cs
- AnchorEditor.cs
- UnsafeNativeMethods.cs
- WebSysDescriptionAttribute.cs
- TableCell.cs
- ContentFileHelper.cs
- MultilineStringConverter.cs
- WSFederationHttpBinding.cs
- LineGeometry.cs
- _CookieModule.cs
- ChannelDispatcher.cs
- IndicShape.cs
- DateTimeParse.cs
- ProcessThread.cs
- HttpModuleAction.cs
- WebEvents.cs
- RemotingServices.cs
- NetworkStream.cs
- WorkflowItemPresenter.cs
- GridViewAutomationPeer.cs
- SoapEnumAttribute.cs
- XmlSchemaDocumentation.cs
- MarshalByRefObject.cs
- FactoryGenerator.cs
- TableCellsCollectionEditor.cs
- ToolboxItemCollection.cs
- LoginStatusDesigner.cs
- TextEditorCharacters.cs
- ValueUnavailableException.cs
- SqlMethodCallConverter.cs
- InkCanvasInnerCanvas.cs
- indexingfiltermarshaler.cs
- OleAutBinder.cs
- XamlStream.cs
- EmptyStringExpandableObjectConverter.cs
- CodeTypeParameterCollection.cs
- PrintPageEvent.cs
- Marshal.cs
- PointLightBase.cs
- InheritanceRules.cs
- ConnectionConsumerAttribute.cs
- RSAOAEPKeyExchangeFormatter.cs
- PropertyIDSet.cs
- CultureInfo.cs
- ComponentRenameEvent.cs
- WebUtil.cs
- EditorBrowsableAttribute.cs
- AppLevelCompilationSectionCache.cs
- MissingMemberException.cs
- COM2ColorConverter.cs
- SoapHeaderException.cs
- StylusPointPropertyUnit.cs
- ContextProperty.cs
- DataMemberFieldEditor.cs
- WebPartPersonalization.cs
- CodeExpressionStatement.cs
- XmlName.cs
- GuidTagList.cs
- SecurityTokenException.cs
- DateTimeFormatInfo.cs
- AssemblyName.cs
- Timer.cs
- FamilyMapCollection.cs
- HtmlLabelAdapter.cs
- HTTPNotFoundHandler.cs
- Table.cs
- AsmxEndpointPickerExtension.cs
- AnimatedTypeHelpers.cs
- PluralizationServiceUtil.cs
- SchemaExporter.cs
- DataListGeneralPage.cs
- X509ChainPolicy.cs
- RegexCharClass.cs
- PackageRelationshipSelector.cs
- ScopelessEnumAttribute.cs
- DesignerProperties.cs
- BuilderPropertyEntry.cs
- WebServiceHandler.cs
- BitmapEffectvisualstate.cs
- RelatedView.cs
- ObjectDataSourceEventArgs.cs
- DataExpression.cs
- WebConfigurationHostFileChange.cs