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
- NameTable.cs
- DesignerDataStoredProcedure.cs
- DynamicRendererThreadManager.cs
- NonceCache.cs
- RoleGroupCollection.cs
- SelectionUIHandler.cs
- ZoneLinkButton.cs
- ResourceDisplayNameAttribute.cs
- IsolatedStorageFilePermission.cs
- InsufficientMemoryException.cs
- SurrogateChar.cs
- SplineQuaternionKeyFrame.cs
- NumberFunctions.cs
- ComNativeDescriptor.cs
- Identifier.cs
- ListViewContainer.cs
- ContextQuery.cs
- Rotation3DAnimation.cs
- TrustManagerPromptUI.cs
- EnumMemberAttribute.cs
- DataGridViewCellCollection.cs
- Base64WriteStateInfo.cs
- ListItemCollection.cs
- RtfToXamlReader.cs
- AnimationLayer.cs
- BindingElementCollection.cs
- LocalClientSecuritySettings.cs
- RuntimeIdentifierPropertyAttribute.cs
- SkewTransform.cs
- ValueProviderWrapper.cs
- CodeTypeDeclarationCollection.cs
- XslTransform.cs
- NoneExcludedImageIndexConverter.cs
- SQLDouble.cs
- MultipartIdentifier.cs
- WebFaultClientMessageInspector.cs
- HMAC.cs
- COM2ColorConverter.cs
- SQLBytesStorage.cs
- FormsAuthenticationTicket.cs
- Socket.cs
- StateManagedCollection.cs
- AccessibilityHelperForXpWin2k3.cs
- AttachmentCollection.cs
- SQLDecimalStorage.cs
- DataGridLinkButton.cs
- QuaternionAnimation.cs
- FacetChecker.cs
- Vector3D.cs
- Section.cs
- SerialErrors.cs
- CustomLineCap.cs
- SharedStatics.cs
- Vector3dCollection.cs
- Color.cs
- DocumentXmlWriter.cs
- DataPointer.cs
- MonitoringDescriptionAttribute.cs
- DataStreamFromComStream.cs
- BuildManagerHost.cs
- OdbcConnectionFactory.cs
- InputEventArgs.cs
- QilGeneratorEnv.cs
- Timer.cs
- BitmapEffectInputData.cs
- Privilege.cs
- DataBindingCollection.cs
- FileDetails.cs
- DataGridViewAutoSizeModeEventArgs.cs
- CollectionAdapters.cs
- DateTimeValueSerializerContext.cs
- XslVisitor.cs
- WsdlInspector.cs
- GridViewColumn.cs
- ReferenceEqualityComparer.cs
- EntitySqlQueryState.cs
- WmlLinkAdapter.cs
- CompilerInfo.cs
- Screen.cs
- DSACryptoServiceProvider.cs
- ErrorWebPart.cs
- ExecutionProperties.cs
- CopyNamespacesAction.cs
- DragAssistanceManager.cs
- ELinqQueryState.cs
- ScalarConstant.cs
- PasswordRecovery.cs
- BrowserCapabilitiesFactoryBase.cs
- SmtpReplyReader.cs
- TdsParameterSetter.cs
- ControlCachePolicy.cs
- RequestQueue.cs
- PersonalizationProvider.cs
- StandardToolWindows.cs
- WebDescriptionAttribute.cs
- TagMapCollection.cs
- NodeLabelEditEvent.cs
- Expressions.cs
- TypeInfo.cs
- PLINQETWProvider.cs