public static List <T> DeserializeTokens <T>(JsonReader reader)
        {
            JObject jsonObject          = JObject.Load(reader);
            JEnumerable <JToken> tokens = jsonObject.Children();

            return(tokens.Select(token => token.First.ToObject <T>()).ToList());
        }
        public IEnumerable <string> MapToCollectionOfCarPhotoUris(string jsonString)
        {
            JObject jObject = JObject.Parse(jsonString);
            JEnumerable <JToken> photoJTokens = jObject.SelectToken("data").First.First.Children();
            IEnumerable <string> carPhotoUris = photoJTokens.Select(p => p.First.SelectToken("formats").First.Value <string>());

            return(carPhotoUris);
        }
Beispiel #3
0
        private static IEnumerable <string> GetProfileNames()
        {
            string localJsonChrome = Path.Combine(ChromeDataPath, "Local State");
            JEnumerable <JToken> tokenEnumProfile =
                JObject.Parse(File.ReadAllText(localJsonChrome))["profile"]["info_cache"].Children();
            List <string> profileList = tokenEnumProfile
                                        .Select(item => item.Path.Substring(item.Path.LastIndexOf(".", StringComparison.Ordinal) + 1)).ToList();

            return(profileList);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jsonObject          = JObject.Load(reader);
            JEnumerable <JToken> tokens = jsonObject.Children();

            return(tokens.Select(token =>
            {
                var obj = token.First.ToObject <Research>();
                obj.Name = ((JProperty)token).Name;
                return obj;
            }).ToList());
        }
Beispiel #5
0
        public static IEnumerable <Uri> GetReceiveEndpointAddresses(this IBus bus)
        {
            var probeResult = bus.GetProbeResult();

            var probeJObject = JObject.Parse(probeResult.ToJsonString());
            JEnumerable <JToken> receiveEndpoints = probeJObject["results"]["bus"]["host"]["receiveEndpoint"].Children();

            IEnumerable <ReceiveTransportProbeResult> probeResults = receiveEndpoints.Select(result =>
                                                                                             JsonConvert.DeserializeObject <ReceiveTransportProbeResult>(result["inMemoryReceiveTransport"].ToString()))
                                                                     .Where(x => x.Address != null);

            return(probeResults.Select(result => new Uri(result.Address)));
        }
Beispiel #6
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JArray jsonArray            = JArray.Load(reader);
            JEnumerable <JToken> tokens = jsonArray.Children();

            return(tokens.Select(token =>
            {
                return new Order
                {
                    Delay = token[0].ToObject <int>(),
                    StarId = token[1].ToObject <int>(),
                    Action = token[2].ToObject <int>(),
                    Ships = token[3].ToObject <int>()
                };
            }).ToList());
        }
Beispiel #7
0
        private void DownloadData(PackType type)
        {
            downloadingData = true;

            frmDescription.instance.Hide();

            int    index            = comboBox1.SelectedIndex;
            string path             = GetFolderPathVer(index, type);
            JToken verObj           = GetVersion(index, type);
            JEnumerable <JToken> dl = verObj["Files"].Children();

            if (type == PackType.Client)
            {
                btnRuninsClient.Text = "Cancelar instalacion";
            }
            else
            {
                btnRunisServer.Text = "Cancelar instalacion";
            }

            //Set maximums
            pbFileProgress.Maximum  = 100; //verObj["TotalSize"].ToObject<int>();
            pbTotalProgress.Maximum = 100;

            PhaseManager.PhaseCompleted += (i) =>
            {
                switch (i)
                {       //Do something special when...
                case 0: //... Modpack downloaded
                    break;

                case 1:     //... TLauncher Files downloaded
                    break;

                case 2:     //... TLauncher Config downloaded
                    ModifyMCLProperties(LauncherFolderPath);
                    break;
                }
            };

            PhaseManager phase = new PhaseManager(type,
                                                  new DownloadPack(verObj["TotalSize"].ToObject <long>(),
                                                                   dl.Select(token =>
            {
                return(new DownloadPath(new Uri(token["FileUrl"].ToObject <string>()), Path.Combine(path, token["FileRelPath"].ToObject <string>())));
            })
                                                                   ),
                                                  new DownloadPack(TLauncherData, LauncherFolderPath));

            //Check if appdata folder exists and if not add download and then do the following or if it exists modify the value from the config to another one

            if (!File.Exists(MCLPath))
            {
                PhaseManager.instance.AddDownload(new DownloadPack(TLauncherConfig, Path.GetDirectoryName(MCLPath)));
            }
            else
            {
                ModifyMCLProperties(LauncherFolderPath);
            }

            phase.Download(1);
        }