Example #1
0
        private void Initialize(object rcw, Guid sourceIid)
        {
            _sourceIid    = sourceIid;
            _adviseCookie = -1;

            Debug.Assert(_connectionPoint == null, "re-initializing event sink w/o unadvising from connection point");

            ComTypes.IConnectionPointContainer cpc = rcw as ComTypes.IConnectionPointContainer;
            if (cpc == null)
            {
                throw Error.COMObjectDoesNotSupportEvents();
            }

            cpc.FindConnectionPoint(ref _sourceIid, out _connectionPoint);
            if (_connectionPoint == null)
            {
                throw Error.COMObjectDoesNotSupportSourceInterface();
            }

            // Read the comments for ComEventSinkProxy about why we need it
            ComEventSinkProxy proxy = new ComEventSinkProxy(this, _sourceIid);

            _connectionPoint.Advise(proxy.GetTransparentProxy(), out _adviseCookie);
        }
Example #2
0
        private void Initialize(object rcw, Guid sourceIid) {
            _sourceIid = sourceIid;
            _adviseCookie = -1;

            Debug.Assert(_connectionPoint == null, "re-initializing event sink w/o unadvising from connection point");

            ComTypes.IConnectionPointContainer cpc = rcw as ComTypes.IConnectionPointContainer;
            if (cpc == null)
                throw Error.COMObjectDoesNotSupportEvents();

            cpc.FindConnectionPoint(ref _sourceIid, out _connectionPoint);
            if (_connectionPoint == null)
                throw Error.COMObjectDoesNotSupportSourceInterface();

            // Read the comments for ComEventSinkProxy about why we need it
            ComEventSinkProxy proxy = new ComEventSinkProxy(this, _sourceIid);
            _connectionPoint.Advise(proxy.GetTransparentProxy(), out _adviseCookie);
        }