Cache property lookups for the object parsing
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LeafWeb.Core.Utility
|
||||
{
|
||||
public class ParseInfoPropertyMatcherWithCache<T> : ParseInfoPropertyMatcher<T>
|
||||
where T: new()
|
||||
{
|
||||
private readonly Func<string, int, PropertyInfo> _matchPropertyMemo;
|
||||
private readonly Func<string, int, PropertyInfo> _matchPropertyExactMemo;
|
||||
|
||||
public ParseInfoPropertyMatcherWithCache()
|
||||
{
|
||||
_matchPropertyMemo = Memoizer.ThreadsafeMemoize<string,int,PropertyInfo>(base.MatchProperty);
|
||||
_matchPropertyExactMemo = Memoizer.ThreadsafeMemoize<string,int,PropertyInfo>(base.MatchPropertyExact);
|
||||
}
|
||||
|
||||
public override PropertyInfo MatchProperty(string title, int position)
|
||||
{
|
||||
return _matchPropertyMemo(title, position);
|
||||
}
|
||||
|
||||
public override PropertyInfo MatchPropertyExact(string title, int position)
|
||||
{
|
||||
return _matchPropertyExactMemo(title, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user