internal bool TryGetPropertySetter(string name, out ComMethodDesc method, Type limitType) { EnsureScanDefinedMethods(); if (ComBinderHelpers.PreferPut(limitType)) { return(_comTypeDesc.Puts.TryGetValue(name, out method) || _comTypeDesc.PutRefs.TryGetValue(name, out method)); } else { return(_comTypeDesc.PutRefs.TryGetValue(name, out method) || _comTypeDesc.Puts.TryGetValue(name, out method)); } }
internal bool TryGetPropertySetterExplicit(string name, out ComMethodDesc method, Type limitType) { EnsureScanDefinedMethods(); // TODO: We have a thread-safety issue here right now // TODO: since we are mutating _funcs array // TODO: The workaround is to use Hashtable (which is thread-safe // TODO: on read operations) to fetch the value out. int dispId; int hresult = GetIDsOfNames(_dispatchObject, name, out dispId); if (hresult == ComHresults.S_OK) { // we do not know whether we have put or putref here // and we will not guess and pretend we found both. ComMethodDesc put = new ComMethodDesc(name, dispId, ComTypes.INVOKEKIND.INVOKE_PROPERTYPUT); _comTypeDesc.Puts.Add(name, put); ComMethodDesc putref = new ComMethodDesc(name, dispId, ComTypes.INVOKEKIND.INVOKE_PROPERTYPUTREF); _comTypeDesc.PutRefs.Add(name, putref); if (ComBinderHelpers.PreferPut(limitType)) { method = put; } else { method = putref; } return(true); } else if (hresult == ComHresults.DISP_E_UNKNOWNNAME) { method = null; return(false); } else { throw Error.CouldNotGetDispId(name, string.Format(CultureInfo.InvariantCulture, "0x{1:X})", hresult)); } }