Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / ComIntegration / TearOffProxy.cs / 1 / TearOffProxy.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.ComIntegration { using System; using System.ServiceModel.Channels; using System.Runtime.InteropServices; using System.Runtime.Remoting.Proxies; using System.Runtime.Remoting.Messaging; using System.Runtime.Remoting.Services; using System.Runtime.Remoting; using System.Runtime.Serialization; using System.ServiceModel; using System.Reflection; using System.Collections.Generic; internal class TearOffProxy : RealProxy, IDisposable { ICreateServiceChannel serviceChannelCreator; DictionarybaseTypeToInterfaceMethod; internal TearOffProxy (ICreateServiceChannel serviceChannelCreator, Type proxiedType) : base (proxiedType) { if (serviceChannelCreator == null) { DiagnosticUtility.DebugAssert("ServiceChannelCreator cannot be null"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } this.serviceChannelCreator = serviceChannelCreator; baseTypeToInterfaceMethod = new Dictionary (); } public override IMessage Invoke(IMessage message) { RealProxy delegatingProxy = null; IMethodCallMessage msg = message as IMethodCallMessage; try { delegatingProxy = serviceChannelCreator.CreateChannel (); } catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) throw; return new ReturnMessage (DiagnosticUtility.ExceptionUtility.ThrowHelperError (new COMException (e.GetBaseException().Message, Marshal.GetHRForException (e.GetBaseException()))), msg); } MethodBase typeMethod = msg.MethodBase; IRemotingTypeInfo typeInfo = delegatingProxy as IRemotingTypeInfo; if (typeInfo == null) { DiagnosticUtility.DebugAssert("Type Info cannot be null"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } if (typeInfo.CanCastTo (typeMethod.DeclaringType, null)) { IMessage msgReturned = delegatingProxy.Invoke (message); ReturnMessage returnMsg = msgReturned as ReturnMessage; if ((returnMsg == null) || (returnMsg.Exception == null)) return msgReturned; else return new ReturnMessage (DiagnosticUtility.ExceptionUtility.ThrowHelperError (new COMException (returnMsg.Exception.GetBaseException().Message, Marshal.GetHRForException (returnMsg.Exception.GetBaseException()))), msg); } else { return new ReturnMessage (DiagnosticUtility.ExceptionUtility.ThrowHelperError (new COMException (SR.GetString(SR.OperationNotFound, typeMethod.Name), HR.DISP_E_UNKNOWNNAME)), msg); } } void IDisposable.Dispose () { serviceChannelCreator = null; } } } // 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
- FontSource.cs
- StoreItemCollection.cs
- OdbcDataAdapter.cs
- SystemIPGlobalProperties.cs
- EntityDataSourceWrapper.cs
- StaticFileHandler.cs
- DurableEnlistmentState.cs
- EntityDataSourceStatementEditor.cs
- MarshalByRefObject.cs
- PackageDigitalSignatureManager.cs
- PackWebResponse.cs
- DataGridViewRowHeaderCell.cs
- FieldBuilder.cs
- MailDefinition.cs
- SQLInt64.cs
- GridItemProviderWrapper.cs
- PolyQuadraticBezierSegment.cs
- ImmutablePropertyDescriptorGridEntry.cs
- DeleteIndexBinder.cs
- Operators.cs
- MimeFormatter.cs
- DynamicILGenerator.cs
- SHA1Managed.cs
- DataPointer.cs
- SQLString.cs
- ButtonBaseAdapter.cs
- LinearGradientBrush.cs
- CompilationLock.cs
- AsyncWaitHandle.cs
- BinaryMessageFormatter.cs
- ToolTipService.cs
- CellNormalizer.cs
- PermissionListSet.cs
- Connector.xaml.cs
- GlobalId.cs
- X509Chain.cs
- Attributes.cs
- WebControlAdapter.cs
- Assembly.cs
- MdiWindowListItemConverter.cs
- GlobalEventManager.cs
- x509store.cs
- SignedXmlDebugLog.cs
- Section.cs
- StylusDownEventArgs.cs
- SubMenuStyleCollection.cs
- WebConfigManager.cs
- IRCollection.cs
- DecoderReplacementFallback.cs
- DataControlField.cs
- PositiveTimeSpanValidator.cs
- XmlWellformedWriterHelpers.cs
- ObjectStateEntry.cs
- CollectionsUtil.cs
- DesignerDataSchemaClass.cs
- ReaderOutput.cs
- OdbcEnvironmentHandle.cs
- TreeNodeEventArgs.cs
- OneToOneMappingSerializer.cs
- RangeBase.cs
- RouteParameter.cs
- CounterSampleCalculator.cs
- UnitySerializationHolder.cs
- DataGridColumn.cs
- TimeSpanConverter.cs
- HwndSourceParameters.cs
- TreeSet.cs
- CaseInsensitiveComparer.cs
- BackStopAuthenticationModule.cs
- GradientStopCollection.cs
- ComponentSerializationService.cs
- DefaultValueConverter.cs
- BaseTemplateBuildProvider.cs
- NameValueCollection.cs
- ComboBox.cs
- EncryptedKeyIdentifierClause.cs
- FormCollection.cs
- SmiRecordBuffer.cs
- IgnoreFileBuildProvider.cs
- BindableAttribute.cs
- DataGridViewCellLinkedList.cs
- Matrix.cs
- WindowsListViewItemCheckBox.cs
- PropertyManager.cs
- SqlClientWrapperSmiStream.cs
- EventItfInfo.cs
- QueryStringParameter.cs
- ScriptBehaviorDescriptor.cs
- ToolStripRenderer.cs
- BitArray.cs
- Merger.cs
- FrameSecurityDescriptor.cs
- RequestCacheEntry.cs
- Stylus.cs
- ControlAdapter.cs
- XPathSelfQuery.cs
- ValidationManager.cs
- ItemCheckedEvent.cs
- DesignColumnCollection.cs
- EdmItemError.cs