/*
* Namespace Summary
* Copyright (C) 2005+ Bogdan Damian Constantin
* E-Mail: damianbcpetro@gmail.com
* WEB: http://www.sourceforge.net/projects/dataholder
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License 2.1 or later, as
* published by the Free Software Foundation. See the included License.txt
* or http://www.gnu.org/copyleft/lesser.html for details.
*
*/
using System;
using System.Collections;
using System.Collections.Generic;
namespace DataHolder.Containers.Property{
/// <summary>
/// Used to hold all the properties - will be transformed into interface
/// </summary>
public class PropertyCollectionCache
{
protected Dictionary<Type, PropertyCollection> l_TypeDictionary = new Dictionary<Type, PropertyCollection>();
public PropertyCollectionCache()
{
//
// TODO: Add constructor logic here
//
}
public virtual PropertyCollection GetProperties(GenericData genent)
{
Type gtype = genent.GetType();
try
{
return l_TypeDictionary[gtype];
}
catch(KeyNotFoundException)
{
PropertyCollection pc = genent.GetNewPropertyCollection();
l_TypeDictionary[gtype] = pc;
return pc;
}
}
public virtual PropertyCollection GetProperties(Type GenricDataType)
{
try
{
return l_TypeDictionary[GenricDataType];
}
catch (KeyNotFoundException)
{
GenericData ge = (GenericData)Activator.CreateInstance(GenricDataType);
PropertyCollection pc = ge.GetNewPropertyCollection();
l_TypeDictionary[GenricDataType] = pc;
ge.Dispose();
return pc;
}
}
}
}
|