Example #1
0
        public static bool AreSame(EventReference a, EventReference b)
        {
            //TODO is it enough?
            if (a.Name != b.Name)
                return false;

            if (!AreSame(a.EventType, b.EventType))
                return false;
            return true;
        }
		EventReference GetEventReference (EventReference source)
		{
			EventReference mr = source;
			TypeReference tr = GetTypeReference (mr.DeclaringType, false);
			EventReference result = GetEventReference (tr, mr);
			return result;
		}
		public EventReference GetEventReference (TypeReference type, EventReference eventa)
		{
			EventReference res = null;
			if (type is TypeDefinition) {
				EventDefinition md = eventa as EventDefinition;
				TypeDefinition td = type as TypeDefinition;
				res = td.Events.GetEvent (eventa.Name);
			}

			if (res == null)
				throw new ArgumentException ("Can't found event:" + eventa.DeclaringType.FullName + "::" + eventa.Name);

			return res;
		}
Example #4
0
 private static void CreateWellName(EventReference er)
 {
     var name = CleanName(er.Name);
     var start = name.IndexOf(NONWELLFLAG);
     if (start == -1)
     {
         if (IsNameRepeated(er.DeclaringType, name))
         {
             name = "E_" + name + "_" + GetShortName(er.EventType);
         }
     }
     else
     {
         name = Replace(name, start, 1, "E") + "_" + GetShortName(er.EventType);
     }
     er.mWellName = Regex.Replace(name, @"\W", "_");
 }
Example #5
0
 public EventReferenceKey(EventReference eventRef)
 {
     this.eventRef = eventRef;
 }
Example #6
0
 /// <summary>
 /// Are the given events the same?
 /// </summary>
 public static bool AreSame(this EventReference a, EventReference b, Func<GenericParameter, TypeReference> genericParamResolver)
 {
     if (a.Name != b.Name)
         return false;
     return (a.EventType.AreSame(b.EventType, genericParamResolver));
 }
Example #7
0
 public EventDef findAny(EventReference er)
 {
     return events.findAny(er);
 }
Example #8
0
 public EventRef(EventReference eventReference, TypeDef owner, int index)
     : base(eventReference, owner, index)
 {
 }
Example #9
0
 /// <summary>
 /// A cecil event reference will be directed to this method.
 /// </summary>
 /// <param name="item">Cecil reference.</param>
 /// <param name="resolvedItem">Output parameter that will be populated with the resolved cecil definition.</param>
 /// <returns><c>true</c></returns>
 private static bool TryResolve(EventReference item, out object resolvedItem)
 {
     resolvedItem = item.Resolve();
     return true;
 }
Example #10
0
        /// <summary>
        /// Mark all reachable items in argument as such.
        /// </summary>
        private static void Walk(ReachableContext context, EventReference evt)
        {
            // Type
            evt.EventType.MarkReachable(context);

            var evtDef = evt as EventDefinition;
            if (evtDef != null)
            {
                evtDef.AddMethod.MarkReachable(context);
                evtDef.RemoveMethod.MarkReachable(context);
                evtDef.InvokeMethod.MarkReachable(context);

                // Custom attributes
                Walk(context, (ICustomAttributeProvider)evtDef);
            }
            else
            {
                // Try to resolve
                evt.Resolve(context).MarkReachable(context);
            }
        }
		public EventReferenceExpression(Expression target, EventReference @event, IEnumerable<Instruction> instructions)
            :base(instructions)
		{
            this.Target = target;
            this.Event = @event;
        }
Example #12
0
 public override void VisitEventReference(EventReference @event)
 {
     var eventReference = @event;
     var scope = GetAssemblyNameReference(eventReference.DeclaringType.Scope);
     MapReference(scope, eventReference);
 }
 protected override string GetEventName(EventReference @event)
 {
     return (writerContext == null || writerContext.ModuleContext.Module == null) ? @event.Name : base.GetEventName(@event);
 }
 private IEnumerable<ProjectReference> GetEventTypeReferences(
     EventReference eventReference, AuditEntryParameters parameters)
 {
     foreach(var projectReference in GetTypeReferences(eventReference.EventType, parameters))
         yield return projectReference;
 }
Example #15
0
 public ScopeAndTokenKey(EventReference evt)
     : this(evt.DeclaringType == null ? null : evt.DeclaringType.Scope, evt.MetadataToken.ToInt32())
 {
 }
Example #16
0
 private static string Format(EventReference @event)
 {
     var sb = new StringBuilder();
     sb.Append(CecilFormat.GetTypeName(@event.DeclaringType));
     sb.Append('.');
     sb.Append(@event.Name);
     return sb.ToString();
 }
Example #17
0
 public static bool compareEventReference(EventReference a, EventReference b)
 {
     if (ReferenceEquals(a, b))
         return true;
     if (a == null || b == null)
         return false;
     return a.Name == b.Name &&
             compareTypes(a.EventType, b.EventType);
 }
Example #18
0
 void addEventReference(EventReference eventReference)
 {
     if (eventReference == null)
         return;
     addMemberReference(eventReference);
     pushMember(eventReference.EventType);
 }
Example #19
0
 public static int eventReferenceHashCode(EventReference a)
 {
     if (a == null)
         return 0;
     int res = 0;
     res += a.Name.GetHashCode();
     res += typeHashCode(a.EventType);
     return res;
 }
        protected virtual string GetEventName(EventReference @event)
        {
            EventDefinition eventDefinition = @event.Resolve();

            if (eventDefinition != null && eventDefinition.Module.FilePath == this.ModuleContext.Module.FilePath)
            {

                return this.ModuleContext.RenamedMembersMap[eventDefinition.MetadataToken.ToUInt32()];
            }

            return Utilities.EscapeName(GenericHelper.GetNonGenericName(@event.Name), this.Language);
        }
 public static EventDefinition TryResolve(this ModuleDefinition scope, EventReference eventRef)
 {
     var matchingType = TryResolve(scope, eventRef.DeclaringType);
     if (matchingType == null) {
         return null;
     }
     return matchingType.Events.FirstOrDefault(e => e.Name == eventRef.Name);
 }