/// <summary> /// Modify the specified object, such as changing its name or /// description. /// </summary> /// <param name="location">The location of the object being modified.</param> /// <param name="name">The old name of the object being modified.</param> /// <param name="newName">The new name of the object being modified.</param> /// <param name="newDesc">The new description of the object being modified.</param> public void ModifyObject(IPersistenceLocation location, String name, String newName, String newDesc) { PersistReader reader = new PersistReader(location); reader.SaveModified(this.xmlOut, name, newName, newDesc); reader.Close(); }
/// <summary> /// Called to search all Encog objects in this collection for one with a name /// that passes what was passed in. /// </summary> /// <param name="name">The name we are searching for.</param> /// <returns>The Encog object with the correct name.</returns> public IEncogPersistedObject Find(String name) { PersistReader reader = new PersistReader(this.filePrimary); IEncogPersistedObject result = reader.ReadObject(name); reader.Close(); return(result); }
/// <summary> /// Merge the objects from this collection into the new one. /// Skip the specified object. /// </summary> /// <param name="location">The location to merge to.</param> /// <param name="skip">The object to skip.</param> public void MergeObjects(IPersistenceLocation location, String skip) { PersistReader reader = new PersistReader(location); reader.SaveTo(this.xmlOut, skip); reader.Close(); }
/// <summary> /// Load the contents of a location. /// </summary> /// <param name="location">The location to load from.</param> public void Load(IPersistenceLocation location) { PersistReader reader = null; this.location = location; try { reader = new PersistReader(location); IDictionary <String, String> header = reader.ReadHeader(); if (header != null) { this.FileVersion = int.Parse(header["fileVersion"]); this.EncogVersion = header["encogVersion"]; this.Platform = header["platform"]; } reader.AdvanceObjectsCollection(); ReadXML xmlIn = reader.XMLInput; this.Contents.Clear(); while (xmlIn.ReadToTag()) { if (xmlIn.IsIt(PersistReader.TAG_OBJECTS, false)) { break; } String type = xmlIn.LastTag.Name; String name = xmlIn.LastTag.Attributes["name"]; IPersistor persistor = PersistorUtil .CreatePersistor(type); if (persistor == null) { throw new PersistError("Do not know how to load: " + type); } IEncogPersistedObject obj = persistor.Load(xmlIn); this.Contents[name] = obj; } } finally { if (reader != null) { reader.Close(); } BuildDirectory(); } }
/// <summary> /// Build a directory of objects. /// </summary> public void BuildDirectory() { PersistReader reader = new PersistReader(this.filePrimary); IDictionary <String, String> header = reader.ReadHeader(); if (header != null) { this.fileVersion = int.Parse(header["fileVersion"]); this.encogVersion = header["encogVersion"]; this.platform = header["platform"]; } this.directory = reader.BuildDirectory(); reader.Close(); }
/// <summary> /// Called to search all Encog objects in this collection for one with a name /// that passes what was passed in. /// </summary> /// <param name="name">The name we are searching for.</param> /// <returns>The Encog object with the correct name.</returns> public IEncogPersistedObject Find(String name) { PersistReader reader = new PersistReader(this.filePrimary); IEncogPersistedObject result = reader.ReadObject(name); reader.Close(); return result; }
/// <summary> /// Build a directory of objects. /// </summary> public void BuildDirectory() { PersistReader reader = new PersistReader(this.filePrimary); IDictionary<String, String> header = reader.ReadHeader(); if (header != null) { this.fileVersion = int.Parse(header["fileVersion"]); this.encogVersion = header["encogVersion"]; this.platform = header["platform"]; } this.directory = reader.BuildDirectory(); reader.Close(); }
/// <summary> /// Load the contents of a location. /// </summary> /// <param name="location">The location to load from.</param> public void Load(IPersistenceLocation location) { PersistReader reader = null; this.location = location; try { reader = new PersistReader(location); IDictionary<String, String> header = reader.ReadHeader(); if (header != null) { this.FileVersion = int.Parse(header["fileVersion"]); this.EncogVersion = header["encogVersion"]; this.Platform = header["platform"]; } reader.AdvanceObjectsCollection(); ReadXML xmlIn = reader.XMLInput; this.Contents.Clear(); while (xmlIn.ReadToTag()) { if (xmlIn.IsIt(PersistReader.TAG_OBJECTS, false)) { break; } String type = xmlIn.LastTag.Name; String name = xmlIn.LastTag.Attributes["name"]; IPersistor persistor = PersistorUtil .CreatePersistor(type); if (persistor == null) { throw new PersistError("Do not know how to load: " + type); } IEncogPersistedObject obj = persistor.Load(xmlIn); this.Contents[name] = obj; } } finally { if (reader != null) { reader.Close(); } BuildDirectory(); } }