/// <summary> /// Creates a connection between a data object and an advisory sink. This method is called by an object /// that supports an advisory sink and enables the advisory sink to be notified of changes in the object's data.</summary> /// <returns>This method supports the standard return values E_INVALIDARG, E_UNEXPECTED, and E_OUTOFMEMORY, /// as well as the following: /// ValueDescriptionS_OK -- The advisory connection was created. /// E_NOTIMPL -- This method is not implemented on the data object. /// DV_E_LINDEX -- There is an invalid value for <see cref="F:System.Runtime.InteropServices.ComTypes.FORMATETC.lindex"/>; /// currently, only -1 is supported. /// DV_E_FORMATETC -- There is an invalid value for the <paramref name="pFormatetc"/> parameter. /// OLE_E_ADVISENOTSUPPORTED -- The data object does not support change notification.</returns> /// <param name="pFormatetc">A <see cref="T:System.Runtime.InteropServices.ComTypes.FORMATETC"/> structure, /// passed by reference, that defines the format, target device, aspect, and medium that will be used for /// future notifications.</param> /// <param name="advf">One of the ADVF values that specifies a group of flags for controlling the advisory /// connection.</param> /// <param name="adviseSink">A pointer to the IAdviseSink interface on the advisory sink that will receive /// the change notification.</param> /// <param name="connection">When this method returns, contains a pointer to a DWORD token that identifies /// this connection. You can use this token later to delete the advisory connection by passing it to /// <see cref="M:System.Runtime.InteropServices.ComTypes.IDataObject.DUnadvise(System.Int32)"/>. /// If this value is zero, the connection was not established. This parameter is passed uninitialized.</param> public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { // Check that the specified advisory flags are supported. const ADVF c_advfAllowed = ADVF.ADVF_NODATA | ADVF.ADVF_ONLYONCE | ADVF.ADVF_PRIMEFIRST; if ((int)((advf | c_advfAllowed) ^ c_advfAllowed) != 0) { connection = 0; return OLE_E_ADVISENOTSUPPORTED; } // Create and insert an entry for the connection list var entry = new AdviseEntry { Format = pFormatetc, Advf = advf, Sink = adviseSink, }; m_connections.Add(m_nextConnectionId, entry); connection = m_nextConnectionId; m_nextConnectionId++; // If the ADVF_PRIMEFIRST flag is specified and the data exists, // raise the DataChanged event now. if ((advf & ADVF.ADVF_PRIMEFIRST) == ADVF.ADVF_PRIMEFIRST) { OleData dataEntry; if (GetDataEntry(ref pFormatetc, out dataEntry)) RaiseDataChanged(connection, ref dataEntry); } return 0; }
/// <summary> /// Adds an advisory connection for the specified format. /// </summary> /// <param name="pFormatetc">The format for which this sink is called for changes.</param> /// <param name="advf">Advisory flags to specify callback behavior.</param> /// <param name="adviseSink">The IAdviseSink to call for this connection.</param> /// <param name="connection">Returns the new connection's ID.</param> /// <returns>An HRESULT.</returns> public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { // Check that the specified advisory flags are supported. const ADVF ADVF_ALLOWED = ADVF.ADVF_NODATA | ADVF.ADVF_ONLYONCE | ADVF.ADVF_PRIMEFIRST; if ((int) ((advf | ADVF_ALLOWED) ^ ADVF_ALLOWED) != 0) { connection = 0; return OLE_E_ADVISENOTSUPPORTED; } // Create and insert an entry for the connection list var entry = new AdviseEntry(ref pFormatetc, advf, adviseSink); connections.Add(nextConnectionId, entry); connection = nextConnectionId; nextConnectionId++; // If the ADVF_PRIMEFIRST flag is specified and the data exists, // raise the DataChanged event now. if ((advf & ADVF.ADVF_PRIMEFIRST) == ADVF.ADVF_PRIMEFIRST) { KeyValuePair<FORMATETC, STGMEDIUM> dataEntry; if (GetDataEntry(ref pFormatetc, out dataEntry)) RaiseDataChanged(connection, ref dataEntry); } // S_OK return 0; }
public static int Advise(this System.Windows.IDataObject dataObject, IAdviseSink sink, string format, ADVF advf) { FORMATETC formatETC; DataObjectExtensions.FillFormatETC(format, TYMED.TYMED_HGLOBAL | TYMED.TYMED_FILE | TYMED.TYMED_ISTREAM | TYMED.TYMED_ISTORAGE | TYMED.TYMED_GDI | TYMED.TYMED_MFPICT | TYMED.TYMED_ENHMF, out formatETC); int connection; int errorCode = ((System.Runtime.InteropServices.ComTypes.IDataObject)dataObject).DAdvise(ref formatETC, advf, sink, out connection); if (errorCode != 0) Marshal.ThrowExceptionForHR(errorCode); return connection; }
public int DAdvise(ref FORMATETC formatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { if (((advf | ADVF.ADVF_NODATA | ADVF.ADVF_PRIMEFIRST | ADVF.ADVF_ONLYONCE) ^ (ADVF.ADVF_NODATA | ADVF.ADVF_PRIMEFIRST | ADVF.ADVF_ONLYONCE)) != (ADVF)0) { connection = 0; return -2147221501; } else { this.connections.Add(this.nextConnectionId, new AdviseEntry(ref formatetc, advf, adviseSink)); connection = this.nextConnectionId; ++this.nextConnectionId; KeyValuePair<FORMATETC, STGMEDIUM> dataEntry; if ((advf & ADVF.ADVF_PRIMEFIRST) == ADVF.ADVF_PRIMEFIRST && this.GetDataEntry(ref formatetc, out dataEntry)) this.RaiseDataChanged(connection, ref dataEntry); return 0; } }
int IComDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink pAdvSink, out int pdwConnection) { if (_innerData is OleConverter) { return ((OleConverter)_innerData).OleDataObject.DAdvise(ref pFormatetc, advf, pAdvSink, out pdwConnection); } pdwConnection = 0; return (NativeMethods.E_NOTIMPL); }
int IDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { Marshal.ThrowExceptionForHR(NativeMethods.OLE_E_ADVISENOTSUPPORTED); throw new NotImplementedException(); }
public AdviseEntry(ref FORMATETC format, ADVF advf, IAdviseSink sink) { this.format = format; this.advf = advf; this.sink = sink; }
public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { throw new NotImplementedException(); }
int IComDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink pAdvSink, out int pdwConnection) { Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "DAdvise"); if (innerData is OleConverter) { return ((OleConverter)innerData).OleDataObject.DAdvise(ref pFormatetc, advf, pAdvSink, out pdwConnection); } pdwConnection = 0; return (NativeMethods.E_NOTIMPL); }
/// <summary> /// Sets up an advisory connection to the data object. /// </summary> /// <param name="dataObject">The data object on which to set the advisory connection.</param> /// <param name="sink">The advisory sink.</param> /// <param name="format">The format on which to callback on.</param> /// <param name="advf">Advisory flags. Can be 0.</param> /// <returns>The ID of the newly created advisory connection.</returns> public static int Advise(this IDataObject dataObject, IAdviseSink sink, string format, ADVF advf) { // Internally, we'll listen for any TYMED FORMATETC formatETC; FillFormatETC(format, TYMED_ANY, out formatETC); int connection; int hr = dataObject.DAdvise(ref formatETC, advf, sink, out connection); if (hr != 0) Marshal.ThrowExceptionForHR(hr); return connection; }
public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { throw Marshal.GetExceptionForHR(OLE_E_ADVISENOTSUPPORTED); }
public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { throw Marshal.GetExceptionForHR(OLE_E_ADVISENOTSUPPORTED); }
public int DAdvise([In] ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { connection = -1; return((int)S_FALSE); }
int IComDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { connection = 0; return(HRESULT.E_NOTIMPL.Code); }
int IDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { Marshal.ThrowExceptionForHR(NativeMethods.OLE_E_ADVISENOTSUPPORTED); throw new NotImplementedException(); }
int System.Runtime.InteropServices.ComTypes.IDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink pAdvSink, out int pdwConnection) { throw null; }
public AdviseEntry(ref FORMATETC format, ADVF advf, IAdviseSink sink) { this.format = format; this.advf = advf; this.sink = sink; }
public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { return DataObject.DAdvise(ref pFormatetc, advf, adviseSink, out connection); }
int System.Runtime.InteropServices.ComTypes.IDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { throw new NotImplementedException(); //return _innerComDataObject.DAdvise(ref pFormatetc, advf, adviseSink, out connection); }
int System.Runtime.InteropServices.ComTypes.IDataObject.DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { Marshal.ThrowExceptionForHR(NativeMethods.OLE_E_ADVISENOTSUPPORTED); throw new NotImplementedException(); }
public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { throw new NotImplementedException(); }
public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { Console.WriteLine("DAdvise"); throw new NotImplementedException(); }
public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { if (null == DataAdviseHolder) { ComDebug.ReportInfo("{0}.IDataObject.DAdvise -> not implemented!", this.GetType().Name); connection = 0; return ComReturnValue.E_NOTIMPL; } else { ComDebug.ReportInfo("{0}.IDataObject.DAdvise {1}, {2}", this.GetType().Name, DataObjectHelper.FormatEtcToString(pFormatetc), advf); try { if (pFormatetc.cfFormat != 0) // if a special format is required { int res = QueryGetData(ref pFormatetc); // ask the render helper for availability of that format if (res != ComReturnValue.S_OK) // if the required format is not available { connection = 0; // return an invalid connection cookie return res; // and the error } } FORMATETC etc = pFormatetc; int conn = 0; DataAdviseHolder.Advise((IDataObject)this, ref etc, advf, adviseSink, out conn); connection = conn; return ComReturnValue.NOERROR; } catch (Exception e) { ComDebug.ReportError("{0}.IDataObject.DAdvise exception: {1}", this.GetType().Name, e); throw; } } }
public int DAdvise(ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection) { return(innerData.DAdvise(pFormatetc, advf, adviseSink, out connection)); }
// Combination of all non-null TYMEDs /// <summary> /// Sets up an advisory connection to the data object. /// </summary> /// <param name="dataObject">The data object on which to set the advisory connection.</param> /// <param name="sink">The advisory sink.</param> /// <param name="format">The format on which to callback on.</param> /// <param name="advf">Advisory flags. Can be 0.</param> /// <returns>The ID of the newly created advisory connection.</returns> public static int Advise(this IDataObject dataObject, IAdviseSink sink, string format, ADVF advf) { // Internally, we'll listen for any TYMED FORMATETC formatETC; FillFormatETC(format, TYMED_ANY, out formatETC); int connection; int hr = dataObject.DAdvise(ref formatETC, advf, sink, out connection); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } return(connection); }
private static unsafe HRESULT DAdvise(IntPtr thisPtr, FORMATETC *pFormatetc, ADVF advf, IntPtr pAdviseSink, int *connection) { var instance = ComInterfaceDispatch.GetInstance <IDataObject>((ComInterfaceDispatch *)thisPtr); var adviseSink = (IAdviseSink)Marshal.GetObjectForIUnknown(pAdviseSink); return((HRESULT)instance.DAdvise(ref *pFormatetc, advf, adviseSink, out *connection)); }