Esempio n. 1
0
        public void Render()
        {
            var currentBindingContext = _currentBindingContext;

            if (currentBindingContext != null)
            {
                var inspector = new InstanceInspector(currentBindingContext);
                var key       = currentBindingContext.GetType().FullName;
                SendInstanceUpdate(key, inspector.Serialize());
            }
        }
Esempio n. 2
0
        private void OnCurrentPageBindingContextChanged(object bindingContext)
        {
            if (bindingContext is INotifyPropertyChanged inpc)
            {
                if (_currentBindingContext != inpc)
                {
                    _currentBindingContextDisposable?.Dispose();

                    var instanceInspector = new InstanceInspector(inpc);

                    inpc.PropertyChanged += inpcPropertyChanged;

                    _currentBindingContext           = inpc;
                    _currentBindingContextDisposable = new ActionDisposable(() => inpc.PropertyChanged -= inpcPropertyChanged);

                    void inpcPropertyChanged(object sender, PropertyChangedEventArgs e)
                    {
                        var existingInspector = instanceInspector.Properties.FirstOrDefault(pi => pi.PropertyInfo.Name == e.PropertyName);

                        if (existingInspector != null)
                        {
                            existingInspector.UpdateValue(inpc);
                        }
                        else
                        {
                            // If property was added without our knowledge (dynamic stuff)
                            var properties = InstanceInspector.GetAllProperties(inpc);
                            var property   = properties.FirstOrDefault(p => p.Name == e.PropertyName);

                            if (property != null)
                            {
                                instanceInspector.Properties.Add(new PropertyInspector(property, inpc));
                            }
                        }

                        SendInstanceUpdate(instanceInspector.Key, instanceInspector.Serialize());
                    }

                    SendInstanceUpdate(instanceInspector.Key, instanceInspector.Serialize());
                }
            }
        }