Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / PeerNode.cs / 1 / PeerNode.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel { using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.ServiceModel.Dispatcher; using System.ServiceModel.Channels; using System.Threading; public sealed class PeerNode : IOnlineStatus { PeerNodeImplementation innerNode = null; SynchronizationContext synchronizationContext = null; MessageEncodingBindingElement encoderElement; internal PeerNode(PeerNodeImplementation peerNode) { this.innerNode = peerNode; } public event EventHandler Offline; public event EventHandler Online; internal void FireOffline(object source, EventArgs args) { FireEvent(Offline, source, args); } internal void FireOnline(object source, EventArgs args) { FireEvent(Online, source, args); } void FireEvent(EventHandler handler, object source, EventArgs args) { if(handler != null) { try { SynchronizationContext context = synchronizationContext; if(context != null) { context.Send( delegate (object state) { handler(source, args); }, null); } else { handler(source, args); } } catch(Exception e) { if(DiagnosticUtility.IsFatal(e)) throw; throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(SR.GetString(SR.NotificationException), e); } } } public bool IsOnline { get { return InnerNode.IsOnline; } } internal bool IsOpen { get { return InnerNode.IsOpen; } } public int Port { get { return InnerNode.ListenerPort; } } public PeerMessagePropagationFilter MessagePropagationFilter { get { return InnerNode.MessagePropagationFilter; } set { InnerNode.MessagePropagationFilter = value; } } internal void OnOpen() { synchronizationContext = ThreadBehavior.GetCurrentSynchronizationContext(); this.innerNode.Offline += FireOffline; this.innerNode.Online += FireOnline; this.innerNode.EncodingElement = this.encoderElement; } internal void OnClose() { this.innerNode.Offline -= FireOffline; this.innerNode.Online -= FireOnline; synchronizationContext = null; } internal PeerNodeImplementation InnerNode { get { return innerNode; } } public void RefreshConnection() { PeerNodeImplementation node = InnerNode; if(node != null) { node.RefreshConnection(); } } public override string ToString() { if(this.IsOpen) { return SR.GetString(SR.PeerNodeToStringFormat, this.InnerNode.MeshId, this.InnerNode.NodeId, this.IsOnline, this.IsOpen, this.Port); } else { return SR.GetString(SR.PeerNodeToStringFormat, "", -1, this.IsOnline, this.IsOpen, -1); } } private MessageEncodingBindingElement EncodingElement { get {return this.encoderElement;} set {this.encoderElement = value;} } } } // 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
- SecurityElement.cs
- NavigationWindow.cs
- ErrorHandler.cs
- TypeProvider.cs
- ListControlBoundActionList.cs
- Send.cs
- ArcSegment.cs
- DisplayMemberTemplateSelector.cs
- BitmapEncoder.cs
- TimeEnumHelper.cs
- entityreference_tresulttype.cs
- SecurityUtils.cs
- ScaleTransform3D.cs
- ClientBuildManager.cs
- DoubleUtil.cs
- TypeLoadException.cs
- ScrollEvent.cs
- SetStoryboardSpeedRatio.cs
- WindowsListViewItemCheckBox.cs
- SqlDataSourceCommandEventArgs.cs
- TableAutomationPeer.cs
- AutoGeneratedFieldProperties.cs
- MembershipUser.cs
- BrushMappingModeValidation.cs
- DataGridViewHeaderCell.cs
- SystemMulticastIPAddressInformation.cs
- EnumerableRowCollectionExtensions.cs
- InvalidDataException.cs
- AuthenticationService.cs
- RuntimeWrappedException.cs
- InertiaExpansionBehavior.cs
- TemplateInstanceAttribute.cs
- SqlTopReducer.cs
- RegularExpressionValidator.cs
- PeerTransportListenAddressValidatorAttribute.cs
- DesignerCategoryAttribute.cs
- WebControlParameterProxy.cs
- TextPatternIdentifiers.cs
- UnsafePeerToPeerMethods.cs
- EntityClassGenerator.cs
- InputLanguageEventArgs.cs
- BulletedListEventArgs.cs
- COM2PictureConverter.cs
- Quaternion.cs
- ConnectionInterfaceCollection.cs
- LocalFileSettingsProvider.cs
- StickyNoteContentControl.cs
- SocketInformation.cs
- SecurityTokenValidationException.cs
- DataBinder.cs
- BindingMemberInfo.cs
- RangeValuePattern.cs
- SafeEventHandle.cs
- ReferenceConverter.cs
- SapiAttributeParser.cs
- QilInvokeEarlyBound.cs
- EnvironmentPermission.cs
- PointCollectionValueSerializer.cs
- PathData.cs
- XDeferredAxisSource.cs
- HttpModuleActionCollection.cs
- BamlCollectionHolder.cs
- EditorZoneBase.cs
- Literal.cs
- DataGridBoolColumn.cs
- CryptoKeySecurity.cs
- SystemResourceHost.cs
- ScriptingSectionGroup.cs
- WebPartActionVerb.cs
- SiteMapNodeItem.cs
- XmlHierarchicalDataSourceView.cs
- OdbcEnvironment.cs
- SmtpNetworkElement.cs
- StrokeDescriptor.cs
- ErrorCodes.cs
- SequenceDesigner.cs
- DBAsyncResult.cs
- ExpressionPrefixAttribute.cs
- SqlCaseSimplifier.cs
- X509CertificateChain.cs
- EntityDesignerBuildProvider.cs
- MulticastIPAddressInformationCollection.cs
- CodeRemoveEventStatement.cs
- PathData.cs
- MonthCalendar.cs
- LinqDataSourceValidationException.cs
- RelatedEnd.cs
- XPathDescendantIterator.cs
- RotateTransform3D.cs
- TaskFormBase.cs
- DataView.cs
- ProfileParameter.cs
- TrackingProfile.cs
- FontCacheLogic.cs
- LocationSectionRecord.cs
- DataRecordObjectView.cs
- OleDbConnectionFactory.cs
- HandledMouseEvent.cs
- DataSourceIDConverter.cs
- HMACMD5.cs