Example #1
0
        protected void WeaveTypeInterface(TypeDefinition type)
        {
            var destinationEvent = type.GetEvent("PropertyChanged");

            type = destinationEvent.DeclaringType; //can be base type

            var weaver = new TypeWeaver(originType, type);

            weaver.ProcessNestedTypes();

            //TODO delete event generated field
            weaver.Merge(tNotifierEvent, destinationEvent);

            weaver.AddDefinition(tNotifierMethod);
            weaver.AddDefinition(tNotifierField);

            weaver.ProcessInstructions();
        }
Example #2
0
        private EventDefinition CreateNewEvent(TypeDefinition targetType, EventDefinition yourEvent,
			NewMemberAttribute newEventAttr)
        {
            if (newEventAttr.IsImplicit) {
                Log_implicitly_creating_member("event", yourEvent);
            } else {
                Log_creating_member("event", yourEvent);
            }
            var newName = newEventAttr.NewMemberName ?? yourEvent.Name;
            var maybeDuplicate = targetType.GetEvent(newName);

            if (maybeDuplicate != null) {
                var prevName = newName;
                Log_duplicate_member("event", yourEvent, maybeDuplicate);
                newName = GetNameAfterCollision(newName);
                Log_name_changed("event", yourEvent, prevName, newName);
            }

            var targetEvent = CopyEvent(yourEvent, newName);
            targetType.Events.Add(targetEvent);
            return targetEvent;
        }