Пример #1
0
        public MainPage()
        {
            this.InitializeComponent();
            // This is the try catch block for serializing the code
            // try and load the serialized class

            try
            {
                ai = new RPSAI();
                Task task = RPS.My_Serialize.CreateObject <RPSAI>(ai, path);
            }
            // If there is an error we need to detect which kind.
            // If the serialized file doesn't exist then we need to
            // create one.
            catch (FileNotFoundException)
            {
                ai = new RPSAI();
                Task task = RPS.My_Serialize.SaveObject <RPSAI>(ai, path);
            }
            // If there is another type of error then we need to catch that.
            catch (SerializationException ex)
            {
                Result.Text = ex.Message;
            }
            finally
            {
                Task <RPSAI> task = RPS.My_Serialize.ReadObject <RPSAI>(path);
                ai = task.Result;
            }
        }
Пример #2
0
        public MainPage()
        {
            this.InitializeComponent();
            // This is the try catch block for serializing the code
            // try and load the serialized class
            //try
            //{
            ai = new RPSAI();
            //}
            // If there is an error we need to detect which kind.
            // If the serialized file doesn't exist then we need to
            // create one.
            //catch()
            //{

            //}
            // If there is another type of error then we need to catch that.
            //catch()
            //{

            //}
            // Do I need this finally?
            //finally
            //{

            //}
        }