Inheritance: System.Attribute
Exemplo n.º 1
0
            /// <summary>
            ///     Return the default event. The default event is determined by the
            ///     presence of a DefaultEventAttribute on the class.
            /// </summary>
            internal EventDescriptor GetDefaultEvent(object instance)
            {
                AttributeCollection attributes;

                if (instance != null)
                {
                    attributes = TypeDescriptor.GetAttributes(instance);
                }
                else
                {
                    attributes = TypeDescriptor.GetAttributes(_type);
                }

                DefaultEventAttribute attr = (DefaultEventAttribute)attributes[typeof(DefaultEventAttribute)];

                if (attr != null && attr.Name != null)
                {
                    if (instance != null)
                    {
                        return(TypeDescriptor.GetEvents(instance)[attr.Name]);
                    }
                    else
                    {
                        return(TypeDescriptor.GetEvents(_type)[attr.Name]);
                    }
                }

                return(null);
            }
		public bool FilterAttributes (IComponent component,IDictionary attributes)
		{
			Attribute ea = new DefaultEventAttribute ("AnEvent");
			attributes [ea.TypeId] = ea;
			ea = new DefaultPropertyAttribute ("TestProperty");
			attributes [ea.TypeId] = ea;
			ea = new EditorAttribute ();
			attributes [ea.TypeId] = ea;
			return true;
		}
Exemplo n.º 3
0
        public EventDescriptor GetDefaultEvent()
        {
            if (this._gotDefaultEvent)
            {
                return(this._defaultEvent);
            }
            DefaultEventAttribute defaultEventAttribute = (DefaultEventAttribute)this.GetAttributes()[typeof(DefaultEventAttribute)];

            if (defaultEventAttribute == null || defaultEventAttribute.Name == null)
            {
                this._defaultEvent = null;
            }
            else
            {
                EventDescriptorCollection events = this.GetEvents();
                this._defaultEvent = events[defaultEventAttribute.Name];
            }
            this._gotDefaultEvent = true;
            return(this._defaultEvent);
        }
Exemplo n.º 4
0
 // Get the default event for a specified component type.
 public static EventDescriptor GetDefaultEvent(Type componentType)
 {
     lock (typeof(TypeDescriptor))
     {
         TypeElement element = GetOrCreateElement(componentType);
         if (element.defaultEvent != null)
         {
             return(element.defaultEvent);
         }
         DefaultEventAttribute attr = (DefaultEventAttribute)
                                      GetAttributeForType(componentType,
                                                          typeof(DefaultEventAttribute));
         if (attr != null && attr.Name != null)
         {
             element.defaultEvent =
                 CreateEvent(componentType, attr.Name, null, null);
             return(element.defaultEvent);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 5
0
        public EventDescriptor GetDefaultEvent()
        {
            if (_gotDefaultEvent)
            {
                return(_defaultEvent);
            }

            DefaultEventAttribute attr = (DefaultEventAttribute)GetAttributes()[typeof(DefaultEventAttribute)];

            if (attr == null || attr.Name == null)
            {
                _defaultEvent = null;
            }
            else
            {
                EventDescriptorCollection events = GetEvents();
                _defaultEvent = events [attr.Name];
#if !NET_2_0
                // In our test case (TypeDescriptorTest.TestGetDefaultEvent), we have
                // a scenario where a custom filter adds the DefaultEventAttribute,
                // but its FilterEvents method removes the event the
                // DefaultEventAttribute applied to.  .NET 1.x accepts this and returns
                // the *other* event defined in the class.
                //
                // Consequently, we know we have a DefaultEvent, but we need to check
                // and ensure that the requested event is unfiltered.  If it is, just
                // grab the first element in the collection.
                if (_defaultEvent == null && events.Count > 0)
                {
                    _defaultEvent = events [0];
                }
#endif
            }
            _gotDefaultEvent = true;
            return(_defaultEvent);
        }
        public override bool Equals(object obj)
        {
            DefaultEventAttribute attribute = obj as DefaultEventAttribute;

            return((attribute != null) && (attribute.Name == this.name));
        }
Exemplo n.º 7
0
        public override bool Equals(object obj)
        {
            DefaultEventAttribute other = obj as DefaultEventAttribute;

            return((other != null) && other.Name == name);
        }