Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / ComIntegration / ComProxy.cs / 1 / ComProxy.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.ComIntegration { using System; using System.Runtime.InteropServices; using System.Collections.Generic; using System.ServiceModel; internal class ComProxy : IDisposable { IntPtr inner; IDisposable ccw; internal static ComProxy Create (IntPtr outer, object obj, IDisposable disp) { if (outer == IntPtr.Zero) { DiagnosticUtility.DebugAssert("Outer cannot be null"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } IntPtr inner = IntPtr.Zero; inner = Marshal.CreateAggregatedObject (outer, obj); int refCount = Marshal.AddRef (inner); // Workaround for the CLR ref count issue. if (3 == refCount) Marshal.Release (inner); Marshal.Release (inner); return new ComProxy (inner, disp); } internal ComProxy (IntPtr inner, IDisposable disp) { this.inner = inner; ccw = disp; } internal void QueryInterface (ref Guid riid, out IntPtr tearoff) { if (inner == IntPtr.Zero) { DiagnosticUtility.DebugAssert("Inner should not be Null at this point"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } int hr = Marshal.QueryInterface (inner, ref riid, out tearoff); if (hr != HR.S_OK) { DiagnosticUtility.DebugAssert("QueryInterface should succeed"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } } void IDisposable.Dispose() { Dispose(true); } void Dispose (bool disposing) { if (inner == IntPtr.Zero) { DiagnosticUtility.DebugAssert("Inner should not be Null at this point"); #pragma warning suppress 56519 // throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } Marshal.Release (inner); if (disposing) { if (ccw != null) ccw.Dispose (); } } public ComProxy Clone () { if (inner == IntPtr.Zero) { DiagnosticUtility.DebugAssert("Inner should not be Null at this point"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } Marshal.AddRef (inner); return new ComProxy (inner, 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
- TextTreePropertyUndoUnit.cs
- ThousandthOfEmRealPoints.cs
- BulletedListEventArgs.cs
- Calendar.cs
- PlainXmlSerializer.cs
- Line.cs
- AspNetHostingPermission.cs
- MetadataSerializer.cs
- FormsAuthenticationEventArgs.cs
- SmiGettersStream.cs
- unitconverter.cs
- XslAst.cs
- ContextInformation.cs
- BuildProvidersCompiler.cs
- ReadOnlyState.cs
- HashHelper.cs
- LinkClickEvent.cs
- Size.cs
- SQLUtility.cs
- TableLayout.cs
- DataControlFieldCollection.cs
- OptimisticConcurrencyException.cs
- SoapAttributeOverrides.cs
- ThreadExceptionDialog.cs
- ToolStripComboBox.cs
- SourceFilter.cs
- TdsParserSafeHandles.cs
- DBPropSet.cs
- CustomLineCap.cs
- SqlReferenceCollection.cs
- sqlnorm.cs
- TypeElement.cs
- ToolStripItemTextRenderEventArgs.cs
- LambdaCompiler.cs
- Tablet.cs
- StringFormat.cs
- ContentTypeSettingClientMessageFormatter.cs
- SQLDateTimeStorage.cs
- SystemIcmpV6Statistics.cs
- MissingManifestResourceException.cs
- TransformGroup.cs
- GestureRecognitionResult.cs
- PieceDirectory.cs
- CellParagraph.cs
- TemplateXamlParser.cs
- InputLangChangeEvent.cs
- PriorityQueue.cs
- EnumValAlphaComparer.cs
- EmissiveMaterial.cs
- DetailsViewPageEventArgs.cs
- SettingsContext.cs
- NamespaceQuery.cs
- SqlEnums.cs
- RunClient.cs
- ListSortDescription.cs
- RuntimeConfigLKG.cs
- DataSourceControl.cs
- AmbientLight.cs
- SimpleMailWebEventProvider.cs
- PageSetupDialog.cs
- DataGridTableStyleMappingNameEditor.cs
- DurableEnlistmentState.cs
- CodePageEncoding.cs
- WsatExtendedInformation.cs
- WmpBitmapDecoder.cs
- VisemeEventArgs.cs
- ClientTarget.cs
- RemoteWebConfigurationHostServer.cs
- TextSearch.cs
- SystemSounds.cs
- SystemResourceKey.cs
- StylusDevice.cs
- GradientStop.cs
- ExpressionEditorAttribute.cs
- ValueProviderWrapper.cs
- ScriptReference.cs
- BindableTemplateBuilder.cs
- PasswordDeriveBytes.cs
- CompensatableTransactionScopeActivityDesigner.cs
- MetadataArtifactLoaderFile.cs
- GetWinFXPath.cs
- Stackframe.cs
- SafeCertificateContext.cs
- SqlDataSourceSummaryPanel.cs
- UserControlParser.cs
- EdmScalarPropertyAttribute.cs
- PersonalizationDictionary.cs
- SerializationEventsCache.cs
- DataGridRowAutomationPeer.cs
- XmlSchemaInclude.cs
- JoinTreeSlot.cs
- MenuEventArgs.cs
- HttpCapabilitiesSectionHandler.cs
- FloaterParagraph.cs
- WebPartMenu.cs
- BrushValueSerializer.cs
- DataTableCollection.cs
- IIS7UserPrincipal.cs
- ListMarkerLine.cs
- EasingQuaternionKeyFrame.cs