Exemplo n.º 1
0
            public override bool IsValueDefault <T>(string field, T value)
            {
                if (CurrentWritingEntity.Prototype == null)
                {
                    // No prototype, can't be default.
                    return(false);
                }

                if (!CurrentWritingEntity.Prototype.Components.TryGetValue(CurrentWritingComponent, out var compData))
                {
                    // This component was added mid-game.
                    return(false);
                }

                var testSer = YamlObjectSerializer.NewReader(compData);

                if (testSer.TryReadDataFieldCached(field, out T prototypeVal))
                {
                    if (value == null)
                    {
                        return(prototypeVal == null);
                    }

                    return(YamlObjectSerializer.IsSerializedEqual(value, prototypeVal));
                }

                return(false);
            }
Exemplo n.º 2
0
        public void SerializedEqualDictTest()
        {
            var dict = new Dictionary <string, string>
            {
                ["A"] = "B",
                ["C"] = "W",
                ["D"] = "G",
                ["E"] = "J"
            };

            var dict2 = new Dictionary <string, string>(dict);

            Assert.That(YamlObjectSerializer.IsSerializedEqual(dict, dict2), Is.True);
        }