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
- MetabaseSettings.cs
- VisualBasicSettings.cs
- CheckBox.cs
- DBCommand.cs
- itemelement.cs
- IisTraceWebEventProvider.cs
- SessionStateModule.cs
- AutomationPeer.cs
- BoundsDrawingContextWalker.cs
- AstNode.cs
- LabelAutomationPeer.cs
- HybridObjectCache.cs
- SqlMethodAttribute.cs
- XmlArrayAttribute.cs
- ProfileEventArgs.cs
- LicenseProviderAttribute.cs
- CodeTypeDelegate.cs
- JsonQNameDataContract.cs
- AvTrace.cs
- ArgumentDesigner.xaml.cs
- PersistenceParticipant.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- ControlPropertyNameConverter.cs
- XmlMemberMapping.cs
- OleDbPropertySetGuid.cs
- KeyValueInternalCollection.cs
- GridViewCancelEditEventArgs.cs
- MethodCallConverter.cs
- CubicEase.cs
- TransactionScope.cs
- CmsUtils.cs
- ResizeBehavior.cs
- PasswordDeriveBytes.cs
- CollectionBuilder.cs
- TreeChangeInfo.cs
- X509ChainPolicy.cs
- RijndaelCryptoServiceProvider.cs
- DataGridViewComboBoxCell.cs
- _SingleItemRequestCache.cs
- JavaScriptObjectDeserializer.cs
- EntitySqlQueryCacheKey.cs
- RuleElement.cs
- ExclusiveTcpTransportManager.cs
- DeclarativeCatalogPartDesigner.cs
- SplitterCancelEvent.cs
- WCFModelStrings.Designer.cs
- SecurityResources.cs
- Tokenizer.cs
- SemanticResultValue.cs
- odbcmetadatafactory.cs
- WCFBuildProvider.cs
- TextProperties.cs
- RegistryKey.cs
- SqlTopReducer.cs
- CodeBlockBuilder.cs
- RtfControlWordInfo.cs
- SafeRightsManagementQueryHandle.cs
- RNGCryptoServiceProvider.cs
- HyperLinkColumn.cs
- ScrollEventArgs.cs
- Verify.cs
- ColorBlend.cs
- PresentationAppDomainManager.cs
- Effect.cs
- OleDbParameterCollection.cs
- RefreshPropertiesAttribute.cs
- HttpServerVarsCollection.cs
- OrderByLifter.cs
- SurrogateSelector.cs
- EntitySqlQueryCacheEntry.cs
- TypedReference.cs
- InvokeWebService.cs
- TypeUtils.cs
- UInt16.cs
- ReferenceEqualityComparer.cs
- ObjectDataSourceView.cs
- DrawingContextDrawingContextWalker.cs
- CodeDirectoryCompiler.cs
- GetKeyedHashRequest.cs
- XamlPoint3DCollectionSerializer.cs
- SyntaxCheck.cs
- DirectoryInfo.cs
- SoapIncludeAttribute.cs
- StringAnimationUsingKeyFrames.cs
- SubstitutionDesigner.cs
- SrgsOneOf.cs
- WsatAdminException.cs
- MobileUserControlDesigner.cs
- DrawingGroupDrawingContext.cs
- LookupBindingPropertiesAttribute.cs
- ManagementPath.cs
- EntityTypeEmitter.cs
- ChangeInterceptorAttribute.cs
- TextParagraphView.cs
- TreeNodeClickEventArgs.cs
- EmptyElement.cs
- ParenExpr.cs
- RectAnimationUsingKeyFrames.cs
- HtmlTableCell.cs
- FontResourceCache.cs