Working on

This commit is contained in:
Shannon
2014-03-11 14:23:51 +11:00
parent ec6cb4520c
commit d737afa327
18 changed files with 628 additions and 94 deletions

View File

@@ -329,35 +329,7 @@ namespace Umbraco.Web.Models
// can handle properties only when using the proper casing. So what this
// does is ensure that any casing is supported.
Func<string, Attempt<object>> getMember =
memberAlias =>
{
try
{
return Attempt<object>.Succeed(
content.GetType().InvokeMember(memberAlias,
System.Reflection.BindingFlags.GetProperty |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.Public,
null,
content,
null));
}
catch (MissingMethodException ex)
{
return Attempt<object>.Fail(ex);
}
};
//try with the current casing
var attempt = getMember(alias);
if (!attempt.Success)
{
//if we cannot get with the current alias, try changing it's case
attempt = alias[0].IsUpperCase()
? getMember(alias.ToCleanString(CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.CamelCase))
: getMember(alias.ToCleanString(CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.PascalCase));
}
var attempt = content.GetType().GetMemberIgnoreCase(content, alias);
return !attempt.Success
? null