Inheritance: Newtonsoft.Json.JsonReader
コード例 #1
0
ファイル: Program.cs プロジェクト: williamalveslp/Entropy
        static void Strip(string id, string path)
        {
            var directoryInfo = new DirectoryInfo(path);

            foreach (var fileInfo in directoryInfo.EnumerateFiles(id.ToLowerInvariant() + "_*.json"))
            {
                using (FileStream stream = fileInfo.OpenRead())
                {
                    using (var textReader = new StreamReader(stream))
                    {
                        using (var jsonReader = new JsonSkipReader(new JsonTextReader(textReader)))
                        {
                            JObject obj = JObject.Load(jsonReader);
                            foreach (var item in obj["items"])
                            {
                                JToken catalogEntry = item["catalogEntry"];
                                Console.WriteLine("{0}/{1}", catalogEntry["id"], catalogEntry["version"]);
                            }
                            File.WriteAllText(fileInfo.FullName + ".txt", obj.ToString(Formatting.None));
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: williamalveslp/Entropy
        static void Test1()
        {
            const string Id   = "ravendb.client";
            const string Path = @"c:\data\scratch\";

            Download(Id, Path).Wait();
            Inline(Id, Path);

            var fileInfo = new FileInfo(Path + "inline.json");

            using (var stream = fileInfo.OpenRead())
            {
                using (var textReader = new StreamReader(stream))
                {
                    using (var jsonReader = new JsonSkipReader(new JsonTextReader(textReader)))
                    {
                        JObject obj = JObject.Load(jsonReader);

                        File.WriteAllText(Path + "inlineSkipped.json", obj.ToString());
                        File.WriteAllText(Path + "inlineSkippedAndMinified.json", obj.ToString(Formatting.None));
                    }
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: NuGet/Entropy
        static void Strip(string id, string path)
        {
            var directoryInfo = new DirectoryInfo(path);

            foreach (var fileInfo in directoryInfo.EnumerateFiles(id.ToLowerInvariant() + "_*.json"))
            {
                using (FileStream stream = fileInfo.OpenRead())
                {
                    using (var textReader = new StreamReader(stream))
                    {
                        using (var jsonReader = new JsonSkipReader(new JsonTextReader(textReader)))
                        {
                            JObject obj = JObject.Load(jsonReader);
                            foreach (var item in obj["items"])
                            {
                                JToken catalogEntry = item["catalogEntry"];
                                Console.WriteLine("{0}/{1}", catalogEntry["id"], catalogEntry["version"]);
                            }
                            File.WriteAllText(fileInfo.FullName + ".txt", obj.ToString(Formatting.None));
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: NuGet/Entropy
        static void Test1()
        {
            const string Id = "ravendb.client";
            const string Path = @"c:\data\scratch\";
            Download(Id, Path).Wait();
            Inline(Id, Path);

            var fileInfo = new FileInfo(Path + "inline.json");

            using (var stream = fileInfo.OpenRead())
            {
                using (var textReader = new StreamReader(stream))
                {
                    using (var jsonReader = new JsonSkipReader(new JsonTextReader(textReader)))
                    {
                        JObject obj = JObject.Load(jsonReader);

                        File.WriteAllText(Path + "inlineSkipped.json", obj.ToString());
                        File.WriteAllText(Path + "inlineSkippedAndMinified.json", obj.ToString(Formatting.None));
                    }
                }
            }
        }
コード例 #5
0
ファイル: Startup.cs プロジェクト: NuGet/Entropy
        async Task<JObject> FetchMissingPage(string pageUri)
        {
            HttpClient client = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(pageUri);

            Stream stream = await response.Content.ReadAsStreamAsync();

            using (var textReader = new StreamReader(stream))
            {
                using (var jsonReader = new JsonSkipReader(new JsonTextReader(textReader), RegistrationPageJsonPathToSkip()))
                {
                    return JObject.Load(jsonReader);
                }
            }
        }
コード例 #6
0
ファイル: Startup.cs プロジェクト: NuGet/Entropy
        async Task InterceptRegistrationIndex(string remoteResourceId, IOwinContext context)
        {
            HttpClient client = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(remoteResourceId);

            Stream stream = await response.Content.ReadAsStreamAsync();

            using (var textReader = new StreamReader(stream))
            {
                using (var jsonReader = new JsonSkipReader(new JsonTextReader(textReader), RegistrationIndexJsonPathToSkip()))
                {
                    var obj = JObject.Load(jsonReader);

                    await InlineRegistration(obj);

                    context.Response.ContentType = response.Content.Headers.ContentType.MediaType;
                    context.Response.StatusCode = (int)HttpStatusCode.OK;
                    await context.Response.WriteAsync(obj.ToString(Formatting.None));
                }
            }
        }