Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / CustomBindingCollectionElement.cs / 1 / CustomBindingCollectionElement.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Configuration { using System.Collections.Generic; using System.Collections.ObjectModel; using System.Configuration; using System.Globalization; using System.ServiceModel; using System.ServiceModel.Channels; public sealed partial class CustomBindingCollectionElement : BindingCollectionElement { [ConfigurationProperty(ConfigurationStrings.DefaultCollectionName, Options = ConfigurationPropertyOptions.IsDefaultCollection)] public CustomBindingElementCollection Bindings { get {return (CustomBindingElementCollection) base[ConfigurationStrings.DefaultCollectionName]; } } public override Type BindingType { get {return typeof(CustomBinding); } } public override ReadOnlyCollectionConfiguredBindings { get { List configuredBindings = new List (); foreach (IBindingConfigurationElement configuredBinding in this.Bindings) { configuredBindings.Add(configuredBinding); } return new ReadOnlyCollection (configuredBindings); } } public override bool ContainsKey(string name) { // This line needed because of the IBindingSection implementation return this.Bindings.ContainsKey(name); } protected internal override Binding GetDefault() { return System.Activator.CreateInstance (); } internal static CustomBindingCollectionElement GetBindingCollectionElement() { return (CustomBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement(ConfigurationStrings.CustomBindingCollectionElementName); } bool TryCreateMatchingExtension(BindingElement bindingElement, ExtensionElementCollection collection, bool allowDerivedTypes, string assemblyName, out BindingElementExtensionElement result) { result = null; foreach (ExtensionElement element in collection) { BindingElementExtensionElement bindingElementExtension = Activator.CreateInstance(Type.GetType(element.Type, true)) as BindingElementExtensionElement; if (null == bindingElementExtension) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidExtensionType, element.Type, assemblyName, ConfigurationStrings.BindingElementExtensions))); } bool isMatch; if (allowDerivedTypes) { isMatch = bindingElementExtension.BindingElementType.IsAssignableFrom(bindingElement.GetType()); } else { isMatch = bindingElementExtension.BindingElementType.Equals(bindingElement.GetType()); } if (isMatch) { result = bindingElementExtension; return true; } } return false; } protected internal override bool TryAdd(string name, Binding binding, Configuration config) { if (String.IsNullOrEmpty(name)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name"); } if (null == binding) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("binding"); } if (null == config) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("config"); } ServiceModelSectionGroup sg = ServiceModelSectionGroup.GetSectionGroup(config); CustomBindingElementCollection customBindings = sg.Bindings.CustomBinding.Bindings; CustomBindingElement configElement = new CustomBindingElement(name); customBindings.Add(configElement); ExtensionElementCollection collection = sg.Extensions.BindingElementExtensions; CustomBinding customBinding = (CustomBinding) binding; foreach (BindingElement bindingElement in customBinding.Elements) { BindingElementExtensionElement bindingElementExtension; bool foundMatch = TryCreateMatchingExtension(bindingElement, collection, false, configElement.CollectionElementBaseType.AssemblyQualifiedName, out bindingElementExtension); if (!foundMatch) { foundMatch = TryCreateMatchingExtension(bindingElement, collection, true, configElement.CollectionElementBaseType.AssemblyQualifiedName, out bindingElementExtension); } if (!foundMatch) { break; } bindingElementExtension.InitializeFrom(bindingElement); configElement.Add(bindingElementExtension); } bool retval = configElement.Count == customBinding.Elements.Count; if (!retval) { customBindings.Remove(configElement); } return retval; } } } // 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
- VariantWrapper.cs
- MediaTimeline.cs
- SerializerProvider.cs
- ForwardPositionQuery.cs
- DataRowCollection.cs
- Registry.cs
- SoapFormatExtensions.cs
- SctClaimSerializer.cs
- BaseCodePageEncoding.cs
- MLangCodePageEncoding.cs
- DataGridViewLinkColumn.cs
- precedingsibling.cs
- RemoteArgument.cs
- GridToolTip.cs
- TextSegment.cs
- FontFamily.cs
- GraphicsContainer.cs
- ServiceNameCollection.cs
- ToolStripSettings.cs
- TextUtf8RawTextWriter.cs
- HttpBufferlessInputStream.cs
- PanelDesigner.cs
- Mappings.cs
- TreeNode.cs
- PageStatePersister.cs
- Win32MouseDevice.cs
- SecuritySessionFilter.cs
- TextElement.cs
- SpanIndex.cs
- CacheVirtualItemsEvent.cs
- NativeRightsManagementAPIsStructures.cs
- StateManagedCollection.cs
- CheckBoxRenderer.cs
- XmlAttributeOverrides.cs
- VolatileResourceManager.cs
- FormViewCommandEventArgs.cs
- ListBox.cs
- TextStore.cs
- NullableBoolConverter.cs
- Matrix3D.cs
- IsolatedStorageException.cs
- XsltLibrary.cs
- TextShapeableCharacters.cs
- Int32Rect.cs
- ModelEditingScope.cs
- KeyGesture.cs
- latinshape.cs
- InvalidWMPVersionException.cs
- NativeCompoundFileAPIs.cs
- TrackBar.cs
- HtmlTableCellCollection.cs
- SessionPageStateSection.cs
- SecurityHeaderElementInferenceEngine.cs
- ConnectionStringSettings.cs
- RectConverter.cs
- XmlSchemaException.cs
- OutOfMemoryException.cs
- TdsParameterSetter.cs
- SafeRightsManagementHandle.cs
- ArrayTypeMismatchException.cs
- RepeatBehaviorConverter.cs
- TextEditorSpelling.cs
- GeneratedContractType.cs
- ZipIOCentralDirectoryFileHeader.cs
- DbProviderManifest.cs
- followingquery.cs
- CacheAxisQuery.cs
- QueuePathDialog.cs
- DataGridHeaderBorder.cs
- CodePrimitiveExpression.cs
- IsolatedStorage.cs
- TreeNodeCollection.cs
- SiteMapProvider.cs
- GenericIdentity.cs
- MimeReflector.cs
- CheckBoxRenderer.cs
- PersonalizationStateInfo.cs
- CngKeyBlobFormat.cs
- SqlDataSource.cs
- MarkupCompilePass2.cs
- ToolStripControlHost.cs
- HostProtectionPermission.cs
- ConfigurationStrings.cs
- GeometryGroup.cs
- AccessViolationException.cs
- EdmToObjectNamespaceMap.cs
- HttpListenerPrefixCollection.cs
- ConvertEvent.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- XNodeSchemaApplier.cs
- ConstraintManager.cs
- EntityDataSourceValidationException.cs
- UIElementIsland.cs
- SpAudioStreamWrapper.cs
- ListCardsInFileRequest.cs
- SerializableAttribute.cs
- DesignerWithHeader.cs
- VisualStates.cs
- ServiceBehaviorElement.cs
- DateTimeOffset.cs