Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / PeerChannelFactory.cs / 1 / PeerChannelFactory.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Net; using System.Diagnostics; using System.ServiceModel; using System.Runtime.Serialization; using System.Xml; interface IPeerFactory : ITransportFactorySettings { IPAddress ListenIPAddress { get; } int Port { get; } XmlDictionaryReaderQuotas ReaderQuotas{get;} PeerResolver Resolver { get; } PeerSecurityManager SecurityManager { get; } PeerNodeImplementation PrivatePeerNode { get; set; } long MaxBufferPoolSize{ get; } } sealed class PeerChannelFactory: TransportChannelFactory , IPeerFactory { // settings passed to PeerNode IPAddress listenIPAddress; int port; PeerResolver resolver; PeerSecurityManager securityManager; XmlDictionaryReaderQuotas readerQuotas; ISecurityCapabilities securityCapabilities; // use a private mesh (PeerNode) rather than creating/retrieving one from the registry. // used as a test hook to allow multiple PeerNode instances per app domain PeerNodeImplementation privatePeerNode; internal PeerChannelFactory(PeerTransportBindingElement bindingElement, BindingContext context, PeerResolver peerResolver) : base(bindingElement, context) { this.listenIPAddress = bindingElement.ListenIPAddress; this.port = bindingElement.Port; this.resolver = peerResolver; readerQuotas = new XmlDictionaryReaderQuotas(); BinaryMessageEncodingBindingElement encoder = context.Binding.Elements.Find (); if(encoder != null) encoder.ReaderQuotas.CopyTo(this.readerQuotas); else EncoderDefaults.ReaderQuotas.CopyTo(this.readerQuotas); this.securityManager = PeerSecurityManager.Create(bindingElement.Security, context, this.readerQuotas); this.securityCapabilities = bindingElement.GetProperty (context); } public IPAddress ListenIPAddress { get { return listenIPAddress; } } public int Port { get { return port; } } public XmlDictionaryReaderQuotas ReaderQuotas { get { return this.readerQuotas; } } public PeerResolver Resolver { get { return resolver; } } public override string Scheme { get { return PeerStrings.Scheme; } } public PeerNodeImplementation PrivatePeerNode { get { return privatePeerNode; } set { privatePeerNode = value; } } public PeerSecurityManager SecurityManager { get { return this.securityManager; } set { this.securityManager = value; } } public override T GetProperty () { if(typeof(T) == typeof(PeerChannelFactory )) { return (T) (object) this; } else if(typeof(T) == typeof(IPeerFactory)) { return (T) (object) this; } else if(typeof(T) == typeof(PeerNodeImplementation)) { return (T) (object) privatePeerNode; } else if (typeof(T) == typeof(ISecurityCapabilities)) { return (T)(object)this.securityCapabilities; } return base.GetProperty (); } protected override void OnOpen(TimeSpan timeout) { } protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) { return new CompletedAsyncResult(callback, state); } protected override void OnEndOpen(IAsyncResult result) { CompletedAsyncResult.End(result); } protected override TChannel OnCreateChannel(EndpointAddress to, Uri via) { base.ValidateScheme(via); PeerNodeImplementation peerNode = null; PeerNodeImplementation.Registration registration = null; // use the private PeerNode if it has been configured and matches the channel // otherwise have the channel look for one or create a new one if (privatePeerNode != null && via.Host == privatePeerNode.MeshId) { peerNode = privatePeerNode; } else { registration = new PeerNodeImplementation.Registration(via, this); } if (typeof(TChannel) == typeof(IOutputChannel)) { return (TChannel)(object)new PeerOutputChannel(peerNode, registration, this, to, via, this.MessageVersion); } // typeof(TChannel) == typeof(IDuplexChannel) // 'to' is both the remote address and the local address PeerDuplexChannel duplexChannel = new PeerDuplexChannel(peerNode, registration, this, to, via); PeerMessageDispatcher .PeerMessageQueueAdapter queueHandler = new PeerMessageDispatcher .PeerMessageQueueAdapter(duplexChannel); PeerMessageDispatcher dispatcher = new PeerMessageDispatcher (queueHandler, duplexChannel.InnerNode, this, to, via); duplexChannel.Dispatcher = dispatcher; return (TChannel)(object)duplexChannel; } } } // 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
- EntityContainerEmitter.cs
- ComponentCollection.cs
- WebProxyScriptElement.cs
- _ShellExpression.cs
- DataControlPagerLinkButton.cs
- FakeModelPropertyImpl.cs
- WebAdminConfigurationHelper.cs
- WorkflowApplication.cs
- IgnoreFileBuildProvider.cs
- ItemList.cs
- ExpressionConverter.cs
- EmbeddedMailObjectsCollection.cs
- BaseComponentEditor.cs
- HttpCachePolicyElement.cs
- EnvelopedSignatureTransform.cs
- SqlClientPermission.cs
- RichTextBoxAutomationPeer.cs
- TextSelectionProcessor.cs
- OrderByExpression.cs
- ComponentResourceKey.cs
- __ConsoleStream.cs
- FontDialog.cs
- DateTimeConstantAttribute.cs
- ElapsedEventArgs.cs
- DeclarativeCatalogPart.cs
- ComponentRenameEvent.cs
- TextAutomationPeer.cs
- WebPartCatalogCloseVerb.cs
- UnsafeNativeMethods.cs
- OperationAbortedException.cs
- validation.cs
- StyleCollection.cs
- RefreshEventArgs.cs
- CollectionExtensions.cs
- VectorValueSerializer.cs
- MarkupObject.cs
- GZipStream.cs
- GridEntryCollection.cs
- EqualityArray.cs
- ErrorProvider.cs
- ParallelTimeline.cs
- GeneralTransform.cs
- CorrelationQuery.cs
- DataGridToolTip.cs
- Matrix.cs
- ClientUrlResolverWrapper.cs
- DataControlCommands.cs
- SiteMapSection.cs
- ContainerVisual.cs
- AttributeUsageAttribute.cs
- SortKey.cs
- SystemIPAddressInformation.cs
- TextBoxAutomationPeer.cs
- FreezableCollection.cs
- DesignDataSource.cs
- DataBinding.cs
- DataTableClearEvent.cs
- WebPartCatalogAddVerb.cs
- CodeSnippetExpression.cs
- DBSchemaTable.cs
- BinaryCommonClasses.cs
- CustomErrorCollection.cs
- CommonRemoteMemoryBlock.cs
- TabItemWrapperAutomationPeer.cs
- Error.cs
- XmlAtomicValue.cs
- RuntimeEnvironment.cs
- CriticalFinalizerObject.cs
- DataGridTextColumn.cs
- QuaternionConverter.cs
- PropertyGroupDescription.cs
- Enum.cs
- TypedReference.cs
- Timer.cs
- AssemblyResourceLoader.cs
- CodeTypeReference.cs
- StorageMappingItemLoader.cs
- ActivityInterfaces.cs
- RC2CryptoServiceProvider.cs
- ComPlusAuthorization.cs
- NoResizeSelectionBorderGlyph.cs
- FixedSOMLineRanges.cs
- CachedCompositeFamily.cs
- ConfigurationValue.cs
- ClientRuntime.cs
- SiteMapNode.cs
- SecurityHelper.cs
- SqlConnectionStringBuilder.cs
- SharedUtils.cs
- CloseSequence.cs
- MulticastDelegate.cs
- ValueSerializer.cs
- StoreAnnotationsMap.cs
- EntityCollection.cs
- DbProviderServices.cs
- TextAutomationPeer.cs
- FontUnit.cs
- MessageParameterAttribute.cs
- _RequestCacheProtocol.cs
- CodeIdentifiers.cs