28 lines
855 B
C#
28 lines
855 B
C#
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);
|
|
}
|
|
}
|
|
} |