init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
64
Framework/Caching/CacheManager.cs
Normal file
64
Framework/Caching/CacheManager.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.Framework.Caching
|
||||
{
|
||||
public class CacheManager
|
||||
{
|
||||
private Dictionary<Type, Cache> m_Caches = new Dictionary<Type, Cache>();
|
||||
private System.Threading.ReaderWriterLockSlim m_CacheManagerLock = new System.Threading.ReaderWriterLockSlim();
|
||||
|
||||
public CacheManager()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adott cache kérése a managertől
|
||||
/// </summary>
|
||||
/// <typeparam name="CacheType">Cache típusa</typeparam>
|
||||
/// <returns>Cache példány</returns>
|
||||
public CacheType AquireCache<CacheType>() where CacheType : Cache
|
||||
{
|
||||
m_CacheManagerLock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
if (!m_Caches.ContainsKey(typeof(CacheType)))
|
||||
{
|
||||
m_Caches.Add(typeof(CacheType), (Cache)Activator.CreateInstance(typeof(CacheType), new object[] { this }));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CacheManagerLock.ExitWriteLock();
|
||||
}
|
||||
return (CacheType)m_Caches[typeof(CacheType)];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adott cache kérése a managertől, mobilból
|
||||
/// </summary>
|
||||
/// <typeparam name="CacheType">Cache típusa</typeparam>
|
||||
/// <returns>Cache példány</returns>
|
||||
public CacheType AquireCacheMobile<CacheType>() where CacheType : Cache
|
||||
{
|
||||
m_CacheManagerLock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
if (!m_Caches.ContainsKey(typeof(CacheType)))
|
||||
{
|
||||
m_Caches.Add(typeof(CacheType), (Cache)Activator.CreateInstance(typeof(CacheType), new object[] { this }));
|
||||
}
|
||||
return (CacheType)m_Caches[typeof(CacheType)];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SDAServer.Instance.Logger.ExceptionThrown(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CacheManagerLock.ExitWriteLock();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue