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;
Dictionary baseTypeToInterfaceMethod;
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
- StringComparer.cs
- ComplexTypeEmitter.cs
- PolicyUnit.cs
- PersonalizableTypeEntry.cs
- Point3DKeyFrameCollection.cs
- BeginStoryboard.cs
- WebPartHeaderCloseVerb.cs
- PassportAuthentication.cs
- XmlCharCheckingReader.cs
- GPStream.cs
- FamilyMap.cs
- ConstraintStruct.cs
- InfoCardBaseException.cs
- BuildManager.cs
- PseudoWebRequest.cs
- validation.cs
- DrawListViewItemEventArgs.cs
- WebPartTransformerCollection.cs
- Currency.cs
- DeferredReference.cs
- EventProviderWriter.cs
- StateMachineDesignerPaint.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ListComponentEditor.cs
- ServicePointManagerElement.cs
- TreeNodeEventArgs.cs
- EnumerableRowCollectionExtensions.cs
- EntityViewGenerationConstants.cs
- StringDictionary.cs
- transactioncontext.cs
- TemplateBindingExtension.cs
- MembershipSection.cs
- PowerEase.cs
- FtpWebRequest.cs
- SharedConnectionInfo.cs
- TextUtf8RawTextWriter.cs
- PageParserFilter.cs
- SizeAnimationUsingKeyFrames.cs
- ValidationError.cs
- InvalidCastException.cs
- PropertyManager.cs
- WriteLine.cs
- TypeSystem.cs
- ActivityExecutionContextCollection.cs
- TextTreeRootTextBlock.cs
- TextRenderer.cs
- XamlGridLengthSerializer.cs
- SoapAttributeOverrides.cs
- ScriptResourceHandler.cs
- Logging.cs
- DynamicUpdateCommand.cs
- MainMenu.cs
- DataColumn.cs
- InvalidPrinterException.cs
- AffineTransform3D.cs
- KeyGestureConverter.cs
- MediaContext.cs
- InputBindingCollection.cs
- Parser.cs
- LineGeometry.cs
- DeclaredTypeValidator.cs
- ObjectStorage.cs
- ToolStripDropDownItemDesigner.cs
- ISO2022Encoding.cs
- BuiltInExpr.cs
- ControlIdConverter.cs
- AsmxEndpointPickerExtension.cs
- TableItemStyle.cs
- ILGenerator.cs
- OutputCacheSection.cs
- DiscreteKeyFrames.cs
- ApplicationHost.cs
- BindingsCollection.cs
- XmlMessageFormatter.cs
- Bold.cs
- ValidationRuleCollection.cs
- ToggleProviderWrapper.cs
- SessionEndingEventArgs.cs
- ClipboardProcessor.cs
- ToolStripPanelRenderEventArgs.cs
- CompareValidator.cs
- PageHandlerFactory.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- BamlTreeNode.cs
- BStrWrapper.cs
- FrameSecurityDescriptor.cs
- WS2007FederationHttpBinding.cs
- EllipseGeometry.cs
- RuleSettings.cs
- DesignerTransactionCloseEvent.cs
- WpfGeneratedKnownTypes.cs
- GroupItemAutomationPeer.cs
- FileDialogCustomPlacesCollection.cs
- OneWayBindingElement.cs
- HttpWebRequest.cs
- PriorityQueue.cs
- FolderBrowserDialogDesigner.cs
- PerformanceCounterPermissionAttribute.cs
- SqlBulkCopyColumnMappingCollection.cs
- UIElement3D.cs