コード例 #1
0
        private void VerifyDocuments()
        {
            string embeddedXML;

            embeddedXML = EmbeddedResourcesHelper.ReadEmbeddedFile(_resourceConfigID);

            if (!DependencyService.Get <IFileReadWrite>().FileExist(_fileConfigID))
            {
                DependencyService.Get <IFileReadWrite>().WriteData(_fileConfigID, embeddedXML);
            }
            else
            {
                string platformXML;
                platformXML = DependencyService.Get <IFileReadWrite>().ReadData(_fileConfigID);

                XDocument embeddedDoc    = XDocument.Parse(embeddedXML);
                XDocument platformDoc    = XDocument.Parse(platformXML);
                bool      updateRequired = false;

                foreach (XElement embeddedElement in embeddedDoc.Root.Elements())
                {
                    bool elementFound = false;

                    foreach (XElement platformElement in platformDoc.Root.Elements())
                    {
                        if (platformElement.Name == embeddedElement.Name)
                        {
                            elementFound = true;
                            break;
                        }
                    }

                    if (!elementFound)
                    {
                        updateRequired = true;
                        platformDoc.Root.Add(new XElement(embeddedElement));
                    }
                }

                if (updateRequired)
                {
                    DependencyService.Get <IFileReadWrite>().WriteData(_fileConfigID, platformDoc.ToString());
                }
            }
        }
コード例 #2
0
ファイル: Languages.cs プロジェクト: Vince0382/DepartureTime
        public void LoadLanguagesXML(string resourceID)
        {
            if (!string.IsNullOrEmpty(resourceID))
            {
                string    xmlLanguageFile = EmbeddedResourcesHelper.ReadEmbeddedFile(resourceID);
                XDocument xMLStream       = XDocument.Parse(xmlLanguageFile);
                _availableLanguage = new List <string>();
                labelLanguages     = xMLStream.Descendants("Label");

                foreach (XElement language in labelLanguages.Descendants())
                {
                    if (!_availableLanguage.Contains(language.Name.ToString()))
                    {
                        _availableLanguage.Add(language.Name.ToString());
                    }
                }
            }
        }