Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Looking for properties to tamper with.
public bool MaybeTamperWith()
{
return _typeDef.IsClass
&& HasPropertiesToTamperWith()
&& ReallyTamperWith();
}
private bool HasPropertiesToTamperWith()
{
FindPropertiesToTamperWith();
return _map.Count > 0;
}
private void FindPropertiesToTamperWith()
{
var isViewableType = IsViewable(_typeDef);
foreach (var prop in _typeDef.Properties
.Where(p => IsViewable(p) || (isViewableType && !IsOpaque(p))))
{
HandlePropertyToNotify(prop);
}
}
private static bool IsViewable(ICustomAttributeProvider item)
{
return HasAttribute(item, ViewableAttributeName);
}
private static bool IsOpaque(ICustomAttributeProvider item)
{
return HasAttribute(item, OpaqueAttributeName);
}
private static bool HasAttribute(ICustomAttributeProvider item,
string attributeName)
{
return item.CustomAttributes.Any(
a => a.AttributeType.Name == attributeName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment