using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace JustMe { [Serializable] public class FITS { static List<Fitness> fitness; static FITS() { fitness = new List<Fitness>(); } public void AddFitness(Fitness addF) { for (int i = 0; i < fitness.Count; i++) { if (fitness[i].Id.Equals(addF.Id) == true) { ExceptionHandler error = new ExceptionHandler(addF.Id); throw (error); } } fitness.Add(addF); } public void DeleteFitness(Fitness deleteF) { fitness.Remove(deleteF); } public void SelectSort() { int smallest; for (int i = 0; i < fitness.Count - 1; i++) { smallest = i; for (int index = i + 1; index < fitness.Count; index++) { if (fitness[index].Id.CompareTo(fitness[smallest].Id) < 0) { smallest = index; } } var temp = fitness[i]; fitness[i] = fitness[smallest]; fitness[smallest] = temp; } } public void SelectSort1() { int smallest1; for (int i = 0; i < fitness.Count - 1; i++) { smallest1 = i; for (int index1 = i + 1; index1 < fitness.Count; index1++) { if (fitness[smallest1].Id.CompareTo(fitness[index1].Id) < 0) { smallest1 = index1; } } var temp1 = fitness[i]; fitness[i] = fitness[smallest1]; fitness[smallest1] = temp1; } } public void clear() { fitness.Clear(); } public Fitness getFitnessClass(int index) { return fitness[index]; } public int Count() { return fitness.Count; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; namespace JustMe { public class SerialiseHandler { public void WriteListToFile(string filePath) { FileStream outFile; BinaryFormatter bFormatter = new BinaryFormatter(); string newpath = HttpContext.Current.Server.MapPath(filePath); outFile = new FileStream(newpath, FileMode.Create, FileAccess.Write); bFormatter.Serialize(outFile, FITS.GetValues()); outFile.Close(); } public FITS ReadListFromFile(String filePath) { FileStream inFile; BinaryFormatter bFormatter = new BinaryFormatter(); FITS fits = new FITS(); string newpath = HttpContext.Current.Server.MapPath(filePath); inFile = new FileStream(newpath, FileMode.Open, FileAccess.Read); fits = (FITS)bFormatter.Deserialize(inFile); inFile.Close(); return fits; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)