本文整理汇总了C#中System.Reflection.EventInfo.GetCustomAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# EventInfo.GetCustomAttributes方法的具体用法?C# EventInfo.GetCustomAttributes怎么用?C# EventInfo.GetCustomAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.EventInfo
的用法示例。
在下文中一共展示了EventInfo.GetCustomAttributes方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMBeanNotificationInfo
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"));
}
示例2: GetEndTrigger
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());
}
示例3: ReflectionEventDescriptor
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 ();
}
示例4: InternalGetCustomAttributes
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);
}
示例5: InternalGetCustomAttributes
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;
}
示例6: InternalGetCustomAttributes
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;
}
示例7: WriteCustomAttributes
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);
}
}
示例8: InternalGetCustomAttributes
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;
}
示例9: InternalGetCustomAttributes
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;
}
示例10: InternalGetCustomAttributes
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;
}
示例11: InternalGetCustomAttributes
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);
}
示例12: EventPropertyDescriptor
public EventPropertyDescriptor(EventInfo ev) :
base(ev.Name, (Attribute[]) ev.GetCustomAttributes(typeof(Attribute), true))
{
_event = ev;
}