Ejemplo n.º 1
0
        protected Api()
        {
            jsonBuffer = new System.Buffers.ArrayBufferWriter <byte>();
            var jsonOptions = new System.Text.Json.JsonWriterOptions()
            {
                SkipValidation = true
            };

            jsonWriter = new System.Text.Json.Utf8JsonWriter(jsonBuffer, jsonOptions);
        }
Ejemplo n.º 2
0
        internal void _WriteJSON(System.IO.Stream sw, bool indented)
        {
            System.Text.Json.JsonWriterOptions options = default;

            options.Indented = indented;

            using (var writer = new System.Text.Json.Utf8JsonWriter(sw, options))
            {
                this.Serialize(writer);
            }
        }
        internal void _WriteJSON(System.IO.Stream sw, bool indented)
        {
            System.Text.Json.JsonWriterOptions options = new System.Text.Json.JsonWriterOptions()
            {
                Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
            };

            options.Indented = indented;

            using (var writer = new System.Text.Json.Utf8JsonWriter(sw, options))
            {
                this.Serialize(writer);
            }
        }
Ejemplo n.º 4
0
        public void TestJsonExtendedCharacters()
        {
            TestContext.CurrentContext.AttachShowDirLink();
            TestContext.CurrentContext.AttachGltfValidatorLinks();

            // create a test model

            var model = Schema2.ModelRoot.CreateModel();

            model.Asset.Copyright = UNESCAPED;
            model.UseScene(UNESCAPED);
            model.Asset.Extras = JsonContent.CreateFrom(new string[] { UNESCAPED, ESCAPED, UNESCAPED });
            model.CreateImage().Content = Memory.MemoryImage.DefaultPngImage;

            // create write settings

            var joptions = new System.Text.Json.JsonWriterOptions
            {
                Indented = true,
                Encoder  = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
            };

            var wsettings = new Schema2.WriteSettings();

            wsettings.JsonOptions = joptions;

            // model save-load roundtrip

            var roundtripPath  = model.AttachToCurrentTest("extended 你好 characters.gltf", wsettings);
            var roundtripJson  = System.IO.File.ReadAllText(roundtripPath);
            var roundtripModel = Schema2.ModelRoot.Load(roundtripPath);

            // checks

            TestContext.WriteLine(roundtripJson);

            Assert.IsTrue(roundtripJson.Contains("你好"));

            // https://github.com/KhronosGroup/glTF/issues/1978#issuecomment-831744624
            Assert.IsTrue(roundtripJson.Contains("extended%20%E4%BD%A0%E5%A5%BD%20characters.png"));

            Assert.IsTrue(roundtripModel.LogicalImages[0].Content.IsPng);
        }
 public Utf8JsonWriter(System.IO.Stream utf8Json, System.Text.Json.JsonWriterOptions options = default(System.Text.Json.JsonWriterOptions))
 {
 }
 public Utf8JsonWriter(System.Buffers.IBufferWriter <byte> bufferWriter, System.Text.Json.JsonWriterOptions options = default(System.Text.Json.JsonWriterOptions))
 {
 }
Ejemplo n.º 7
0
 public JsonWriterState(System.Text.Json.JsonWriterOptions options = default(System.Text.Json.JsonWriterOptions))
 {
     throw null;
 }