Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }