public bool TryGetSetItem(out DispCallable value) { if (_setter != null) { value = _setter; return(true); } return(SlowTryGetSetItem(out value)); }
public bool SlowTryGetSetItem(out DispCallable value) { EnsureScanDefinedMethods(); ComMethodDesc methodDesc = _comTypeDesc.SetItem; // The following attempts to get a method corresponding to "[PROPERTYPUT, DISPID(0)] HRESULT Item(...)". // However, without type information, we really don't know whether or not we have a property setter. // All we can do is verify that the found dispId is DISPID_VALUE. So, if we find a dispId of DISPID_VALUE, // we happily package it up as a property setter; otherwise, it's a no go... if (methodDesc == null) { int dispId; string name = "Item"; int hresult = GetIDsOfNames(_dispatchObject, name, out dispId); if (hresult == ComHresults.DISP_E_UNKNOWNNAME) { value = null; return(false); } else if (hresult != ComHresults.S_OK) { throw Error.CouldNotGetDispId(name, string.Format(CultureInfo.InvariantCulture, "0x{1:X})", hresult)); } else if (dispId != ComDispIds.DISPID_VALUE) { value = null; return(false); } methodDesc = new ComMethodDesc(name, dispId, ComTypes.INVOKEKIND.INVOKE_PROPERTYPUT); _comTypeDesc.SetItem = methodDesc; } Interlocked.CompareExchange( ref _setter, new DispCallable(_dispatchObject, methodDesc), null); value = _setter; return(true); }
public bool SlowTryGetSetItem(out DispCallable value) { EnsureScanDefinedMethods(); ComMethodDesc methodDesc = _comTypeDesc.SetItem; // The following attempts to get a method corresponding to "[PROPERTYPUT, DISPID(0)] HRESULT Item(...)". // However, without type information, we really don't know whether or not we have a property setter. // All we can do is verify that the found dispId is DISPID_VALUE. So, if we find a dispId of DISPID_VALUE, // we happily package it up as a property setter; otherwise, it's a no go... if (methodDesc == null) { int dispId; string name = "Item"; int hresult = GetIDsOfNames(_dispatchObject, name, out dispId); if (hresult == ComHresults.DISP_E_UNKNOWNNAME) { value = null; return false; } else if (hresult != ComHresults.S_OK) { throw Error.CouldNotGetDispId(name, string.Format(CultureInfo.InvariantCulture, "0x{1:X})", hresult)); } else if (dispId != ComDispIds.DISPID_VALUE) { value = null; return false; } methodDesc = new ComMethodDesc(name, dispId, ComTypes.INVOKEKIND.INVOKE_PROPERTYPUT); _comTypeDesc.SetItem = methodDesc; } Interlocked.CompareExchange( ref _setter, new DispCallable(_dispatchObject, methodDesc), null); value = _setter; return true; }
public bool TryGetSetItem(out DispCallable value) { if (_setter != null) { value = _setter; return true; } return SlowTryGetSetItem(out value); }
internal DispCallableMetaObject(Expression expression, DispCallable callable) : base(expression, Restrictions.Empty, callable) { _callable = callable; }