Example #1
0
        public static RollConstraint __constraint_Deserialize_Roll(JsonNode parsed)
        {
            var value = new RollConstraint();

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

                if (key == "extensions")
                {
                    value.Extensions = new glTFExtensionImport(kv.Value);
                    continue;
                }

                if (key == "extras")
                {
                    value.Extras = new glTFExtensionImport(kv.Value);
                    continue;
                }

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

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

                if (key == "rollAxis")
                {
                    value.RollAxis = (RollAxis)Enum.Parse(typeof(RollAxis), kv.Value.GetString(), true);
                    continue;
                }

                if (key == "weight")
                {
                    value.Weight = kv.Value.GetSingle();
                    continue;
                }
            }
            return(value);
        }
Example #2
0
        public static void __constraint_Serialize_Roll(JsonFormatter f, RollConstraint value)
        {
            f.BeginMap();


            if (value.Extensions != null)
            {
                f.Key("extensions");
                (value.Extensions as glTFExtension).Serialize(f);
            }

            if (value.Extras != null)
            {
                f.Key("extras");
                (value.Extras as glTFExtension).Serialize(f);
            }

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

            if (value.Source.HasValue)
            {
                f.Key("source");
                f.Value(value.Source.GetValueOrDefault());
            }

            if (true)
            {
                f.Key("rollAxis");
                f.Value(value.RollAxis.ToString());
            }

            if (value.Weight.HasValue)
            {
                f.Key("weight");
                f.Value(value.Weight.GetValueOrDefault());
            }

            f.EndMap();
        }