Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyItemValue"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        public PropertyItemValue(PropertyItem property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            this._property = property;

            _hasSubProperties = property.Converter.GetPropertiesSupported();

            if (_hasSubProperties)
            {
                object value = property.GetValue();

                PropertyDescriptorCollection descriptors = property.Converter.GetProperties(value);
                foreach (PropertyDescriptor d in descriptors)
                {
                    _subProperties.Add(new PropertyItem(property.Owner, value, d));
                    // TODO: Move to PropertyData as a public property
                    NotifyParentPropertyAttribute notifyParent = d.Attributes[KnownTypes.Attributes.NotifyParentPropertyAttribute] as NotifyParentPropertyAttribute;
                    if (notifyParent != null && notifyParent.NotifyParent)
                    {
                        d.AddValueChanged(value, NotifySubPropertyChanged);
                    }
                }
            }

            this._property.PropertyChanged += new PropertyChangedEventHandler(ParentPropertyChanged);
        }
        public void Ctor_NotifyParent(bool notifyParent)
        {
            var attribute = new NotifyParentPropertyAttribute(notifyParent);

            Assert.Equal(notifyParent, attribute.NotifyParent);
            Assert.Equal(!notifyParent, attribute.IsDefaultAttribute());
        }
 public void Equals_Object_ReturnsExpected(NotifyParentPropertyAttribute attribute, object other, bool expected)
 {
     Assert.Equal(expected, attribute.Equals(other));
     if (other is NotifyParentPropertyAttribute)
     {
         Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode()));
     }
 }
        /// <summary>
        ///    <para>
        ///       Tests whether the specified object is the same as the current object.
        ///    </para>
        /// </summary>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            NotifyParentPropertyAttribute other = obj as NotifyParentPropertyAttribute;

            return(other != null && other.NotifyParent == NotifyParent);
        }
        // Determine if two attribute values are equal.
        public override bool Equals(Object obj)
        {
            NotifyParentPropertyAttribute other =
                (obj as NotifyParentPropertyAttribute);

            if (other != null)
            {
                return(flag == other.flag);
            }
            else
            {
                return(false);
            }
        }
 public void NameTests(NotifyParentPropertyAttribute attribute, bool isNotifyParent)
 {
     Assert.Equal(isNotifyParent, attribute.NotifyParent);
 }
        public void GetNotifyParent(bool value)
        {
            var attribute = new NotifyParentPropertyAttribute(value);

            Assert.Equal(value, attribute.NotifyParent);
        }
 public void NameTests(NotifyParentPropertyAttribute attribute, bool isNotifyParent)
 {
     Assert.Equal(isNotifyParent, attribute.NotifyParent);
 }
        public void GetNotifyParent(bool value)
        {
            var attribute = new NotifyParentPropertyAttribute(value);

            Assert.Equal(value, attribute.NotifyParent);
        }
 public void DefaultProperties_GetNotifyParent_ReturnsExpected(NotifyParentPropertyAttribute attribute, bool expectedNotifyParent)
 {
     Assert.Equal(expectedNotifyParent, attribute.NotifyParent);
     Assert.Equal(!expectedNotifyParent, attribute.IsDefaultAttribute());
 }