Esempio n. 1
1
		public EDocument_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 2
0
        public void Notify(object eventID, object data)
        {
            IEventBinding binding = GetBinding(eventID) as IEventBinding;

            if (binding != null && binding.value != null)
            {
                object[] callbacks = (binding.value as object[]).Clone() as object[];
                if (callbacks != null && callbacks.Length > 0)
                {
                    for (int i = 0; i < callbacks.Length; i++)
                    {
                        object callback = callbacks[i];
                        if (callback == null)
                        {
                            continue;
                        }
                        if (callback is EventHandlerDelegate)
                        {
                            (callback as EventHandlerDelegate)();
                        }
                        else if (callback is EventHandlerDelegateEX)
                        {
                            (callback as EventHandlerDelegateEX)(data);
                        }
                    }
                }
            }
        }
        public void ReleaseCOMProxy()
        {
            IEventBinding typeEvent = this as IEventBinding;

            if (null != typeEvent)
            {
                typeEvent.DisposeSinkHelper();
            }

            // remove himself from parent childlist
            if (null != _parentObject)
            {
                _parentObject.RemoveChildObject(this);
                _parentObject = null;
            }

            // finally release himself
            if (null != _underlyingObject)
            {
                if (_underlyingObject is ICustomAdapter)
                {
                    // enumerator
                    ICustomAdapter adapter = (ICustomAdapter)_underlyingObject;
                    Marshal.ReleaseComObject(adapter.GetUnderlyingObject());
                }
                else
                {
                    Marshal.ReleaseComObject(_underlyingObject);
                }
                _underlyingObject = null;
            }
        }
Esempio n. 4
0
 private void AddBinding(IEventBinding binding)
 {
     if (!IsDisabled)
     {
         binding.Bind();
     }
     m_Bindings.Add(binding);
 }
Esempio n. 5
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass">target CoClass instance</param>
 public SinkHelper(ICOMObject eventClass)
 {
     if (null == eventClass)
     {
         throw new ArgumentNullException("eventClass");
     }
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
 }
Esempio n. 6
0
        public bool HasListener(object evt, EmptyCallback callback)
        {
            IEventBinding binding = GetBinding(evt) as IEventBinding;

            if (binding == null)
            {
                return(false);
            }
            return(binding.TypeForCallback(callback) != EventCallbackType.NOT_FOUND);
        }
Esempio n. 7
0
        public void Dispose()
        {
            IEventBinding eventBind = this as IEventBinding;

            if (null != eventBind)
            {
                eventBind.DisposeSinkHelper();
            }

            RemoveChildObjects();
            ReleaseCOMProxy();
        }
        public new void Dispose()
        {
            _isDisposed = true;

            // in case of object implements also event binding we dispose them
            IEventBinding eventBind = this as IEventBinding;

            if (null != eventBind)
            {
                eventBind.DisposeSinkHelper();
            }

            RemoveChildObjects();
            ReleaseCOMProxy();
        }
        public EventToCommandBinding(IEventBinding <TSource, TTarget, TEventArgs> binding, Expression <Func <TSource, TCommand> > commandExpression, Expression <Func <TTarget, bool> > canExecuteTargetPropertyExpression = null) :
            base(binding)
        {
            Check.NotNull(commandExpression, nameof(commandExpression));

            this.getCommand     = commandExpression.Compile();
            this.sourceRootNode = commandExpression.AsObservedNode();
            this.sourceRootNode.Observe(this.Source, this.WhenCommandChanged);

            if (canExecuteTargetPropertyExpression != null)
            {
                this.canExecuteTargetProperty = canExecuteTargetPropertyExpression.GetBindingExpression(this.Target);
                this.WhenCommandChanged();
            }
        }
Esempio n. 10
0
        public void ReleaseCOMProxy()
        {
            IEventBinding typeEvent = this as IEventBinding;

            if (null != typeEvent)
            {
                typeEvent.DisposeSinkHelper();
            }

            // remove himself from parent childlist
            if (null != _parentObject)
            {
                _parentObject.RemoveChildObject(this);
                _parentObject = null;
            }

            // finally release himself
            if (null != _comProxy)
            {
                Marshal.ReleaseComObject(_comProxy);
                _comProxy = null;
            }
        }
Esempio n. 11
0
 public FontEvents_SinkHelper(COMObject eventClass) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(_riid);
 }
		public _DPageWrapCtrlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 13
0
		public ISpreadsheetEventSink_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 14
0
		public ApplicationEvents_10_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 15
0
		public AccountSelectorEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 16
0
		public MAPIFolderEvents_12_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 17
0
		public _CustomXMLPartsEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
 public _dispReferencesEvents_SinkHelper(COMObject eventClass) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(_riid);
 }
 public NavigationPaneEvents_12_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
 public DispBoundObjectFrameEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
Esempio n. 21
0
		public _dispReferencesEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 22
0
        public void Dispatch(object eventType, object data)
        {
#if UNITY_EDITOR
            string eventTypeText = eventType.ToString();

            if (eventTypeText != eventTypeOld &&
                eventTypeText != "E_AppFixedUpdate" &&
                eventTypeText != "E_AppLateUpdate" &&
                eventTypeText != "E_AppUpdate")
            {
                UnityEngine.Debug.Log("<size=14><color=#808000>STRANGE IOC  Dispatch: " + eventTypeText + " </color></size>");
                eventTypeOld = eventTypeText;
            }
#endif
            //Scrub the data to make eventType and data conform if possible
            IEvent evt = conformDataToEvent(eventType, data);

            if (evt is IPoolable)
            {
                (evt as IPoolable).Retain();
            }

            bool continueDispatch = true;
            if (triggerClients != null)
            {
                isTriggeringClients = true;
                foreach (ITriggerable trigger in triggerClients)
                {
                    if (!trigger.Trigger(eventType, evt))
                    {
                        continueDispatch = false;
                        break;
                    }
                }
                if (triggerClientRemovals != null)
                {
                    flushRemovals();
                }
                isTriggeringClients = false;
            }

            if (!continueDispatch)
            {
                internalReleaseEvent(evt);
                return;
            }

            IEventBinding binding = GetBinding(eventType) as IEventBinding;
            if (binding == null)
            {
                internalReleaseEvent(evt);
                return;
            }

            object[] callbacks = (binding.value as object[]).Clone() as object[];
            if (callbacks == null)
            {
                internalReleaseEvent(evt);
                return;
            }
            for (int a = 0; a < callbacks.Length; a++)
            {
                object callback = callbacks[a];
                if (callback == null)
                {
                    continue;
                }

                callbacks[a] = null;

                object[] currentCallbacks = binding.value as object[];
                if (Array.IndexOf(currentCallbacks, callback) == -1)
                {
                    continue;
                }

                if (callback is EventCallback)
                {
                    invokeEventCallback(evt, callback as EventCallback);
                }
                else if (callback is EmptyCallback)
                {
                    (callback as EmptyCallback)();
                }
            }

            internalReleaseEvent(evt);
        }
 public DispWebBrowserControlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
Esempio n. 24
0
 public ISpreadsheetEventSink_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
		public DispPageHdrFtrInReportEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 26
0
 public EDataRecordset_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
Esempio n. 27
0
 public HTMLImgEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
Esempio n. 28
0
        public void Dispatch(object eventType, object data)
        {
            //Scrub the data to make eventType and data conform if possible
            IEvent evt = ConformDataToEvent(eventType, data);

            if (evt is IPoolable)
            {
                (evt as IPoolable).Retain();
            }

            bool continueDispatch = true;

            if (triggerClients != null)
            {
                isTriggeringClients = true;
                foreach (ITriggerable trigger in triggerClients)
                {
                    try
                    {
                        if (!trigger.Trigger(evt.type, evt))
                        {
                            continueDispatch = false;
                            break;
                        }
                    }
                    catch (Exception ex) //If trigger throws, we still want to cleanup!
                    {
                        InternalReleaseEvent(evt);
                        throw (ex);
                    }
                }
                if (triggerClientRemovals != null)
                {
                    FlushRemovals();
                }
                isTriggeringClients = false;
            }

            if (!continueDispatch)
            {
                InternalReleaseEvent(evt);
                return;
            }

            IEventBinding binding = GetBinding(evt.type) as IEventBinding;

            if (binding == null)
            {
                InternalReleaseEvent(evt);
                return;
            }

            object[] callbacks = (binding.value as object[]).Clone() as object[];
            if (callbacks == null)
            {
                InternalReleaseEvent(evt);
                return;
            }
            for (int a = 0; a < callbacks.Length; a++)
            {
                object callback = callbacks[a];
                if (callback == null)
                {
                    continue;
                }

                callbacks[a] = null;

                object[] currentCallbacks = binding.value as object[];
                if (Array.IndexOf(currentCallbacks, callback) == -1)
                {
                    continue;
                }

                if (callback is EventCallback)
                {
                    InvokeEventCallback(evt, callback as EventCallback);
                }
                else if (callback is EmptyCallback)
                {
                    (callback as EmptyCallback)();
                }
            }

            InternalReleaseEvent(evt);
        }
Esempio n. 29
0
		public IMsoEnvelopeVBEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 30
0
		public IProgressBarEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 31
0
		public OutlookBarPaneEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 32
0
 public DispPaletteButtonEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
		public NavigationGroupsEvents_12_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
		public HTMLOptionButtonElementEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 35
0
 public WeakPropertyChangedBinding(IEventBinding wrappedBinding)
 {
     this.wrappedBinding = new WeakReference <IEventBinding>(wrappedBinding);
 }
 public OlkBusinessCardControlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
Esempio n. 37
0
 public OutlookBarShortcutsEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
 public _CommandBarComboBoxEvents_SinkHelper(COMObject eventClass) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(_riid);
 }
Esempio n. 39
0
		public OlkTimeControlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 40
0
        public void Dispatch(object eventType, object data)
        {
            //Scrub the data to make eventType and data conform if possible
            if (eventType == null)
            {
                throw new EventDispatcherException("Attempt to Dispatch to null.\ndata: " + data, EventDispatcherExceptionType.EVENT_KEY_NULL);
            }
            else if (eventType is IEvent)
            {
                //Client provided a full-formed event
                data      = eventType;
                eventType = (data as IEvent).type;
            }
            else if (data == null)
            {
                //Client provided just an event ID. Create an event for injection
                data = new TmEvent(eventType, this, null);
            }
            else if (data is IEvent)
            {
                //Client provided both an evertType and a full-formed IEvent
                (data as IEvent).type = eventType;
            }
            else
            {
                //Client provided an eventType and some data which is not a IEvent.
                data = new TmEvent(eventType, this, data);
            }

            bool continueDispatch = true;

            if (triggerClients != null)
            {
                isTriggeringClients = true;
                foreach (ITriggerable trigger in triggerClients)
                {
                    if (!trigger.Trigger(eventType, data))
                    {
                        continueDispatch = false;
                    }
                }
                if (triggerClientRemovals != null)
                {
                    flushRemovals();
                }
                isTriggeringClients = false;
            }

            if (!continueDispatch)
            {
                return;
            }

            IEventBinding binding = GetBinding(eventType) as IEventBinding;

            if (binding == null)
            {
                return;
            }

            object[] callbacks = binding.value as object[];

            if (callbacks == null)
            {
                return;
            }

            int bb = callbacks.Length;

            for (int b = 0; b < bb; b++)
            {
                object   callback   = callbacks [b];
                object[] parameters = null;
                if (callback is EventCallback)
                {
                    parameters     = new object[1];
                    parameters [0] = data;
                    EventCallback evtCb = callback as EventCallback;

                    try
                    {
                        evtCb(parameters [0] as IEvent);
                    }
                    catch (InvalidCastException)
                    {
                        object tgt        = evtCb.Target;
                        string methodName = (callback as Delegate).Method.Name;
                        string message    = "An EventCallback is attempting an illegal cast. One possible reason is not typing the payload to IEvent in your callback. Another is illegal casting of the data.\nTarget class: " + tgt + " method: " + methodName;
                        throw new EventDispatcherException(message, EventDispatcherExceptionType.TARGET_INVOCATION);
                    }
                }
                else if (callback is EmptyCallback)
                {
                    parameters = new object[0];
                    EmptyCallback emptyCb = callback as EmptyCallback;
                    emptyCb();
                }
            }
        }
 public _dispCommandBarControlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
Esempio n. 42
0
        /// <summary>
        /// NetOffice method: dispose instance and all child instances
        /// </summary>
        /// <param name="disposeEventBinding">dispose event exported proxies with one or more event recipients</param>
        public virtual void Dispose(bool disposeEventBinding)
        {
            // skip check
            bool cancel = RaiseOnDispose();

            if (cancel)
            {
                return;
            }

            // in case object export events and
            // disposeEventBinding == true we dont remove the object from parents child list
            bool removeFromParent = true;

            // set disposed flag
            _isCurrentlyDisposing = true;

            // in case of object implements also event binding we dispose them
            IEventBinding eventBind = this as IEventBinding;

            if (disposeEventBinding)
            {
                if (!Object.ReferenceEquals(eventBind, null))
                {
                    eventBind.DisposeEventBridge();
                }
            }
            else
            {
                if (!Object.ReferenceEquals(eventBind, null) && (eventBind.EventBridgeInitialized))
                {
                    removeFromParent = false;
                }
            }

            // child proxy dispose
            DisposeChildInstances(disposeEventBinding);


            // remove himself from parent childlist
            if ((!Object.ReferenceEquals(_parentObject, null)) && (true == removeFromParent))
            {
                _parentObject.RemoveChildObject(this);
                _parentObject = null;
            }

            // call quit automaticly if wanted
            if (_callQuitInDispose)
            {
                CallQuit(Settings, Invoker, this);
            }

            // release proxy
            ReleaseCOMProxy();

            // clear supportList reference
            _listSupportedEntities = null;

            _isDisposed           = true;
            _isCurrentlyDisposing = false;
        }
Esempio n. 43
0
 public IMsoEnvelopeVBEvents_SinkHelper(COMObject eventClass) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(_riid);
 }
		public _BoundObjectFrameEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 45
0
		public HTMLInputImageEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
Esempio n. 46
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass">target CoClass instance</param>
 protected SinkHelper(ICOMObject eventClass)
 {
     _eventClass   = eventClass ?? throw new ArgumentNullException(nameof(eventClass));
     _eventBinding = eventClass as IEventBinding ?? throw new ArgumentOutOfRangeException(nameof(eventClass), "The event class object must implement IEventBinding interface.");
 }
Esempio n. 47
0
		public DispTextBoxEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
 public DispPageHdrFtrInReportEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
		public _ToggleButtonInOptionEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
		public HTMLXMLHttpRequestEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}