Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active January 1, 2016 13:49
Show Gist options
  • Save rightfold/8153485 to your computer and use it in GitHub Desktop.
Save rightfold/8153485 to your computer and use it in GitHub Desktop.
private enum Kind { Get, Set };
private static string InterfaceGetOrSetMethod(PropertyInfo propertyInfo, Kind kind)
{
var kindString = Kind == Kind.Get ? "get" : "set";
if (propertyInfo.GetMethod == null)
return "";
var accessModifier = propertyInfo.Accessmodifier();
var methodAccessModifier = propertyInfo.GetMethod.Accessmodifier();
if (methodAccessModifier == accessModifier)
return kindString + ";";
return methodAccessModifier.ToString().ToLower() + kindString + ";";
}
public static string InterfaceGetMethod(this PropertyInfo propertyInfo)
{
return InterfaceGetOrSetMethod(propertyInfo, Kind.Get);
}
public static string InterfaceSetMethod(this PropertyInfo propertyInfo)
{
return InterfaceGetOrSetMethod(propertyInfo, Kind.Set);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment