Esempio n. 1
0
 private static DynamicMethodDelegate GetEndTrigger(EventInfo info)
 {
   EndTriggerAttribute triggerAttribute = Enumerable.FirstOrDefault<object>((IEnumerable<object>) info.GetCustomAttributes(typeof (EndTriggerAttribute), false)) as EndTriggerAttribute;
   if (triggerAttribute == null)
     return (DynamicMethodDelegate) null;
   else
     return ReflectionHelper.CreateDelegate((MethodBase) info.DeclaringType.GetEvent(triggerAttribute.Trigger).GetAddMethod());
 }
 public MBeanNotificationInfo CreateMBeanNotificationInfo(EventInfo info, Type handlerType)
 {
     MBeanNotificationAttribute attribute =
     (MBeanNotificationAttribute)info.GetCustomAttributes(typeof(MBeanNotificationAttribute), true)[0];
      return new MBeanNotificationInfo(new[] { attribute.NotifType },
                                   handlerType.GetGenericArguments()[0].AssemblyQualifiedName,
                                   InfoUtils.GetDescrition(info, info, "MBean notification"));
 }
Esempio n. 3
0
		public ReflectionEventDescriptor (EventInfo eventInfo) : base (eventInfo.Name, (Attribute[]) eventInfo.GetCustomAttributes (true))
		{
			_eventInfo = eventInfo;
			_componentType = eventInfo.DeclaringType;
			_eventType = eventInfo.EventHandlerType;

			add_method = eventInfo.GetAddMethod ();
			remove_method = eventInfo.GetRemoveMethod ();
		}
Esempio n. 4
0
 private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
 {
   Attribute[] attributes = (Attribute[]) element.GetCustomAttributes(type, inherit);
   if (!inherit)
     return attributes;
   Hashtable types = new Hashtable(11);
   ArrayList attributeList = new ArrayList();
   Attribute.CopyToArrayList(attributeList, attributes, types);
   for (EventInfo parentDefinition = Attribute.GetParentDefinition(element); parentDefinition != null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
   {
     Attribute[] customAttributes = Attribute.GetCustomAttributes((MemberInfo) parentDefinition, type, false);
     Attribute.AddAttributesToList(attributeList, customAttributes, types);
   }
   return (Attribute[]) attributeList.ToArray(type);
 }
Esempio n. 5
0
 private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
 {
   Attribute[] attributes = (Attribute[]) element.GetCustomAttributes(type, inherit);
   if (!inherit)
     return attributes;
   Dictionary<Type, AttributeUsageAttribute> types = new Dictionary<Type, AttributeUsageAttribute>(11);
   List<Attribute> attributeList = new List<Attribute>();
   Attribute.CopyToArrayList(attributeList, attributes, types);
   for (EventInfo parentDefinition = Attribute.GetParentDefinition(element); parentDefinition != (EventInfo) null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
   {
     Attribute[] customAttributes = Attribute.GetCustomAttributes((MemberInfo) parentDefinition, type, false);
     Attribute.AddAttributesToList(attributeList, customAttributes, types);
   }
   Array destinationArray = (Array) Attribute.CreateAttributeArrayHelper(type, attributeList.Count);
   Array.Copy((Array) attributeList.ToArray(), 0, destinationArray, 0, attributeList.Count);
   return (Attribute[]) destinationArray;
 }
		private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
		{
			Attribute[] array = (Attribute[])element.GetCustomAttributes(type, inherit);
			if (inherit)
			{
				Dictionary<Type, AttributeUsageAttribute> types = new Dictionary<Type, AttributeUsageAttribute>(11);
				List<Attribute> list = new List<Attribute>();
				Attribute.CopyToArrayList(list, array, types);
				EventInfo parentDefinition = Attribute.GetParentDefinition(element);
				while (parentDefinition != null)
				{
					array = Attribute.GetCustomAttributes(parentDefinition, type, false);
					Attribute.AddAttributesToList(list, array, types);
					parentDefinition = Attribute.GetParentDefinition(parentDefinition);
				}
				Array array2 = Attribute.CreateAttributeArrayHelper(type, list.Count);
				Array.Copy(list.ToArray(), 0, array2, 0, list.Count);
				return (Attribute[])array2;
			}
			return array;
		}
Esempio n. 7
0
		private void WriteCustomAttributes(XmlWriter writer, EventInfo eventInfo)
		{
			try
			{
				WriteCustomAttributes(writer, eventInfo.GetCustomAttributes(this.rep.DocumentInheritedAttributes), "");
			}
			catch (Exception e)
			{
				TraceErrorOutput("Error retrieving custom attributes for " + MemberID.GetMemberID(eventInfo), e);
			}
		}
Esempio n. 8
0
 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
 {
     return(_innerEventInfo.GetCustomAttributes(attributeType, inherit));
 }
Esempio n. 9
0
        private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
        {
            Contract.Requires(element != null);
            Contract.Requires(type != null);
            Contract.Requires(type.IsSubclassOf(typeof(Attribute)) || type == typeof(Attribute));

            // walk up the hierarchy chain
            Attribute[] attributes = (Attribute[])element.GetCustomAttributes(type, inherit);
            if (inherit)
            {
                // create the hashtable that keeps track of inherited types
                Dictionary<Type, AttributeUsageAttribute> types = new Dictionary<Type, AttributeUsageAttribute>(11);
                // create an array list to collect all the requested attibutes
                List<Attribute> attributeList = new List<Attribute>();
                CopyToArrayList(attributeList, attributes, types);

                EventInfo baseEvent = GetParentDefinition(element);
                while (baseEvent != null)
                {
                    attributes = GetCustomAttributes(baseEvent, type, false);
                    AddAttributesToList(attributeList, attributes, types);
                    baseEvent = GetParentDefinition(baseEvent);
                }
                Array array = CreateAttributeArrayHelper(type, attributeList.Count);
                Array.Copy(attributeList.ToArray(), 0, array, 0, attributeList.Count);
                return (Attribute[])array;
            }
            else
                return attributes;
        }
 private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
 {
     Attribute[] customAttributes = (Attribute[]) element.GetCustomAttributes(type, inherit);
     if (!inherit)
     {
         return customAttributes;
     }
     Dictionary<Type, AttributeUsageAttribute> types = new Dictionary<Type, AttributeUsageAttribute>(11);
     List<Attribute> attributeList = new List<Attribute>();
     CopyToArrayList(attributeList, customAttributes, types);
     for (EventInfo info = GetParentDefinition(element); info != null; info = GetParentDefinition(info))
     {
         customAttributes = GetCustomAttributes(info, type, false);
         AddAttributesToList(attributeList, customAttributes, types);
     }
     Array destinationArray = CreateAttributeArrayHelper(type, attributeList.Count);
     Array.Copy(attributeList.ToArray(), 0, destinationArray, 0, attributeList.Count);
     return (Attribute[]) destinationArray;
 }
Esempio n. 11
0
        private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
        {
            // walk up the hierarchy chain
            Attribute[] attributes = (Attribute[])element.GetCustomAttributes(type, inherit);
            if (inherit) {
                // create the hashtable that keeps track of inherited types
                Hashtable types = new Hashtable(11);
                // create an array list to collect all the requested attibutes
                ArrayList attributeList = new ArrayList();
                CopyToArrayList(attributeList, attributes, types);

                EventInfo baseEvent = GetParentDefinition(element);
                while (baseEvent != null) {
                    attributes = GetCustomAttributes(baseEvent, type, false);
                    AddAttributesToList(attributeList, attributes, types);
                    baseEvent = GetParentDefinition(baseEvent);
                }
                return (Attribute[])attributeList.ToArray(type);
            }
            else
                return attributes;
        }
Esempio n. 12
0
 private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
 {
     Attribute[] customAttributes = (Attribute[]) element.GetCustomAttributes(type, inherit);
     if (!inherit)
     {
         return customAttributes;
     }
     Hashtable types = new Hashtable(11);
     ArrayList attributeList = new ArrayList();
     CopyToArrayList(attributeList, customAttributes, types);
     for (EventInfo info = GetParentDefinition(element); info != null; info = GetParentDefinition(info))
     {
         customAttributes = GetCustomAttributes(info, type, false);
         AddAttributesToList(attributeList, customAttributes, types);
     }
     return (Attribute[]) attributeList.ToArray(type);
 }
Esempio n. 13
0
 public EventPropertyDescriptor(EventInfo ev) :
     base(ev.Name, (Attribute[]) ev.GetCustomAttributes(typeof(Attribute), true))
 {
     _event = ev;           
 }