public static SudokuIntermediateSolution LoadFromFile(string a_fileName)
 {
     if (Path.GetExtension(a_fileName) == FileExtensions.ZipExt)
     {
         try
         {
             using (FileStream file_stream = new FileStream(a_fileName, FileMode.Open, FileAccess.Read))
             {
                 using (GZipStream gzip_stream = new GZipStream(file_stream, CompressionMode.Decompress))
                 {
                     using (StreamReader stream_reader = new StreamReader(gzip_stream, Encoding.ASCII))
                     {
                         return(SudokuIntermediateSolution.LoadFromXML(XElement.Load(stream_reader)));
                     }
                 }
             }
         }
         catch
         {
             return(null);
         }
     }
     else if (Path.GetExtension(a_fileName) == FileExtensions.XmlExt)
     {
         return(SudokuIntermediateSolution.LoadFromXML(XElement.Load(a_fileName)));
     }
     else
     {
         return(null);
     }
 }
        private static SudokuIntermediateSolution LoadFromXML(XElement a_element)
        {
            try
            {
                SudokuBoard    before   = SudokuBoard.LoadFromXML(a_element.Element("board_before"));
                SudokuBoard    after    = SudokuBoard.LoadFromXML(a_element.Element("board_after"));
                SudokuSolution solution = SudokuSolution.LoadFromXML(a_element.Element("solution"), before);

                SudokuIntermediateSolution intermediate_solution = new SudokuIntermediateSolution(before, after, solution);

                return(intermediate_solution);
            }
            catch
            {
                return(null);
            }
        }
        public override bool Equals(object a_obj)
        {
            if (a_obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, a_obj))
            {
                return(true);
            }
            SudokuIntermediateSolution intermediate_solution = a_obj as SudokuIntermediateSolution;

            if (intermediate_solution == null)
            {
                return(false);
            }

            return(m_before.Equals(intermediate_solution.m_before) &&
                   m_after.Equals(intermediate_solution.m_after) &&
                   m_solution.Equals(intermediate_solution.m_solution));
        }
示例#4
0
        public static SudokuIntermediateSolution Rotate(this SudokuIntermediateSolution a_inter_sol)
        {
            SudokuBoard before = Rotate(a_inter_sol.Before);

            return(new SudokuIntermediateSolution(before, Rotate(a_inter_sol.After), Rotate(a_inter_sol.Solution, before)));
        }