mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 00:08:51 -05:00
Allow short member names for static resolvers (#145)
This commit is contained in:
parent
7eb8291c31
commit
86fed7a830
@ -12,17 +12,23 @@ namespace TriInspector.Resolvers
|
||||
public static bool TryResolve(TriPropertyDefinition propertyDefinition, string expression,
|
||||
out ValueResolver<T> resolver)
|
||||
{
|
||||
if (expression.IndexOf('.') == -1)
|
||||
var type = propertyDefinition.OwnerType;
|
||||
var fieldName = expression;
|
||||
|
||||
var separatorIndex = expression.LastIndexOf('.');
|
||||
if (separatorIndex >= 0)
|
||||
{
|
||||
var className = expression.Substring(0, separatorIndex);
|
||||
fieldName = expression.Substring(separatorIndex + 1);
|
||||
|
||||
if (!TriReflectionUtilities.TryFindTypeByFullName(className, out type))
|
||||
{
|
||||
resolver = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var separatorIndex = expression.LastIndexOf('.');
|
||||
var className = expression.Substring(0, separatorIndex);
|
||||
var methodName = expression.Substring(separatorIndex + 1);
|
||||
|
||||
if (!TriReflectionUtilities.TryFindTypeByFullName(className, out var type))
|
||||
if (type == null)
|
||||
{
|
||||
resolver = null;
|
||||
return false;
|
||||
@ -32,7 +38,7 @@ namespace TriInspector.Resolvers
|
||||
|
||||
foreach (var fieldInfo in type.GetFields(flags))
|
||||
{
|
||||
if (fieldInfo.Name == methodName &&
|
||||
if (fieldInfo.Name == fieldName &&
|
||||
typeof(T).IsAssignableFrom(fieldInfo.FieldType))
|
||||
{
|
||||
resolver = new StaticFieldValueResolver<T>(fieldInfo);
|
||||
|
@ -12,17 +12,23 @@ namespace TriInspector.Resolvers
|
||||
public static bool TryResolve(TriPropertyDefinition propertyDefinition, string expression,
|
||||
out ValueResolver<T> resolver)
|
||||
{
|
||||
if (expression.IndexOf('.') == -1)
|
||||
var type = propertyDefinition.OwnerType;
|
||||
var methodName = expression;
|
||||
|
||||
var separatorIndex = expression.LastIndexOf('.');
|
||||
if (separatorIndex >= 0)
|
||||
{
|
||||
var className = expression.Substring(0, separatorIndex);
|
||||
methodName = expression.Substring(separatorIndex + 1);
|
||||
|
||||
if (!TriReflectionUtilities.TryFindTypeByFullName(className, out type))
|
||||
{
|
||||
resolver = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var separatorIndex = expression.LastIndexOf('.');
|
||||
var className = expression.Substring(0, separatorIndex);
|
||||
var methodName = expression.Substring(separatorIndex + 1);
|
||||
|
||||
if (!TriReflectionUtilities.TryFindTypeByFullName(className, out var type))
|
||||
if (type == null)
|
||||
{
|
||||
resolver = null;
|
||||
return false;
|
||||
|
@ -12,17 +12,23 @@ namespace TriInspector.Resolvers
|
||||
public static bool TryResolve(TriPropertyDefinition propertyDefinition, string expression,
|
||||
out ValueResolver<T> resolver)
|
||||
{
|
||||
if (expression.IndexOf('.') == -1)
|
||||
var type = propertyDefinition.OwnerType;
|
||||
var propertyName = expression;
|
||||
|
||||
var separatorIndex = expression.LastIndexOf('.');
|
||||
if (separatorIndex >= 0)
|
||||
{
|
||||
var className = expression.Substring(0, separatorIndex);
|
||||
propertyName = expression.Substring(separatorIndex + 1);
|
||||
|
||||
if (!TriReflectionUtilities.TryFindTypeByFullName(className, out type))
|
||||
{
|
||||
resolver = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var separatorIndex = expression.LastIndexOf('.');
|
||||
var className = expression.Substring(0, separatorIndex);
|
||||
var methodName = expression.Substring(separatorIndex + 1);
|
||||
|
||||
if (!TriReflectionUtilities.TryFindTypeByFullName(className, out var type))
|
||||
if (type == null)
|
||||
{
|
||||
resolver = null;
|
||||
return false;
|
||||
@ -32,7 +38,7 @@ namespace TriInspector.Resolvers
|
||||
|
||||
foreach (var propertyInfo in type.GetProperties(flags))
|
||||
{
|
||||
if (propertyInfo.Name == methodName &&
|
||||
if (propertyInfo.Name == propertyName &&
|
||||
typeof(T).IsAssignableFrom(propertyInfo.PropertyType) &&
|
||||
propertyInfo.CanRead)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user