public void MetaTest()
        {
            var model = new glTF_VRM_Meta()
            {
                allowedUserName      = "******",
                violentUssageName    = "Disallow",
                sexualUssageName     = "Disallow",
                commercialUssageName = "Disallow",
                licenseName          = "CC0",
            };

            var json = model.ToJson();

            Assert.AreEqual(@"{""texture"":-1,""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""sexualUssageName"":""Disallow"",""commercialUssageName"":""Disallow"",""licenseName"":""CC0""}", json);
            Debug.Log(json);

            var c = new JsonSchemaValidationContext("")
            {
                EnableDiagnosisForNotRequiredFields = true,
            };
            var json2 = JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c);

            // NOTE: New serializer outputs values which will not be used...
            Assert.AreEqual(@"{""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""sexualUssageName"":""Disallow"",""commercialUssageName"":""Disallow"",""licenseName"":""CC0""}", json2);
        }
        public static string ToJson(this glTF_VRM_Meta self)
        {
            var f = new JsonFormatter();

            VRMSerializer.Serialize_vrm_meta(f, self);
            return(f.ToString());
        }
        public void MetaTest()
        {
            var model = new glTF_VRM_Meta()
            {
                allowedUserName      = "******",
                violentUssageName    = "Disallow",
                sexualUssageName     = "Disallow",
                commercialUssageName = "Disallow",
                licenseName          = "CC0",
            };

            var json = model.ToJson();

            Assert.AreEqual(@"{""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""sexualUssageName"":""Disallow"",""commercialUssageName"":""Disallow"",""licenseName"":""CC0""}", json);
            Debug.Log(json);
        }
Beispiel #4
0
        public void MetaTest()
        {
            var model = new glTF_VRM_Meta();

            var json = model.ToJson();

            Assert.AreEqual(@"{""texture"":-1}", json);
            Debug.Log(json);

            var c = new JsonSchemaValidationContext("")
            {
                EnableDiagnosisForNotRequiredFields = true,
            };
            var json2 = JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c);

            // NOTE: New serializer outputs values which will not be used...
            Assert.AreEqual(json, json2);
        }
Beispiel #5
0
        public static void Serialize_vrm_meta(JsonFormatter f, glTF_VRM_Meta value)
        {
            f.BeginMap();


            if (!string.IsNullOrEmpty(value.title))
            {
                f.Key("title");
                f.Value(value.title);
            }

            if (!string.IsNullOrEmpty(value.version))
            {
                f.Key("version");
                f.Value(value.version);
            }

            if (!string.IsNullOrEmpty(value.author))
            {
                f.Key("author");
                f.Value(value.author);
            }

            if (!string.IsNullOrEmpty(value.contactInformation))
            {
                f.Key("contactInformation");
                f.Value(value.contactInformation);
            }

            if (!string.IsNullOrEmpty(value.reference))
            {
                f.Key("reference");
                f.Value(value.reference);
            }

            if (value.texture >= 0)
            {
                f.Key("texture");
                f.Value(value.texture);
            }

            if (!string.IsNullOrEmpty(value.allowedUserName))
            {
                f.Key("allowedUserName");
                f.Value(value.allowedUserName);
            }

            if (!string.IsNullOrEmpty(value.violentUssageName))
            {
                f.Key("violentUssageName");
                f.Value(value.violentUssageName);
            }

            if (!string.IsNullOrEmpty(value.sexualUssageName))
            {
                f.Key("sexualUssageName");
                f.Value(value.sexualUssageName);
            }

            if (!string.IsNullOrEmpty(value.commercialUssageName))
            {
                f.Key("commercialUssageName");
                f.Value(value.commercialUssageName);
            }

            if (!string.IsNullOrEmpty(value.otherPermissionUrl))
            {
                f.Key("otherPermissionUrl");
                f.Value(value.otherPermissionUrl);
            }

            if (!string.IsNullOrEmpty(value.licenseName))
            {
                f.Key("licenseName");
                f.Value(value.licenseName);
            }

            if (!string.IsNullOrEmpty(value.otherLicenseUrl))
            {
                f.Key("otherLicenseUrl");
                f.Value(value.otherLicenseUrl);
            }

            f.EndMap();
        }
Beispiel #6
0
        public static glTF_VRM_Meta Deserialize_vrm_meta(ListTreeNode <JsonValue> parsed)
        {
            var value = new glTF_VRM_Meta();

            foreach (var kv in parsed.ObjectItems())
            {
                var key = kv.Key.GetString();

                if (key == "title")
                {
                    value.title = kv.Value.GetString();
                    continue;
                }

                if (key == "version")
                {
                    value.version = kv.Value.GetString();
                    continue;
                }

                if (key == "author")
                {
                    value.author = kv.Value.GetString();
                    continue;
                }

                if (key == "contactInformation")
                {
                    value.contactInformation = kv.Value.GetString();
                    continue;
                }

                if (key == "reference")
                {
                    value.reference = kv.Value.GetString();
                    continue;
                }

                if (key == "texture")
                {
                    value.texture = kv.Value.GetInt32();
                    continue;
                }

                if (key == "allowedUserName")
                {
                    value.allowedUserName = kv.Value.GetString();
                    continue;
                }

                if (key == "violentUssageName")
                {
                    value.violentUssageName = kv.Value.GetString();
                    continue;
                }

                if (key == "sexualUssageName")
                {
                    value.sexualUssageName = kv.Value.GetString();
                    continue;
                }

                if (key == "commercialUssageName")
                {
                    value.commercialUssageName = kv.Value.GetString();
                    continue;
                }

                if (key == "otherPermissionUrl")
                {
                    value.otherPermissionUrl = kv.Value.GetString();
                    continue;
                }

                if (key == "licenseName")
                {
                    value.licenseName = kv.Value.GetString();
                    continue;
                }

                if (key == "otherLicenseUrl")
                {
                    value.otherLicenseUrl = kv.Value.GetString();
                    continue;
                }
            }
            return(value);
        }
        public void MetaTestError()
        {
            {
                var model = new glTF_VRM_Meta();

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[allowedUserName.String] null", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    //licenseName = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[licenseName.String] null", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "_INVALID_SOME_THING_",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[licenseName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    // allowedUserName = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[allowedUserName.String] null", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[allowedUserName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName = "******",
                    //violentUssageName = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[violentUssageName.String] null", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "_INVALID_SOME_THING_",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[violentUssageName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName   = "******",
                    violentUssageName = "Disallow",
                    //sexualUssageName = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[sexualUssageName.String] null", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "_INVALID_SOME_THING_",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[sexualUssageName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName   = "******",
                    violentUssageName = "Disallow",
                    sexualUssageName  = "Disallow",
                    //commercialUssageName = "Disallow",
                    licenseName = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[commercialUssageName.String] null", ex.Message);
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "_INVALID_SOME_THING_",
                    licenseName          = "CC0",
                };

                var c = new JsonSchemaValidationContext("")
                {
                    EnableDiagnosisForNotRequiredFields = true,
                };
                var ex = Assert.Throws <JsonSchemaValidationException>(
                    () => JsonSchema.FromType <glTF_VRM_Meta>().Serialize(model, c)
                    );
                Assert.AreEqual("[commercialUssageName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message);
            }
        }
        public void MetaTestError()
        {
            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = null,
                    violentUssageName    = null,
                    sexualUssageName     = null,
                    commercialUssageName = null,
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    //licenseName = "CC0",
                    licenseName = null,
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "_INVALID_SOME_THING_",
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    // allowedUserName = "******",
                    allowedUserName      = null,
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName = "******",
                    //violentUssageName = "Disallow",
                    violentUssageName    = null,
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "_INVALID_SOME_THING_",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName   = "******",
                    violentUssageName = "Disallow",
                    //sexualUssageName = "Disallow",
                    sexualUssageName     = null,
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "_INVALID_SOME_THING_",
                    commercialUssageName = "Disallow",
                    licenseName          = "CC0",
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName   = "******",
                    violentUssageName = "Disallow",
                    sexualUssageName  = "Disallow",
                    //commercialUssageName = "Disallow",
                    commercialUssageName = null,
                    licenseName          = "CC0",
                };
            }

            {
                var model = new glTF_VRM_Meta()
                {
                    allowedUserName      = "******",
                    violentUssageName    = "Disallow",
                    sexualUssageName     = "Disallow",
                    commercialUssageName = "_INVALID_SOME_THING_",
                    licenseName          = "CC0",
                };
            }
        }