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
- EntitySetDataBindingList.cs
- XNameConverter.cs
- Object.cs
- BatchParser.cs
- TextElementCollection.cs
- WrappedDispatcherException.cs
- DragEventArgs.cs
- ProfilePropertySettings.cs
- TraceRecord.cs
- XamlRtfConverter.cs
- ToolStripSplitStackLayout.cs
- coordinator.cs
- RepeaterItemEventArgs.cs
- RectKeyFrameCollection.cs
- NotCondition.cs
- CreateUserWizardAutoFormat.cs
- SlotInfo.cs
- ValidationSummary.cs
- CallbackTimeoutsElement.cs
- ConfigXmlComment.cs
- LocalFileSettingsProvider.cs
- TextContainerHelper.cs
- serverconfig.cs
- ListViewItem.cs
- dbenumerator.cs
- XmlImplementation.cs
- ValidationError.cs
- TextCollapsingProperties.cs
- SequenceNumber.cs
- PartitionResolver.cs
- SessionViewState.cs
- ObjectItemNoOpAssemblyLoader.cs
- ThreadExceptionDialog.cs
- GridViewEditEventArgs.cs
- Model3D.cs
- ConnectionManagementSection.cs
- PageCodeDomTreeGenerator.cs
- CriticalHandle.cs
- DodSequenceMerge.cs
- bindurihelper.cs
- DefaultObjectMappingItemCollection.cs
- ConfigurationLockCollection.cs
- VirtualDirectoryMappingCollection.cs
- Operators.cs
- DataObjectFieldAttribute.cs
- ControlIdConverter.cs
- PropertyChangingEventArgs.cs
- ValidatorCollection.cs
- InputQueueChannelAcceptor.cs
- StringSource.cs
- EncoderFallback.cs
- Debug.cs
- StubHelpers.cs
- TreeNode.cs
- TextDataBindingHandler.cs
- FacetValueContainer.cs
- ScriptHandlerFactory.cs
- JavaScriptString.cs
- XamlUtilities.cs
- CodeAttributeArgumentCollection.cs
- PagedControl.cs
- FontStretch.cs
- GraphicsPath.cs
- RenderOptions.cs
- WindowsListViewScroll.cs
- TextElement.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- DisplayMemberTemplateSelector.cs
- ModuleBuilder.cs
- DataGridItemEventArgs.cs
- AspCompat.cs
- EUCJPEncoding.cs
- GeometryConverter.cs
- XMLSchema.cs
- DocumentGrid.cs
- CommonObjectSecurity.cs
- ContextMenuService.cs
- BindingExpressionBase.cs
- SchemaMerger.cs
- SqlDataSourceCommandEventArgs.cs
- EncryptedHeaderXml.cs
- TriState.cs
- FontSourceCollection.cs
- OpCodes.cs
- DatagridviewDisplayedBandsData.cs
- ModelItemDictionary.cs
- mongolianshape.cs
- Vector.cs
- EtwTrace.cs
- DivideByZeroException.cs
- FatalException.cs
- DataGridViewTextBoxEditingControl.cs
- ServiceOperationListItemList.cs
- NavigationPropertyEmitter.cs
- Button.cs
- ResourceAssociationType.cs
- MetadataProperty.cs
- CheckBoxRenderer.cs
- PromptEventArgs.cs
- TextRangeProviderWrapper.cs