コード例 #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);
        }
コード例 #2
0
 public static BalancedNumber Read(string denominator)
 {
     using (BinaryReader reader = new BinaryReader(File.Open(basePath + denominator + ".savedata", FileMode.Open)))
     {
         return(BalancedNumber.CreateFromBinaryStream(reader));
     }
 }
コード例 #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);
     }
 }
コード例 #4
0
 public static void Write(BalancedNumber data, BinaryWriter writer)
 {
     data.WriteToBinaryStream(writer);
 }
コード例 #5
0
 public static BalancedNumber Read(BinaryReader reader)
 {
     return(BalancedNumber.CreateFromBinaryStream(reader));
 }