Esempio n. 1
0
		MethodBody[] GetMethodBodies (MemberReference member)
		{
			if (member is MethodReference) {
				return new[]{ (((MethodReference) member).Resolve ()).Body };
			}
			if (member is PropertyReference) {
				PropertyDefinition prop = (PropertyDefinition) member;
				return new[]{
					prop.GetMethod != null ? prop.GetMethod.Body : null,
					prop.SetMethod != null ? prop.SetMethod.Body : null,
				};
			}
			if (member is FieldReference)
				return new MethodBody[]{};
			if (member is EventReference) {
				EventDefinition ev = (EventDefinition) member;
				return new[]{
					ev.AddMethod != null ? ev.AddMethod.Body : null,
					ev.InvokeMethod != null ? ev.InvokeMethod.Body : null, 
					ev.RemoveMethod != null ? ev.RemoveMethod.Body : null,
				};
			}
			throw new NotSupportedException ("Unsupported member type: " + member.GetType().FullName);
		}
Esempio n. 2
0
 public static CecilType getMemberReferenceType(MemberReference memberReference)
 {
     CecilType cecilType;
     var type = memberReference.GetType();
     if (typeToCecilTypeDict.TryGetValue(type, out cecilType))
         return cecilType;
     throw new ApplicationException(string.Format("Unknown MemberReference type: {0}", type));
 }