Esempio n. 1
0
        private VersionsFileContent ParseVersionsXml(string xml)
        {
            var xmlDoc = XmlUtils.Parse(xml);

            var result = new VersionsFileContent();

            result.DefaultFolder = xmlDoc.Root.GetAttributeValue("defaultFolder");

            foreach (var clientXmlElement in xmlDoc.Root.Elements("client"))
            {
                result.Clients.Add(new VersionsFileContent.ClientElement(clientXmlElement.GetAttributeValue("brand"),
                                                                         clientXmlElement.GetAttributeValue("skin"),
                                                                         clientXmlElement.GetAttributeValue("lang"),
                                                                         clientXmlElement.GetAttributeValue("version"),
                                                                         null));
            }

            return(result);
        }
Esempio n. 2
0
        public static VersionsFileContent ParseVersionsJson(string versionsJson)
        {
            dynamic versions = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(versionsJson);

            var result = new VersionsFileContent();

            if (((JObject)versions).Property(JsonNames._default) != null)
            {
                var defaultVersion = ((JObject)versions).Property(JsonNames._default).Value as JObject;
                result.DefaultFolder      = defaultVersion.Property(JsonNames.version).Value.ToString();
                result.PreloaderSetupPath = defaultVersion.Property(JsonNames.setup).Value.ToString();
            }
            else
            {
                result.DefaultFolder = ConvertDynamicValue <string>(versions.defaultFolder);
            }


            if (versions.clients == null)
            {
                return(result);
            }

            foreach (dynamic clientVersion in versions.clients)
            {
                string language = clientVersion.lang?.ToString();
                if (language == null)
                {
                    language = clientVersion.language?.ToString();
                }

                result.Clients.Add(new VersionsFileContent.ClientElement(ConvertDynamicValue <string>(clientVersion.brand),
                                                                         ConvertDynamicValue <string>(clientVersion.skin),
                                                                         language,
                                                                         ConvertDynamicValue <string>(clientVersion.version),
                                                                         ConvertDynamicValue <string>(clientVersion.setup)));
            }

            return(result);
        }
Esempio n. 3
0
        public static ClientVersionInfo ExtractVersion(BrandEntity brand, SkinEntity skin, VersionsFileContent versions)
        {
            var specificVersion = versions.Clients.FirstOrDefault(c => c.Brand == brand.Id.ToString() &&
                                                                  c.Skin == skin.Id.ToString() &&
                                                                  c.Language == "eng");

            if (specificVersion == null)
            {
                specificVersion = versions.Clients.FirstOrDefault(c => c.Brand == brand.Id.ToString() &&
                                                                  c.Skin == skin.Id.ToString() &&
                                                                  c.Language == "*");
            }

            if (specificVersion == null)
            {
                specificVersion = versions.Clients.FirstOrDefault(c => c.Brand == brand.Id.ToString() &&
                                                                  c.Skin == "*" &&
                                                                  c.Language == "*");
            }

            if (specificVersion != null)
            {
                return(new ClientVersionInfo(specificVersion.Version, specificVersion.PreloaderSetupPath));
            }
            else
            {
                return(new ClientVersionInfo(versions.DefaultFolder, versions.PreloaderSetupPath));
            }
        }