Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Dispatcher / ClientRuntime.cs / 1 / ClientRuntime.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Dispatcher { using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Diagnostics; using System.ServiceModel.Channels; using System.ServiceModel.Security; public sealed class ClientRuntime { bool addTransactionFlowProperties = true; Type callbackProxyType; ProxyBehaviorCollectionchannelInitializers; string contractName; string contractNamespace; Type contractProxyType; DispatchRuntime dispatchRuntime; IdentityVerifier identityVerifier; ProxyBehaviorCollection interactiveChannelInitializers; ProxyBehaviorCollection messageInspectors; OperationCollection operations; IClientOperationSelector operationSelector; ImmutableClientRuntime runtime; ClientOperation unhandled; bool useSynchronizationContext = true; Uri via; SharedRuntimeState shared; int maxFaultSize; internal ClientRuntime(DispatchRuntime dispatchRuntime, SharedRuntimeState shared) : this(dispatchRuntime.EndpointDispatcher.ContractName, dispatchRuntime.EndpointDispatcher.ContractNamespace, shared) { if (dispatchRuntime == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatchRuntime"); this.dispatchRuntime = dispatchRuntime; this.shared = shared; DiagnosticUtility.DebugAssert(shared.IsOnServer, "Server constructor called on client?"); } internal ClientRuntime(string contractName, string contractNamespace) : this(contractName, contractNamespace, new SharedRuntimeState(false)) { DiagnosticUtility.DebugAssert(!shared.IsOnServer, "Client constructor called on server?"); } ClientRuntime(string contractName, string contractNamespace, SharedRuntimeState shared) { this.contractName = contractName; this.contractNamespace = contractNamespace; this.shared = shared; this.operations = new OperationCollection(this); this.channelInitializers = new ProxyBehaviorCollection (this); this.messageInspectors = new ProxyBehaviorCollection (this); this.interactiveChannelInitializers = new ProxyBehaviorCollection (this); this.unhandled = new ClientOperation(this, "*", MessageHeaders.WildcardAction, MessageHeaders.WildcardAction); this.unhandled.InternalFormatter = new MessageOperationFormatter(); this.maxFaultSize = TransportDefaults.MaxFaultSize; } internal bool AddTransactionFlowProperties { get { return this.addTransactionFlowProperties; } set { lock (this.ThisLock) { this.InvalidateRuntime(); this.addTransactionFlowProperties = value; } } } public Type CallbackClientType { get { return this.callbackProxyType; } set { lock (this.ThisLock) { this.InvalidateRuntime(); this.callbackProxyType = value; } } } public SynchronizedCollection ChannelInitializers { get { return this.channelInitializers; } } public string ContractName { get { return this.contractName; } } public string ContractNamespace { get { return this.contractNamespace; } } public Type ContractClientType { get { return this.contractProxyType; } set { lock (this.ThisLock) { this.InvalidateRuntime(); this.contractProxyType = value; } } } internal IdentityVerifier IdentityVerifier { get { if (this.identityVerifier == null) { this.identityVerifier = IdentityVerifier.CreateDefault(); } return this.identityVerifier; } set { if (value == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); } this.InvalidateRuntime(); this.identityVerifier = value; } } public Uri Via { get { return this.via;} set { lock (this.ThisLock) { this.InvalidateRuntime(); this.via = value; } } } public bool ValidateMustUnderstand { get { return this.shared.ValidateMustUnderstand; } set { lock (this.ThisLock) { this.InvalidateRuntime(); this.shared.ValidateMustUnderstand = value; } } } internal DispatchRuntime DispatchRuntime { get { return this.dispatchRuntime; } } public DispatchRuntime CallbackDispatchRuntime { get { if (this.dispatchRuntime == null) this.dispatchRuntime = new DispatchRuntime(this, this.shared); return this.dispatchRuntime; } } internal bool EnableFaults { get { if (this.IsOnServer) { return this.dispatchRuntime.EnableFaults; } else { return this.shared.EnableFaults; } } set { lock (this.ThisLock) { if (this.IsOnServer) { string text = SR.GetString(SR.SFxSetEnableFaultsOnChannelDispatcher0); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(text)); } else { this.InvalidateRuntime(); this.shared.EnableFaults = value; } } } } public SynchronizedCollection InteractiveChannelInitializers { get { return this.interactiveChannelInitializers; } } public int MaxFaultSize { get { return this.maxFaultSize; } set { this.InvalidateRuntime(); this.maxFaultSize = value; } } internal bool IsOnServer { get { return this.shared.IsOnServer; } } public bool ManualAddressing { get { if (this.IsOnServer) { return this.dispatchRuntime.ManualAddressing; } else { return this.shared.ManualAddressing; } } set { lock (this.ThisLock) { if (this.IsOnServer) { string text = SR.GetString(SR.SFxSetManualAddresssingOnChannelDispatcher0); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(text)); } else { this.InvalidateRuntime(); this.shared.ManualAddressing = value; } } } } internal int MaxParameterInspectors { get { lock (this.ThisLock) { int max = 0; for (int i=0; i MessageInspectors { get { return this.messageInspectors; } } public SynchronizedKeyedCollection Operations { get { return this.operations; } } public IClientOperationSelector OperationSelector { get { return this.operationSelector; } set { lock (this.ThisLock) { this.InvalidateRuntime(); this.operationSelector = value; } } } internal object ThisLock { get { return this.shared; } } public ClientOperation UnhandledClientOperation { get { return this.unhandled; } } internal bool UseSynchronizationContext { get { return this.useSynchronizationContext; } set { lock (this.ThisLock) { this.InvalidateRuntime(); this.useSynchronizationContext = value; } } } internal T[] GetArray (SynchronizedCollection collection) { lock (collection.SyncRoot) { if (collection.Count == 0) { return EmptyArray .Instance; } else { T[] array = new T[collection.Count]; collection.CopyTo(array, 0); return array; } } } internal ImmutableClientRuntime GetRuntime() { lock (this.ThisLock) { if (this.runtime == null) this.runtime = new ImmutableClientRuntime(this); return this.runtime; } } internal void InvalidateRuntime() { lock (this.ThisLock) { this.shared.ThrowIfImmutable(); this.runtime = null; } } internal void LockDownProperties() { this.shared.LockDownProperties(); } internal SynchronizedCollection NewBehaviorCollection () { return new ProxyBehaviorCollection (this); } class ProxyBehaviorCollection : SynchronizedCollection { ClientRuntime outer; internal ProxyBehaviorCollection(ClientRuntime outer) : base(outer.ThisLock) { this.outer = outer; } protected override void ClearItems() { this.outer.InvalidateRuntime(); base.ClearItems(); } protected override void InsertItem(int index, T item) { if (item == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); } this.outer.InvalidateRuntime(); base.InsertItem(index, item); } protected override void RemoveItem(int index) { this.outer.InvalidateRuntime(); base.RemoveItem(index); } protected override void SetItem(int index, T item) { if (item == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); } this.outer.InvalidateRuntime(); base.SetItem(index, item); } } class OperationCollection : SynchronizedKeyedCollection { ClientRuntime outer; internal OperationCollection(ClientRuntime outer) : base(outer.ThisLock) { this.outer = outer; } protected override void ClearItems() { this.outer.InvalidateRuntime(); base.ClearItems(); } protected override string GetKeyForItem(ClientOperation item) { return item.Name; } protected override void InsertItem(int index, ClientOperation item) { if (item == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); if (item.Parent != this.outer) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.SFxMismatchedOperationParent)); this.outer.InvalidateRuntime(); base.InsertItem(index, item); } protected override void RemoveItem(int index) { this.outer.InvalidateRuntime(); base.RemoveItem(index); } protected override void SetItem(int index, ClientOperation item) { if (item == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); if (item.Parent != this.outer) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.SFxMismatchedOperationParent)); this.outer.InvalidateRuntime(); base.SetItem(index, item); } } } } // 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
- SqlError.cs
- Util.cs
- DesignerTransaction.cs
- AssociationTypeEmitter.cs
- HandledEventArgs.cs
- MethodBuilderInstantiation.cs
- SafeFileMappingHandle.cs
- CompiledQueryCacheKey.cs
- SoapFaultCodes.cs
- VisualStyleElement.cs
- ExecutedRoutedEventArgs.cs
- OleDbRowUpdatedEvent.cs
- CommonProperties.cs
- compensatingcollection.cs
- InfoCardKeyedHashAlgorithm.cs
- ListViewInsertionMark.cs
- DetailsViewDeletedEventArgs.cs
- ThrowHelper.cs
- WsatAdminException.cs
- SizeConverter.cs
- AuthenticationSection.cs
- XmlConvert.cs
- DefaultCommandConverter.cs
- ValidationRule.cs
- DataGridViewCellValueEventArgs.cs
- SortKey.cs
- CodeArrayIndexerExpression.cs
- SerialReceived.cs
- XmlArrayAttribute.cs
- PocoEntityKeyStrategy.cs
- ImageSource.cs
- DesignerDataParameter.cs
- ThreadAbortException.cs
- MenuItemBinding.cs
- ScrollItemProviderWrapper.cs
- SystemTcpStatistics.cs
- DataObjectCopyingEventArgs.cs
- WmpBitmapEncoder.cs
- GenericTypeParameterBuilder.cs
- HtmlInputCheckBox.cs
- MarkupObject.cs
- UriExt.cs
- SettingsProviderCollection.cs
- COM2ComponentEditor.cs
- StringBuilder.cs
- Geometry3D.cs
- PageBuildProvider.cs
- EntityStoreSchemaGenerator.cs
- HybridDictionary.cs
- BamlRecordWriter.cs
- XPathDocument.cs
- PrintControllerWithStatusDialog.cs
- LabelLiteral.cs
- ConfigurationPropertyAttribute.cs
- ErrorFormatterPage.cs
- PageClientProxyGenerator.cs
- TdsParserStateObject.cs
- CodeVariableReferenceExpression.cs
- DefaultCommandConverter.cs
- OracleConnectionFactory.cs
- Ray3DHitTestResult.cs
- IteratorDescriptor.cs
- SyntaxCheck.cs
- NameValueCache.cs
- AccessibleObject.cs
- ExpressionCopier.cs
- JavascriptXmlWriterWrapper.cs
- FormsAuthenticationTicket.cs
- SoapIncludeAttribute.cs
- XhtmlBasicPhoneCallAdapter.cs
- RegexCapture.cs
- SqlDataSourceCache.cs
- TextRangeEditTables.cs
- TemplateEditingService.cs
- EmbeddedObject.cs
- ClaimTypeElementCollection.cs
- Style.cs
- AssemblyCollection.cs
- ToolStripSeparator.cs
- ApplicationException.cs
- CodeLabeledStatement.cs
- SiteMapNode.cs
- FloaterParaClient.cs
- Knowncolors.cs
- NotFiniteNumberException.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- NonParentingControl.cs
- AffineTransform3D.cs
- HttpDictionary.cs
- ProcessManager.cs
- wmiutil.cs
- Image.cs
- __ComObject.cs
- EventSetter.cs
- LambdaExpression.cs
- OutputCacheProfile.cs
- ApplicationGesture.cs
- ConfigXmlSignificantWhitespace.cs
- OdbcConnectionHandle.cs
- PointValueSerializer.cs