using System;
using eDriven.Core.Caching;
namespace eDriven.Core.Reflection
{
///
/// Member wrapper cache
/// A member wrapper creation is the result of reflecting the property/field of a class
/// Since this should be done no more than once during the application lifetime, we use the cache
/// This cache has additional methods forgetting/setting values having 2 parameters: type and property
///
public class MemberCache : Cache>
{
///
/// Gets the member wrapper based on type and property
///
///
///
///
public MemberWrapper Get(Type type, string property)
{
var t = Get(type);
if (null == t)
return null;
var p = t.Get(property);
return p;
}
///
/// Puts the member wrapper based on type and property
///
///
///
///
///
public void Put(Type type, string property, MemberWrapper wrapper)
{
var t = Get(type);
if (null == t)
{
t = new Cache();
Put(type, new Cache());
}
t.Put(property, wrapper);
/*Debug.Log(string.Format(@"Put: {0} [cache size: {1}]
type: {2}, property: {3}", wrapper, Count, type, property));*/
}
}
}