protected ObservableObject()
 {
     _bindingMessage = new ObservableMessage {
         Sender = this
     };
     _binder = new ModelBinder(this);
 }
示例#2
0
        /// <summary>
        ///     Handle all change notification here
        /// </summary>
        /// <param name="m"></param>
        public virtual void OnBindingMessage(ObservableMessage m)
        {
            // ignore if editor
            if (!Application.isPlaying)
            {
                return;
            }

            if (Model == null)
            {
                return;
            }

            if (!enabled)
            {
                return;
            }

            var bindings = GetBindingInfos().Where(o => o.MemberName == m.Name && o.Action != null).ToArray();

            foreach (var binding in bindings)
            {
                if (binding.Action != null)
                {
                    binding.Action(m.Value);
                }
            }
        }
示例#3
0
 void _bindableInstance_OnBindingUpdate(ObservableMessage obj)
 {
     if (_onBindingEvent != null)
     {
         _onBindingEvent(obj);
     }
 }
        /// <summary>
        ///     Posts a message down to data binders
        /// </summary>
        /// <param name="message"></param>
        private void RelayBindingUpdate(ObservableMessage message)
        {
            var array = Binders.ToArray();

            for (var i = 0; i < array.Length; i++)
            {
                array[i].OnBindingMessage(message);
            }

            OnBindingMessage(message);
        }
 /// <summary>
 /// Virtual, Initializes Binder
 /// </summary>
 protected virtual void Awake()
 {
     if (_bindingMessage == null)
     {
         _bindingMessage = new ObservableMessage {
             Sender = this
         }
     }
     ;
     if (_binder == null)
     {
         _binder = new ModelBinder(this);
     }
 }
        public void OnBindingMessage(ObservableMessage message)
        {
            if (message.Name == PropertyName)
            {
                DataInstance = message.Value;

                var array = Binders.ToArray();

                for (var i = 0; i < array.Length; i++)
                {
                    array[i].OnBindingRefresh();
                }
            }
        }
        public virtual void Dispose()
        {
            if (_binder != null)
            {
                _binder.Dispose();
            }

            if (_bindingMessage != null)
            {
                _bindingMessage.Dispose();
            }

            _bindingMessage = null;
            _binder         = null;
        }
        public void RaiseBindingUpdate(string memberName, object paramater)
        {
            if (_bindingMessage == null)
            {
                _bindingMessage = new ObservableMessage {
                    Sender = this
                }
            }
            ;

            Binder.RaiseBindingUpdate(memberName, paramater);

            if (_onBindingEvent != null)
            {
                _bindingMessage.Name  = memberName;
                _bindingMessage.Value = paramater;
                _onBindingEvent(_bindingMessage);
            }
        }
示例#9
0
        public void Dispose()
        {
            _bindingMessage.Dispose();

            if (_bindableInstance != null)
            {
                _bindableInstance.OnBindingUpdate -= _bindableInstance_OnBindingUpdate;
            }
            if (_notifyInstance != null)
            {
                _notifyInstance.PropertyChanged -= _notifyInstance_PropertyChanged;
            }
            _myType           = null;
            _instance         = null;
            _insanceBehaviour = null;
            _bindableInstance = null;
            _bindingMessage   = null;
            _notifyInstance   = null;
        }