Example #1
0
        protected override async void OnStart()
        {
            var fileHelper = DependencyService.Get <IFileHelper>();

            var questionsText = await fileHelper.LoadLocalFileAsync("cachedquestions.xml");

            if (string.IsNullOrWhiteSpace(questionsText))
            {
                var assembly = typeof(App).GetTypeInfo().Assembly;

                using (var stream = assembly.GetManifestResourceStream("eXam.Data.questions.xml"))
                {
                    questionsText = new StreamReader(stream).ReadToEnd();
                }

                await fileHelper.SaveLocalFileAsync("cachedquestions.xml", questionsText);
            }

            var questions = QuizQuestionXmlSerializer.Deserialize(questionsText);

            CurrentGame = new Game(questions);

            if (CrossConnectivity.Current.IsConnected)
            {
                Debug.WriteLine("Connected");
            }
            else
            {
                Debug.WriteLine("Not connected");
            }
        }
Example #2
0
        protected override async void OnStart()
        {
            // Handle when your app starts
            var assembly          = typeof(App).GetTypeInfo().Assembly;
            var resourceStream    = assembly.GetManifestResourceStream("eXam.Data.questions.xml");
            var reader            = new StreamReader(resourceStream);
            var xml               = reader.ReadToEnd();
            var embeddedQuestions = QuizQuestionXmlSerializer.Deserialize(xml);

            CurrentGame = new Game(embeddedQuestions);
        }
Example #3
0
        protected override void OnStart()
        {
            // Handle when your app starts
            var assembly = typeof(App).GetTypeInfo().Assembly;

            string questionText;

            using (var stream = assembly.GetManifestResourceStream("eXam.Data.questions.xml"))
            {
                questionText = new StreamReader(stream).ReadToEnd();
            }

            var questions = QuizQuestionXmlSerializer.Deserialize(questionText);

            CurrentGame = new Game(questions);
        }
Example #4
0
        protected override async void OnStart()
        {
            // Handle when your app starts
            var assembly          = typeof(App).GetTypeInfo().Assembly;
            var resourceStream    = assembly.GetManifestResourceStream("eXam.Data.questions.xml");
            var reader            = new StreamReader(resourceStream);
            var xml               = reader.ReadToEnd();
            var embeddedQuestions = QuizQuestionXmlSerializer.Deserialize(xml);

            CurrentGame = new Game(embeddedQuestions);
            IFileHelper fileHelper      = DependencyService.Get <IFileHelper>();
            var         cachedQuestions = await fileHelper.LoadLocalFileAsync("cachedquestions.xml");

            if (string.IsNullOrWhiteSpace(cachedQuestions))
            {
                await fileHelper.SaveLocalFileAsync("cachedquestions.xml", xml);
            }
        }