public static Dictionary<FieldDefinition, EventDefinition> GetFieldToEventMap(this TypeDefinition typeDefinition, ILanguage language)
        {
            Dictionary<FieldDefinition, EventDefinition> result = new Dictionary<FieldDefinition, EventDefinition>();
            foreach (EventDefinition @event in typeDefinition.Events)
            {
                FieldDefinition eventField;
                AutoImplementedEventMatcher matcher = new AutoImplementedEventMatcher(@event, language);
                if (matcher.IsAutoImplemented(out eventField))
                {
                    result[eventField] = @event;
                }
            }

            return result;
        }
Exemplo n.º 2
0
 private FieldDefinition GetField(EventDefinition eventDef)
 {
     if (eventDef.get_InvokeMethod() != null || eventDef.get_AddMethod() == null || eventDef.get_RemoveMethod() == null)
     {
         return(null);
     }
     V_0 = AutoImplementedEventMatcher.GetFieldWithName(eventDef.get_DeclaringType(), eventDef.get_EventType().get_FullName(), String.Concat(eventDef.get_Name(), "Event"));
     if (V_0 == null)
     {
         V_0 = AutoImplementedEventMatcher.GetFieldWithName(eventDef.get_DeclaringType(), eventDef.get_EventType().get_FullName(), eventDef.get_Name());
     }
     if (V_0 == null)
     {
         return(null);
     }
     if (!this.IsThreadUnsafeEvent(V_0) && !this.IsThreadSafeEvent(V_0))
     {
         return(null);
     }
     return(V_0);
 }