Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / TransportChannelFactory.cs / 1 / TransportChannelFactory.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Collections.Generic; using System.Collections.ObjectModel; using System.ServiceModel; using System.Diagnostics; using System.IO; using System.Runtime.Serialization; using System.Text; using System.Threading; abstract class TransportChannelFactory: ChannelFactoryBase , ITransportFactorySettings { BufferManager bufferManager; long maxBufferPoolSize; long maxReceivedMessageSize; MessageEncoderFactory messageEncoderFactory; bool manualAddressing; MessageVersion messageVersion; protected TransportChannelFactory(TransportBindingElement bindingElement, BindingContext context) : this(bindingElement, context, TransportDefaults.GetDefaultMessageEncoderFactory()) { } protected TransportChannelFactory(TransportBindingElement bindingElement, BindingContext context, MessageEncoderFactory defaultMessageEncoderFactory) : base(context.Binding) { this.manualAddressing = bindingElement.ManualAddressing; this.maxBufferPoolSize = bindingElement.MaxBufferPoolSize; this.maxReceivedMessageSize = bindingElement.MaxReceivedMessageSize; Collection messageEncoderBindingElements = context.BindingParameters.FindAll (); if (messageEncoderBindingElements.Count > 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleMebesInParameters))); } else if (messageEncoderBindingElements.Count == 1) { this.messageEncoderFactory = messageEncoderBindingElements[0].CreateMessageEncoderFactory(); context.BindingParameters.Remove (); } else { this.messageEncoderFactory = defaultMessageEncoderFactory; } if (null != this.messageEncoderFactory) this.messageVersion = this.messageEncoderFactory.MessageVersion; else this.messageVersion = MessageVersion.None; } public BufferManager BufferManager { get { return this.bufferManager; } } public long MaxBufferPoolSize { get { return this.maxBufferPoolSize; } } public long MaxReceivedMessageSize { get { return maxReceivedMessageSize; } } public MessageEncoderFactory MessageEncoderFactory { get { return this.messageEncoderFactory; } } public MessageVersion MessageVersion { get { return this.messageVersion; } } public bool ManualAddressing { get { return this.manualAddressing; } } public abstract string Scheme { get; } public override T GetProperty () { if (typeof(T) == typeof(MessageVersion)) { return (T)(object)this.MessageVersion; } if (typeof(T) == typeof(FaultConverter)) { if (null == this.MessageEncoderFactory) return null; else return this.MessageEncoderFactory.Encoder.GetProperty (); } return base.GetProperty (); } protected override void OnAbort() { OnCloseOrAbort(); base.OnAbort(); } protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { OnCloseOrAbort(); return base.OnBeginClose(timeout, callback, state); } protected override void OnClose(TimeSpan timeout) { OnCloseOrAbort(); base.OnClose(timeout); } void OnCloseOrAbort() { if (this.bufferManager != null) { this.bufferManager.Clear(); } } internal virtual int GetMaxBufferSize() { if (MaxReceivedMessageSize > int.MaxValue) return int.MaxValue; else return (int)MaxReceivedMessageSize; } protected override void OnOpening() { base.OnOpening(); this.bufferManager = BufferManager.CreateBufferManager(MaxBufferPoolSize, GetMaxBufferSize()); } internal void ValidateScheme(Uri via) { if (via.Scheme != this.Scheme) { // URI schemes are case-insensitive, so try a case insensitive compare now if (string.Compare(via.Scheme, this.Scheme, StringComparison.OrdinalIgnoreCase) != 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("via", SR.GetString(SR.InvalidUriScheme, via.Scheme, this.Scheme)); } } } long ITransportFactorySettings.MaxReceivedMessageSize { get { return MaxReceivedMessageSize; } } BufferManager ITransportFactorySettings.BufferManager { get { return BufferManager; } } bool ITransportFactorySettings.ManualAddressing { get { return ManualAddressing; } } MessageEncoderFactory ITransportFactorySettings.MessageEncoderFactory { get { return MessageEncoderFactory; } } } } // 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
- BrowserDefinitionCollection.cs
- HyperLinkColumn.cs
- DataSourceXmlAttributeAttribute.cs
- SubMenuStyleCollectionEditor.cs
- SchemaNamespaceManager.cs
- DiffuseMaterial.cs
- PreservationFileWriter.cs
- FlowLayoutPanelDesigner.cs
- TextEditorDragDrop.cs
- SafeProcessHandle.cs
- Expressions.cs
- TypedRowHandler.cs
- BaseServiceProvider.cs
- BaseServiceProvider.cs
- MetadataArtifactLoaderComposite.cs
- SettingsBindableAttribute.cs
- SchemaInfo.cs
- PolyQuadraticBezierSegment.cs
- NameValueFileSectionHandler.cs
- ConditionalBranch.cs
- HandledMouseEvent.cs
- OdbcException.cs
- PointAnimationBase.cs
- SplashScreenNativeMethods.cs
- AutomationPropertyInfo.cs
- ConfigurationPropertyAttribute.cs
- ForceCopyBuildProvider.cs
- ImmutableCollection.cs
- TableLayoutSettingsTypeConverter.cs
- SourceSwitch.cs
- ReadOnlyDataSourceView.cs
- ViewSimplifier.cs
- PropertySourceInfo.cs
- MetadataItem_Static.cs
- QueryRelOp.cs
- ChangeNode.cs
- DetailsViewPagerRow.cs
- LambdaCompiler.Lambda.cs
- FilteredAttributeCollection.cs
- HijriCalendar.cs
- AppSettingsReader.cs
- OpenTypeCommon.cs
- EventNotify.cs
- TableLayoutPanelCellPosition.cs
- HttpStaticObjectsCollectionBase.cs
- NativeMethods.cs
- RemotingSurrogateSelector.cs
- ExecutionContext.cs
- SemaphoreSlim.cs
- DataGridViewCellValueEventArgs.cs
- PipelineModuleStepContainer.cs
- DataKeyPropertyAttribute.cs
- Single.cs
- DiscoveryService.cs
- TargetParameterCountException.cs
- FontStyle.cs
- _BufferOffsetSize.cs
- MemberExpression.cs
- XPathAxisIterator.cs
- DoubleKeyFrameCollection.cs
- Polyline.cs
- DesignBinding.cs
- CalendarKeyboardHelper.cs
- SqlUserDefinedAggregateAttribute.cs
- compensatingcollection.cs
- SafeNativeMethods.cs
- DispatcherTimer.cs
- ContextMenuStripGroupCollection.cs
- TypeUtils.cs
- FrameDimension.cs
- ClientApiGenerator.cs
- PersonalizationProviderHelper.cs
- DurableInstanceContextProvider.cs
- FigureParagraph.cs
- View.cs
- VisualStyleRenderer.cs
- TdsEnums.cs
- input.cs
- XamlTypeMapperSchemaContext.cs
- ListView.cs
- ListViewItem.cs
- X509IssuerSerialKeyIdentifierClause.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- ListViewItem.cs
- ScaleTransform.cs
- ObjectListGeneralPage.cs
- Divide.cs
- HttpsHostedTransportConfiguration.cs
- DataGrid.cs
- DataGridViewDataErrorEventArgs.cs
- webbrowsersite.cs
- KeyConverter.cs
- DisplayInformation.cs
- ContainerControl.cs
- SignHashRequest.cs
- ControlAdapter.cs
- SchemaImporterExtensionsSection.cs
- DataSourceXmlSerializer.cs
- Size.cs
- ToolStripProgressBar.cs