Esempio n. 1
0
        public static List <BalancedNumber> LoadBalancedNumberList()
        {
            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
            List <BalancedNumber> result = new List <BalancedNumber>();

            try
            {
                using (BinaryReader reader = new BinaryReader(File.Open(basePath + "BalancedNumberList.savedata", FileMode.Open)))
                {
                    ushort length = reader.ReadUInt16();
                    if (length == 0)
                    {
                        return(new List <BalancedNumber>());
                    }
                    for (int i = 0; i < length; i++)
                    {
                        BalancedNumber bn = Read(reader);
                        result.Add(bn);
                    }
                }
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine("Error loading list");
                return(new List <BalancedNumber>());
            }
            return(result);
        }
Esempio n. 2
0
 public static BalancedNumber Read(string denominator)
 {
     using (BinaryReader reader = new BinaryReader(File.Open(basePath + denominator + ".savedata", FileMode.Open)))
     {
         return(BalancedNumber.CreateFromBinaryStream(reader));
     }
 }
Esempio n. 3
0
 public static void Write(BalancedNumber data, string denominator)
 {
     if (!Directory.Exists(basePath))
     {
         Directory.CreateDirectory(basePath);
     }
     using (BinaryWriter writer = new BinaryWriter(File.Open(basePath + denominator + ".savedata", FileMode.Create)))
     {
         data.WriteToBinaryStream(writer);
     }
 }
Esempio n. 4
0
 public static void Write(BalancedNumber data, BinaryWriter writer)
 {
     data.WriteToBinaryStream(writer);
 }
Esempio n. 5
0
 public static BalancedNumber Read(BinaryReader reader)
 {
     return(BalancedNumber.CreateFromBinaryStream(reader));
 }