Add findAny() methods
This commit is contained in:
parent
91c406b2a0
commit
ad59501474
|
@ -620,7 +620,7 @@ namespace de4dot.code.renamer {
|
||||||
if (string.IsNullOrEmpty(name) || propType.FullName == "System.Void")
|
if (string.IsNullOrEmpty(name) || propType.FullName == "System.Void")
|
||||||
return null;
|
return null;
|
||||||
var newProp = DotNetUtils.createPropertyDefinition(name, propType, getter, setter);
|
var newProp = DotNetUtils.createPropertyDefinition(name, propType, getter, setter);
|
||||||
var propDef = ownerType.find(newProp);
|
var propDef = ownerType.findAny(newProp);
|
||||||
if (propDef != null)
|
if (propDef != null)
|
||||||
return propDef;
|
return propDef;
|
||||||
|
|
||||||
|
@ -825,7 +825,7 @@ namespace de4dot.code.renamer {
|
||||||
if (string.IsNullOrEmpty(name) || eventType == null || eventType.FullName == "System.Void")
|
if (string.IsNullOrEmpty(name) || eventType == null || eventType.FullName == "System.Void")
|
||||||
return null;
|
return null;
|
||||||
var newEvent = DotNetUtils.createEventDefinition(name, eventType);
|
var newEvent = DotNetUtils.createEventDefinition(name, eventType);
|
||||||
var eventDef = ownerType.find(newEvent);
|
var eventDef = ownerType.findAny(newEvent);
|
||||||
if (eventDef != null)
|
if (eventDef != null)
|
||||||
return eventDef;
|
return eventDef;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace de4dot.code.renamer.asmmodules {
|
||||||
IEnumerable<TRef> getAll();
|
IEnumerable<TRef> getAll();
|
||||||
IEnumerable<TRef> getSorted();
|
IEnumerable<TRef> getSorted();
|
||||||
TRef find(TMRef tmref);
|
TRef find(TMRef tmref);
|
||||||
|
TRef findAny(TMRef tmref);
|
||||||
void add(TRef tref);
|
void add(TRef tref);
|
||||||
void onTypesRenamed();
|
void onTypesRenamed();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +53,10 @@ namespace de4dot.code.renamer.asmmodules {
|
||||||
return typeToDef.find(typeReference);
|
return typeToDef.find(typeReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TypeDef findAny(TypeReference typeReference) {
|
||||||
|
return typeToDef.findAny(typeReference);
|
||||||
|
}
|
||||||
|
|
||||||
public void add(TypeDef typeDef) {
|
public void add(TypeDef typeDef) {
|
||||||
typeToDef.add(typeDef.TypeDefinition, typeDef);
|
typeToDef.add(typeDef.TypeDefinition, typeDef);
|
||||||
}
|
}
|
||||||
|
@ -82,6 +87,10 @@ namespace de4dot.code.renamer.asmmodules {
|
||||||
return fieldToDef.find(fieldReference);
|
return fieldToDef.find(fieldReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FieldDef findAny(FieldReference fieldReference) {
|
||||||
|
return fieldToDef.findAny(fieldReference);
|
||||||
|
}
|
||||||
|
|
||||||
public void add(FieldDef fieldDef) {
|
public void add(FieldDef fieldDef) {
|
||||||
fieldToDef.add(fieldDef.FieldDefinition, fieldDef);
|
fieldToDef.add(fieldDef.FieldDefinition, fieldDef);
|
||||||
}
|
}
|
||||||
|
@ -112,6 +121,10 @@ namespace de4dot.code.renamer.asmmodules {
|
||||||
return methodToDef.find(methodReference);
|
return methodToDef.find(methodReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MethodDef findAny(MethodReference methodReference) {
|
||||||
|
return methodToDef.findAny(methodReference);
|
||||||
|
}
|
||||||
|
|
||||||
public void add(MethodDef methodDef) {
|
public void add(MethodDef methodDef) {
|
||||||
methodToDef.add(methodDef.MethodDefinition, methodDef);
|
methodToDef.add(methodDef.MethodDefinition, methodDef);
|
||||||
}
|
}
|
||||||
|
@ -142,6 +155,10 @@ namespace de4dot.code.renamer.asmmodules {
|
||||||
return propToDef.find(propertyReference);
|
return propToDef.find(propertyReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PropertyDef findAny(PropertyReference propertyReference) {
|
||||||
|
return propToDef.findAny(propertyReference);
|
||||||
|
}
|
||||||
|
|
||||||
public void add(PropertyDef propDef) {
|
public void add(PropertyDef propDef) {
|
||||||
propToDef.add(propDef.PropertyDefinition, propDef);
|
propToDef.add(propDef.PropertyDefinition, propDef);
|
||||||
}
|
}
|
||||||
|
@ -172,6 +189,10 @@ namespace de4dot.code.renamer.asmmodules {
|
||||||
return eventToDef.find(eventReference);
|
return eventToDef.find(eventReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EventDef findAny(EventReference eventReference) {
|
||||||
|
return eventToDef.findAny(eventReference);
|
||||||
|
}
|
||||||
|
|
||||||
public void add(EventDef eventDef) {
|
public void add(EventDef eventDef) {
|
||||||
eventToDef.add(eventDef.EventDefinition, eventDef);
|
eventToDef.add(eventDef.EventDefinition, eventDef);
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,20 +319,36 @@ namespace de4dot.code.renamer.asmmodules {
|
||||||
return methods.find(mr);
|
return methods.find(mr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MethodDef findAny(MethodReference mr) {
|
||||||
|
return methods.findAny(mr);
|
||||||
|
}
|
||||||
|
|
||||||
public FieldDef find(FieldReference fr) {
|
public FieldDef find(FieldReference fr) {
|
||||||
return fields.find(fr);
|
return fields.find(fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FieldDef findAny(FieldReference fr) {
|
||||||
|
return fields.findAny(fr);
|
||||||
|
}
|
||||||
|
|
||||||
public PropertyDef find(PropertyReference pr) {
|
public PropertyDef find(PropertyReference pr) {
|
||||||
return properties.find(pr);
|
return properties.find(pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PropertyDef findAny(PropertyReference pr) {
|
||||||
|
return properties.findAny(pr);
|
||||||
|
}
|
||||||
|
|
||||||
public EventDef find(EventReference er) {
|
public EventDef find(EventReference er) {
|
||||||
return events.find(er);
|
return events.find(er);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EventDef findAny(EventReference er) {
|
||||||
|
return events.findAny(er);
|
||||||
|
}
|
||||||
|
|
||||||
public PropertyDef create(PropertyDefinition newProp) {
|
public PropertyDef create(PropertyDefinition newProp) {
|
||||||
if (find(newProp) != null)
|
if (findAny(newProp) != null)
|
||||||
throw new ApplicationException("Can't add a property when it's already been added");
|
throw new ApplicationException("Can't add a property when it's already been added");
|
||||||
|
|
||||||
var propDef = new PropertyDef(newProp, this, properties.Count);
|
var propDef = new PropertyDef(newProp, this, properties.Count);
|
||||||
|
@ -342,7 +358,7 @@ namespace de4dot.code.renamer.asmmodules {
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventDef create(EventDefinition newEvent) {
|
public EventDef create(EventDefinition newEvent) {
|
||||||
if (find(newEvent) != null)
|
if (findAny(newEvent) != null)
|
||||||
throw new ApplicationException("Can't add an event when it's already been added");
|
throw new ApplicationException("Can't add an event when it's already been added");
|
||||||
|
|
||||||
var eventDef = new EventDef(newEvent, this, events.Count);
|
var eventDef = new EventDef(newEvent, this, events.Count);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user