Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / UriTemplateQueryValue.cs / 2 / UriTemplateQueryValue.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System { using System.Collections.Specialized; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; using System.Web; using System.ServiceModel.Channels; // This represents a Query value, which can either be Empty, a Literal or a Variable abstract class UriTemplateQueryValue { readonly UriTemplatePartType nature; static UriTemplateQueryValue empty = new EmptyUriTemplateQueryValue(); protected UriTemplateQueryValue(UriTemplatePartType nature) { this.nature = nature; } public static UriTemplateQueryValue Empty { get { return UriTemplateQueryValue.empty; } } public UriTemplatePartType Nature { get { return this.nature; } } public static UriTemplateQueryValue CreateFromUriTemplate(string value, UriTemplate template) { // Checking for empty value if (value == null) { return UriTemplateQueryValue.Empty; } // Identifying the type of value - Literal|Compound|Variable switch (UriTemplateHelpers.IdentifyPartType(value)) { case UriTemplatePartType.Literal: return UriTemplateLiteralQueryValue.CreateFromUriTemplate(value); case UriTemplatePartType.Compound: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString( SR2.UTQueryCannotHaveCompoundValue, template.originalTemplate))); case UriTemplatePartType.Variable: return new UriTemplateVariableQueryValue(template.AddQueryVariable(value.Substring(1, value.Length - 2))); default: Fx.Assert("Invalid value from IdentifyStringNature"); return null; } } public static bool IsNullOrEmpty(UriTemplateQueryValue utqv) { if (utqv == null) { return true; } if (utqv == UriTemplateQueryValue.Empty) { return true; } return false; } public abstract void Bind(string keyName, string[] values, ref int valueIndex, StringBuilder query); public abstract bool IsEquivalentTo(UriTemplateQueryValue other); public abstract void Lookup(string value, NameValueCollection boundParameters); class EmptyUriTemplateQueryValue : UriTemplateQueryValue { public EmptyUriTemplateQueryValue() : base(UriTemplatePartType.Literal) { } public override void Bind(string keyName, string[] values, ref int valueIndex, StringBuilder query) { query.AppendFormat("&{0}", UrlUtility.UrlEncode(keyName, Encoding.UTF8)); } public override bool IsEquivalentTo(UriTemplateQueryValue other) { return (other == UriTemplateQueryValue.Empty); } public override void Lookup(string value, NameValueCollection boundParameters) { Fx.Assert(string.IsNullOrEmpty(value), "shouldn't have a value"); } } } } // 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
- BCLDebug.cs
- Literal.cs
- PeerFlooder.cs
- HorizontalAlignConverter.cs
- ExpressionBuilder.cs
- XmlPropertyBag.cs
- SortQuery.cs
- VisualCollection.cs
- DiagnosticsConfiguration.cs
- GeneralTransformCollection.cs
- PeerResolverMode.cs
- SqlConnectionHelper.cs
- XmlSchemaComplexContent.cs
- StringStorage.cs
- HttpCachePolicyElement.cs
- SqlDataSourceDesigner.cs
- CreateUserWizard.cs
- StreamInfo.cs
- HandlerBase.cs
- XmlSchemaSet.cs
- ComIntegrationManifestGenerator.cs
- HttpTransportManager.cs
- SafeEventLogWriteHandle.cs
- HandoffBehavior.cs
- AsyncOperationManager.cs
- PersistNameAttribute.cs
- RuntimeDelegateArgument.cs
- HttpCapabilitiesSectionHandler.cs
- ContextProperty.cs
- DocumentViewer.cs
- LoadedOrUnloadedOperation.cs
- ReachDocumentSequenceSerializerAsync.cs
- ResizeGrip.cs
- Win32Native.cs
- WorkflowInstance.cs
- PostBackOptions.cs
- FontFaceLayoutInfo.cs
- RowParagraph.cs
- DataColumnPropertyDescriptor.cs
- HttpRuntime.cs
- DynamicValueConverter.cs
- ObjectItemCollection.cs
- CompiledIdentityConstraint.cs
- FixedDocumentPaginator.cs
- StrongName.cs
- IncomingWebResponseContext.cs
- ThemeDirectoryCompiler.cs
- ImmComposition.cs
- SqlDataReaderSmi.cs
- TagPrefixInfo.cs
- Set.cs
- ProcessHost.cs
- NextPreviousPagerField.cs
- SqlMetaData.cs
- WorkflowServiceHostFactory.cs
- X509SubjectKeyIdentifierClause.cs
- PrePrepareMethodAttribute.cs
- DynamicValueConverter.cs
- BooleanStorage.cs
- SrgsText.cs
- HashStream.cs
- CatalogPart.cs
- AnimationTimeline.cs
- PropertyTabAttribute.cs
- DataContractSerializerSection.cs
- MouseActionConverter.cs
- SystemIPInterfaceStatistics.cs
- DrawListViewColumnHeaderEventArgs.cs
- TokenizerHelper.cs
- SQLSingle.cs
- ReaderOutput.cs
- PassportAuthenticationEventArgs.cs
- SecurityContext.cs
- ReadOnlyObservableCollection.cs
- ResourceReader.cs
- Automation.cs
- EditorOptionAttribute.cs
- ValidationError.cs
- DataTable.cs
- CodeChecksumPragma.cs
- ClientApiGenerator.cs
- TcpTransportBindingElement.cs
- FrameworkElementAutomationPeer.cs
- MSAAWinEventWrap.cs
- RoutedEventValueSerializer.cs
- EndpointAddressElementBase.cs
- XmlSchemaImporter.cs
- NameTable.cs
- WebUtil.cs
- LineUtil.cs
- Visual3D.cs
- TextServicesHost.cs
- EpmTargetPathSegment.cs
- VariableReference.cs
- HealthMonitoringSectionHelper.cs
- LineMetrics.cs
- XmlCountingReader.cs
- CodeTypeOfExpression.cs
- BitmapEffectState.cs
- StructuralComparisons.cs