Exemplo n.º 1
0
        public PropertyMountPoint(object origin, PropertyPath propertyPath)
        {
            Guard.ThrowIfNull(origin, nameof(origin));
            Guard.ThrowIfNull(propertyPath, nameof(propertyPath));

            this.referencedTargettedProperty = GetReferencedPropertyInfo(origin, propertyPath, 0);
        }
Exemplo n.º 2
0
        private IEnumerable<PropertyDefinition> GetSubscriptionsRecursive(object current, PropertyPath propertyPath, int i)
        {
            var subscriptions = new List<PropertyDefinition>();
            var inpc = current as INotifyPropertyChanged;

            if (inpc == null)
            {
                return subscriptions;
            }

            var nextPropertyName = propertyPath.Chunks[i];
            subscriptions.Add(new PropertyDefinition(inpc, nextPropertyName));

            if (i < _propertyPath.Chunks.Length)
            {
                var currentObjectTypeInfo = current.GetType().GetTypeInfo();
                var nextProperty = currentObjectTypeInfo.GetDeclaredProperty(nextPropertyName);
                var nextInstance = nextProperty.GetValue(current);

                if (i < _propertyPath.Chunks.Length - 1)
                {
                    subscriptions.AddRange(GetSubscriptionsRecursive(nextInstance, propertyPath, i + 1));
                }
            }

            return subscriptions;
        }
Exemplo n.º 3
0
 public XamlBindingDefinition(Control target, PerspexProperty targetProperty, PropertyPath sourcePropertyPath, BindingMode bindingMode)
 {
     _target = target;
     _targetProperty = targetProperty;
     _sourcePropertyPath = sourcePropertyPath;
     _bindingMode = bindingMode;
 }
Exemplo n.º 4
0
        public ObservablePropertyBranch(object root, PropertyPath propertyPath)
        {
            Guard.ThrowIfNull(root, nameof(root));
            Guard.ThrowIfNull(propertyPath, nameof(propertyPath));

            this.root = root;
            this.propertyPath = propertyPath;
            this.mountPoint = new PropertyMountPoint(root, propertyPath);
            var subscriptions = this.GetInpcNodes();
            this.Changed = this.CreateObservableFromNodes(subscriptions);
        }
Exemplo n.º 5
0
        public ObservablePropertyBranch(object instance, PropertyPath propertyPath)
        {
            Guard.ThrowIfNull(instance, nameof(instance));
            Guard.ThrowIfNull(propertyPath, nameof(propertyPath));

            _instance = instance;
            _propertyPath = propertyPath;
            _mountPoint = new PropertyMountPoint(instance, propertyPath);
            var properties = GetPropertiesThatRaiseNotifications();
            Values = CreateUnifiedObservableFromNodes(properties);
        }
Exemplo n.º 6
0
        private static TargettedProperty GetReferencedPropertyInfo(object current, PropertyPath propertyPath, int level)
        {
            var typeInfo = current.GetType().GetTypeInfo();
            var leftPropertyInfo = typeInfo.GetDeclaredProperty(propertyPath.Chunks[level]);

            if (level == propertyPath.Chunks.Length - 1)
            {
                return new TargettedProperty(current, leftPropertyInfo);
            }

            var nextInstance = leftPropertyInfo.GetValue(current);

            return GetReferencedPropertyInfo(nextInstance, propertyPath, level + 1);
        }
 public BindingSource(PropertyPath sourcePropertyPath, object source)
 {
     _sourcePropertyPath = sourcePropertyPath;
     _source = source;
 }
Exemplo n.º 8
0
 public BindingDefinitionBuilder()
 {
     _bindingMode = BindingMode.Default;
     _sourcePropertyPath = new PropertyPath(string.Empty);
 }