internal GeckoAttribute(nsIDOMAttr attr) : base(attr) { this.DomAttr = attr; // since a reference is stored in the base class, we only need a weak reference here Marshal.ChangeWrapperHandleStrength(attr, true); }
internal GeckoDocument(nsIDOMHTMLDocument document) : base(document) { this.DomDocument = document; // since a reference is stored in the base class, we only need a weak reference here Marshal.ChangeWrapperHandleStrength(DomDocument, true); }
public override void SetCOMIUnknown(IntPtr i) { bool flag = false; if ((this._gitCookie == 0) && !Util.ExtendedLifetime) { try { if (i == IntPtr.Zero) { flag = true; i = Marshal.GetIUnknownForObject(this.GetTransparentProxy()); } this._gitCookie = Proxy.StoreObject(i); if (this._proxyTearoff != null) { Marshal.ChangeWrapperHandleStrength(this._proxyTearoff, true); } Marshal.ChangeWrapperHandleStrength(this.GetTransparentProxy(), true); } finally { if (flag && (i != IntPtr.Zero)) { Marshal.Release(i); } } } }
// TODO: @cleanup: Move to ServicedComponentProxy private static void ReconnectForPooling(ServicedComponentProxy scp) { Type serverType = scp.GetProxiedType(); bool fIsJitActivated = scp.IsJitActivated; bool fIsTypePooled = scp.IsObjectPooled; bool fAreMethodsSecure = scp.AreMethodsSecure; ProxyTearoff tearoff = null; DBG.Assert(fIsTypePooled == true, "CS.ReconnectForPooling called on a non-pooled proxy!"); DBG.Info(DBG.SC, "CS.ReconnectForPooling (type is pooled) " + serverType); ServicedComponent server = scp.DisconnectForPooling(ref tearoff); // now setup a new SCP that we can add to the pool // with the current server object and the CCW ServicedComponentProxy newscp = new ServicedComponentProxy(serverType, fIsJitActivated, fIsTypePooled, fAreMethodsSecure, false); DBG.Info(DBG.SC, "CS.ReconnectForPooling (calling newscp.ConnectForPooling)"); newscp.ConnectForPooling(scp, server, tearoff, false); // switch the CCW from oldtp to new tp DBG.Info(DBG.SC, "CS.ReconnectForPooling (SwitchingWrappers)"); EnterpriseServicesHelper.SwitchWrappers(scp, newscp); // Strengthen the CCW: The only reference now held is // the reference from the pool. if (tearoff != null) { Marshal.ChangeWrapperHandleStrength(tearoff, false); } Marshal.ChangeWrapperHandleStrength(newscp.GetTransparentProxy(), false); }
internal GeckoElement(nsIDOMHTMLElement element) : base(element) { this.DomElement = element; this.DomNSElement = (nsIDOMNSHTMLElement)element; // since a reference is stored in the base class, we only need a weak reference here Marshal.ChangeWrapperHandleStrength(DomNSElement, true); }
internal GeckoElement(nsIDOMHTMLElement element) : base(element) { this.DomElement = element; this.DomNSElement = (nsIDOMNSElement)element; this.DomNSHTMLElement = (nsIDOMNSHTMLElement)element; Marshal.ChangeWrapperHandleStrength(DomNSElement, true); Marshal.ChangeWrapperHandleStrength(DomNSHTMLElement, true); }
public void ChangeWrapperHandleStrength_ObjectNotCollectible_ThrowsNotSupportedException() { AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module"); TypeBuilder typeBuilder = moduleBuilder.DefineType("Type"); Type type = typeBuilder.CreateType(); object o = Activator.CreateInstance(type); Assert.Throws <NotSupportedException>(() => Marshal.ChangeWrapperHandleStrength(o, fIsWeak: true)); }
internal GeckoElement(nsIDOMHTMLElement element) : base(element) { DomElement = element; DomNSElement = multiversion <nsIDOMNSElement> .Cast(element); DomNSHTMLElement = multiversion <nsIDOMNSHTMLElement> .Cast(element); // since a reference is stored in the base class, we only need weak references here Marshal.ChangeWrapperHandleStrength(DomNSElement, true); Marshal.ChangeWrapperHandleStrength(DomNSHTMLElement, true); }
internal GeckoElement(nsIDOMHTMLElement element) : base(element) { this.DomElement = element; this.DomNSElement = (nsIDOMNSElement)element; this.DomNSHTMLElement = (nsIDOMNSHTMLElement)element; if (Xpcom.IsDotNet) // TODO FIXME: ChangeWrapperHandleStrength not implemented in mono { // since a reference is stored in the base class, we only need weak references here Marshal.ChangeWrapperHandleStrength(DomNSElement, true); Marshal.ChangeWrapperHandleStrength(DomNSHTMLElement, true); } }
private static void ReconnectForPooling(ServicedComponentProxy scp) { Type proxiedType = scp.GetProxiedType(); bool isJitActivated = scp.IsJitActivated; bool isObjectPooled = scp.IsObjectPooled; bool areMethodsSecure = scp.AreMethodsSecure; ProxyTearoff proxyTearoff = null; ServicedComponent server = scp.DisconnectForPooling(ref proxyTearoff); ServicedComponentProxy newcp = new ServicedComponentProxy(proxiedType, isJitActivated, isObjectPooled, areMethodsSecure, false); newcp.ConnectForPooling(scp, server, proxyTearoff, false); EnterpriseServicesHelper.SwitchWrappers(scp, newcp); if (proxyTearoff != null) { Marshal.ChangeWrapperHandleStrength(proxyTearoff, false); } Marshal.ChangeWrapperHandleStrength(newcp.GetTransparentProxy(), false); }
void IManagedObjectInfo.SetWrapperStrength(bool bStrong) { Marshal.ChangeWrapperHandleStrength(((ServicedComponentProxy)this._scp.Target).GetTransparentProxy(), !bStrong); }
public void ChangeWrapperHandleStrength_Unix_ThrowsPlatformNotSupportedException() { Assert.Throws <PlatformNotSupportedException>(() => Marshal.ChangeWrapperHandleStrength(null, fIsWeak: true)); Assert.Throws <PlatformNotSupportedException>(() => Marshal.ChangeWrapperHandleStrength(null, fIsWeak: false)); }
public void ChangeWrapperHandleStrength_NullObject_ThrowsArgumentNullException() { AssertExtensions.Throws <ArgumentNullException>("otp", () => Marshal.ChangeWrapperHandleStrength(null, fIsWeak: true)); AssertExtensions.Throws <ArgumentNullException>("otp", () => Marshal.ChangeWrapperHandleStrength(null, fIsWeak: false)); }
public void ChangeWrapperHandleStrength_ValidObject_Success(object otp) { Marshal.ChangeWrapperHandleStrength(otp, fIsWeak: true); Marshal.ChangeWrapperHandleStrength(otp, fIsWeak: false); }