public void CopyConstructorAddsAttribute()
        {
            var oldEventDescriptor = TypeDescriptor.CreateEvent(typeof(DescriptorTestComponent), nameof(DescriptorTestComponent.ActionEvent), typeof(Action));
            var expectedString     = "EventDescriptorTests.CopyConstructorAddsAttribute";
            var newAttribute       = new DescriptorTestAttribute(expectedString);

            EventDescriptor newEventDescriptor = TypeDescriptor.CreateEvent(typeof(DescriptorTestComponent), oldEventDescriptor, new[] { newAttribute });

            Assert.True(newEventDescriptor.Attributes.Contains(newAttribute));
        }
예제 #2
0
        public void CopyConstructorAddsAttribute()
        {
            var oldEventDescriptor = TypeDescriptor.CreateEvent(typeof(DescriptorTestComponent), nameof(DescriptorTestComponent.ActionEvent), typeof(Action));
            var expectedString = "EventDescriptorTests.CopyConstructorAddsAttribute";
            var newAttribute = new DescriptorTestAttribute(expectedString);

            EventDescriptor newEventDescriptor = TypeDescriptor.CreateEvent(typeof(DescriptorTestComponent), oldEventDescriptor, new[] { newAttribute });

            Assert.True(newEventDescriptor.Attributes.Contains(newAttribute));
        }
예제 #3
0
        public void AddAttribute()
        {
            var component = new DescriptorTestComponent();
            var addedAttribute = new DescriptorTestAttribute("expected string");

            TypeDescriptor.AddAttributes(component.GetType(), addedAttribute);

            AttributeCollection attributes = TypeDescriptor.GetAttributes(component);
            Assert.True(attributes.Contains(addedAttribute));
        }
예제 #4
0
        public void AddAttribute()
        {
            var component      = new DescriptorTestComponent();
            var addedAttribute = new DescriptorTestAttribute("expected string");

            TypeDescriptor.AddAttributes(component.GetType(), addedAttribute);

            AttributeCollection attributes = TypeDescriptor.GetAttributes(component);

            Assert.True(attributes.Contains(addedAttribute));
        }
        public void CopyConstructorAddsAttribute()
        {
            var component  = new DescriptorTestComponent();
            var properties = TypeDescriptor.GetProperties(component.GetType());
            PropertyDescriptor oldPropertyDescriptor = properties.Find(nameof(component.Property), false);
            var newAttribute = new DescriptorTestAttribute();

            PropertyDescriptor newPropertyDescriptor = TypeDescriptor.CreateProperty(component.GetType(), oldPropertyDescriptor, newAttribute);

            Assert.True(newPropertyDescriptor.Attributes.Contains(newAttribute));
        }
예제 #6
0
        public void CopyConstructorAddsAttribute()
        {
            var component = new DescriptorTestComponent();
            var properties = TypeDescriptor.GetProperties(component.GetType());
            PropertyDescriptor oldPropertyDescriptor = properties.Find(nameof(component.Property), false);
            var newAttribute = new DescriptorTestAttribute();

            PropertyDescriptor newPropertyDescriptor = TypeDescriptor.CreateProperty(component.GetType(), oldPropertyDescriptor, newAttribute);

            Assert.True(newPropertyDescriptor.Attributes.Contains(newAttribute));
        }