Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Description / ConfigWriter.cs / 1 / ConfigWriter.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Description { using System; using System.ServiceModel.Channels; using System.Configuration; using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Configuration; using System.ServiceModel.Diagnostics; internal class ConfigWriter { readonly DictionarybindingTable; readonly BindingsSection bindingsSection; readonly ChannelEndpointElementCollection channels; readonly Configuration config; internal ConfigWriter(Configuration configuration) { this.bindingTable = new Dictionary (); this.bindingsSection = BindingsSection.GetSection(configuration); ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration); this.channels = serviceModelSectionGroup.Client.Endpoints; this.config = configuration; } internal ChannelEndpointElement WriteChannelDescription(ServiceEndpoint endpoint, string typeName) { ChannelEndpointElement channelElement = null; // Create Binding BindingDictionaryValue bindingDV = CreateBindingConfig(endpoint.Binding); channelElement = new ChannelEndpointElement(endpoint.Address, typeName); // [....]: review: Use decoded form to preserve the user-given friendly name, however, beacuse our Encoding algorithm // does not touch ASCII names, a name that looks like encoded name will not roundtrip(Example: "_x002C_" will turned into ",") channelElement.Name = NamingHelper.GetUniqueName(NamingHelper.CodeName(endpoint.Name), this.CheckIfChannelNameInUse, null); channelElement.BindingConfiguration = bindingDV.BindingName; channelElement.Binding = bindingDV.BindingSectionName; channels.Add(channelElement); return channelElement; } internal void WriteBinding(Binding binding, out string bindingSectionName, out string configurationName) { BindingDictionaryValue result = CreateBindingConfig(binding); configurationName = result.BindingName; bindingSectionName = result.BindingSectionName; } BindingDictionaryValue CreateBindingConfig(Binding binding) { BindingDictionaryValue bindingDV; if (!bindingTable.TryGetValue(binding, out bindingDV)) { // [....]: review: Use decoded form to preserve the user-given friendly name, however, beacuse our Encoding algorithm // does not touch ASCII names, a name that looks like encoded name will not roundtrip(Example: "_x002C_" will turned into ",") string bindingName = NamingHelper.GetUniqueName(NamingHelper.CodeName(binding.Name), this.CheckIfBindingNameInUse, null); string bindingSectionName; if (!BindingsSection.TryAdd(bindingName, binding, config, out bindingSectionName)) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.ConfigBindingCannotBeConfigured), "endpoint.Binding")); bindingDV = new BindingDictionaryValue(bindingName, bindingSectionName); bindingTable.Add(binding, bindingDV); } return bindingDV; } bool CheckIfBindingNameInUse(string name, object nameCollection) { foreach (BindingCollectionElement bindingCollectionElement in this.bindingsSection.BindingCollections) if (bindingCollectionElement.ContainsKey(name)) return true; return false; } bool CheckIfChannelNameInUse(string name, object namingCollection) { foreach (ChannelEndpointElement element in this.channels) if (element.Name == name) return true; return false; } sealed class BindingDictionaryValue { public readonly string BindingName; public readonly string BindingSectionName; public BindingDictionaryValue(string bindingName, string bindingSectionName) { this.BindingName = bindingName; this.BindingSectionName = bindingSectionName; } } } } // 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
- SuppressMessageAttribute.cs
- SafeFileHandle.cs
- BlockUIContainer.cs
- DSASignatureDeformatter.cs
- RoleGroupCollection.cs
- DecryptRequest.cs
- SQLChars.cs
- DataGridRow.cs
- Byte.cs
- AsnEncodedData.cs
- MenuCommands.cs
- ClientConfigurationHost.cs
- DoubleAnimationUsingKeyFrames.cs
- DeploymentExceptionMapper.cs
- Encoder.cs
- PageSetupDialog.cs
- ByeMessageApril2005.cs
- BooleanFacetDescriptionElement.cs
- shaperfactoryquerycacheentry.cs
- OleDbReferenceCollection.cs
- HashHelper.cs
- ComponentChangedEvent.cs
- DesignObjectWrapper.cs
- PageBuildProvider.cs
- SinglePageViewer.cs
- AccessedThroughPropertyAttribute.cs
- OperatingSystem.cs
- DeferredElementTreeState.cs
- InvalidPropValue.cs
- listitem.cs
- XmlSchemaElement.cs
- DataBinding.cs
- CryptographicAttribute.cs
- XmlSchemaSimpleContentExtension.cs
- CryptoProvider.cs
- WmlTextViewAdapter.cs
- QilTargetType.cs
- ResourceManagerWrapper.cs
- SystemResources.cs
- KerberosTokenFactoryCredential.cs
- PathSegment.cs
- XmlEncodedRawTextWriter.cs
- XmlSecureResolver.cs
- TextBox.cs
- XmlLoader.cs
- HttpAsyncResult.cs
- DataGridPagerStyle.cs
- DataGridItemEventArgs.cs
- ExcCanonicalXml.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- ConfigurationPropertyCollection.cs
- ConnectionStringsExpressionEditor.cs
- HtmlTable.cs
- SqlCacheDependencySection.cs
- XPathMultyIterator.cs
- cookieexception.cs
- PhysicalFontFamily.cs
- WsdlBuildProvider.cs
- AuthorizationBehavior.cs
- NetCodeGroup.cs
- TypedReference.cs
- _SafeNetHandles.cs
- CodeMethodReturnStatement.cs
- IgnorePropertiesAttribute.cs
- MaskedTextBox.cs
- TransformerTypeCollection.cs
- ChannelSinkStacks.cs
- AttributeCollection.cs
- PieceNameHelper.cs
- DbConnectionPoolIdentity.cs
- DataBoundLiteralControl.cs
- MemoryStream.cs
- SafeThreadHandle.cs
- ReachUIElementCollectionSerializer.cs
- AdCreatedEventArgs.cs
- DbExpressionBuilder.cs
- CollectionExtensions.cs
- PropertyDescriptorGridEntry.cs
- OdbcTransaction.cs
- ValidationErrorCollection.cs
- PrintDialogException.cs
- Processor.cs
- Semaphore.cs
- HandledMouseEvent.cs
- InteropAutomationProvider.cs
- CommonObjectSecurity.cs
- DoubleLink.cs
- ModuleConfigurationInfo.cs
- SystemBrushes.cs
- ContentPlaceHolderDesigner.cs
- CancelRequestedRecord.cs
- ApplicationSecurityInfo.cs
- Expr.cs
- WebEvents.cs
- TypeDelegator.cs
- AccessControlList.cs
- TranslateTransform3D.cs
- DataGridViewCellEventArgs.cs
- WebHttpSecurityModeHelper.cs
- EntityDataSourceState.cs