public virtual void LoadFromText(string text) { EntityCacheGeneric <K, E> entities = (EntityCacheGeneric <K, E>)GOC.Instance.GetSerializer(SerializerType.XML).DeserializeFromText(this.GetType(), text); Clear(); foreach (E e in entities) { _entities.Add(GetSurrogateKeyValue(e), e); } }
public virtual void LoadFromFile(string filePath) { if (string.IsNullOrEmpty(filePath)) { if (string.IsNullOrEmpty(_defaultFilePath)) { throw new NullReferenceException("File path not specified for entity cache."); } filePath = _defaultFilePath; } if (!File.Exists(filePath)) { SaveToFile(filePath); } EntityCacheGeneric <K, E> entities = (EntityCacheGeneric <K, E>)GOC.Instance.GetSerializer(SerializerType.XML).DeserializeFromFile(this.GetType(), filePath); Clear(); foreach (E e in entities) { _entities.Add(GetSurrogateKeyValue(e), e); } }