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
- ZipIOExtraField.cs
- FrameworkTemplate.cs
- _HelperAsyncResults.cs
- DataServiceHostWrapper.cs
- ProfilePropertySettingsCollection.cs
- ContractDescription.cs
- DBSqlParser.cs
- UseLicense.cs
- wmiprovider.cs
- SoapReflector.cs
- DefaultValueTypeConverter.cs
- WindowsNonControl.cs
- FixedPageStructure.cs
- ArraySubsetEnumerator.cs
- UnmanagedMemoryStream.cs
- ServiceSettingsResponseInfo.cs
- DrawingState.cs
- GAC.cs
- DesignerActionTextItem.cs
- Color.cs
- NativeCompoundFileAPIs.cs
- BinHexEncoder.cs
- CompositeScriptReferenceEventArgs.cs
- DataGridTable.cs
- CompareValidator.cs
- ListView.cs
- ControlPager.cs
- TableCell.cs
- RuntimeComponentFilter.cs
- _NetRes.cs
- LockRecoveryTask.cs
- DeferredElementTreeState.cs
- VersionedStreamOwner.cs
- BindingCompleteEventArgs.cs
- ContainerParagraph.cs
- VisualStyleInformation.cs
- MD5HashHelper.cs
- UnsafeNativeMethods.cs
- RoleGroupCollection.cs
- ISessionStateStore.cs
- Point.cs
- SimpleFieldTemplateUserControl.cs
- UnsignedPublishLicense.cs
- CustomAttributeSerializer.cs
- DirectoryNotFoundException.cs
- TextEditorMouse.cs
- ExtendedProperty.cs
- WebPartChrome.cs
- ColorKeyFrameCollection.cs
- ScriptControlManager.cs
- AppDomainProtocolHandler.cs
- ColorPalette.cs
- XmlNamespaceMapping.cs
- MembershipPasswordException.cs
- ToolBar.cs
- TimeStampChecker.cs
- AggregateException.cs
- WebPartHeaderCloseVerb.cs
- ProcessModelSection.cs
- GridViewRowPresenter.cs
- XmlQualifiedName.cs
- SingleObjectCollection.cs
- Attribute.cs
- CodeCompiler.cs
- EntityRecordInfo.cs
- SpanIndex.cs
- CompoundFileStreamReference.cs
- MULTI_QI.cs
- StringUtil.cs
- FormatStringEditor.cs
- SystemMulticastIPAddressInformation.cs
- ConfigXmlElement.cs
- AllMembershipCondition.cs
- EventProvider.cs
- ToolStripTextBox.cs
- OperationDescription.cs
- sqlpipe.cs
- keycontainerpermission.cs
- KnownBoxes.cs
- PreservationFileWriter.cs
- Model3D.cs
- WinFormsSecurity.cs
- ExpanderAutomationPeer.cs
- IgnoreFlushAndCloseStream.cs
- TextOptionsInternal.cs
- LazyTextWriterCreator.cs
- InfoCardProofToken.cs
- TextFormatterContext.cs
- TabControl.cs
- CqlBlock.cs
- BindingGroup.cs
- Soap.cs
- NameTable.cs
- FormsAuthentication.cs
- AxHostDesigner.cs
- MSG.cs
- log.cs
- CodeConstructor.cs
- SchemaImporter.cs
- SocketStream.cs