The idea of the Encog persisted collection is that the entire file might be quite long and should not be read into memory in its entirity. Directory entry classes allow you to list the contents of a file without loading the entire file.
Наследование: IComparable
 /// <summary>
 /// Find the specified object, using a DirectoryEntry.
 /// </summary>
 /// <param name="d">The directory entry to find.</param>
 /// <returns>The loaded object.</returns>
 public IEncogPersistedObject Find(DirectoryEntry d)
 {
     return Find(d.Name);
 }
       /// <summary>
        /// Delete the specified object, use a directory entry.
       /// </summary>
        /// <param name="d">The object to delete.</param>
        public void Delete(DirectoryEntry d)
        {
            this.Delete(d.Name);

        }
 /// <inheritdoc/>
 public IEncogPersistedObject Find(DirectoryEntry entry)
 {
     return this.Contents[entry.Name];
 }
 /// <inheritdoc/>
 public void Delete(DirectoryEntry o)
 {
     this.Contents.Remove(o.Name);
     BuildDirectory();
 }
        /// <inheritdoc/>
        public void BuildDirectory()
        {
            this.directory.Clear();
		    foreach ( IEncogPersistedObject obj in this.Contents.Values) 
            {
			    DirectoryEntry entry = new DirectoryEntry(obj);
			    this.directory.Add(entry);
		    }

        }
Пример #6
0
        /// <summary>
        /// Build a directory entry list for the file.
        /// </summary>
        /// <returns>A list of objects in the file.</returns>
        public IList<DirectoryEntry> BuildDirectory()
        {
            IList<DirectoryEntry> result = new List<DirectoryEntry>();
            AdvanceObjectsCollection();

            while (this.xmlIn.ReadToTag())
            {
                if (this.xmlIn.IsIt(PersistReader.TAG_OBJECTS, false))
                {
                    break;
                }

                String type = this.xmlIn.LastTag.Name;
                String name = this.xmlIn.LastTag.GetAttributeValue("name");
                String description = this.xmlIn.LastTag.GetAttributeValue(
                       "description");

                DirectoryEntry entry = new DirectoryEntry(type, name,
                       description);
                if (!result.Contains(entry))
                {
                    result.Add(entry);
                }

                SkipObject();
            }

            return result;
        }