Ejemplo n.º 1
0
        public static void Serializer(object untypedInput, ISerializationContext context, Type expected)
        {
            var type = untypedInput.GetType();

            var serialized = JsonSerializer.Serialize(untypedInput);

            //TODO: differentiate between activities defined in Orleans.Workflows and activities defined in other assemblies (no need to compile/decompile)
            SerializationManager.SerializeInner(type.ToSourceCode(), context);
            SerializationManager.SerializeInner(serialized, context);
        }
Ejemplo n.º 2
0
    private void Utf8JsonSample()
    {
        // UTF8Json : neuecc氏作、JsonUtilityと同様速い上に汎用的
        // Dose'nt work on HoloLens2 (IL2CPPxARM64)
        {
            var target = new PersonSerializableClassField
            {
                id        = 100,
                addresses = new AddressSerializableClassField[]
                {
                    new AddressSerializableClassField {
                        zipcode = 1002321, address = "hoge"
                    },
                    new AddressSerializableClassField {
                        zipcode = 1008492, address = "fuga"
                    },
                },
            };
            {
                var serialized = JsonSerializer.ToJsonString(target);
                Debug.Log(serialized);

                var deserialized = JsonSerializer.Deserialize <PersonSerializableClassField>(serialized);
                Debug.Log(deserialized.ToString());
            }

            {
                var serialized = JsonSerializer.Serialize(target);
                Debug.Log(Convert.ToBase64String(serialized));
                var tmp = System.Text.Encoding.UTF8.GetString(serialized);
                Debug.Log(tmp);


                var deserialized = JsonSerializer.Deserialize <PersonSerializableClassField>(serialized);
                Debug.Log(deserialized.ToString());
            }
        }

        {
            var target = new PersonPlaneClassProperty
            {
                Id        = 200,
                Addresses = new AddressPlaneClassProperty[]
                {
                    new AddressPlaneClassProperty {
                        Zipcode = 2003921, Address = "hoge"
                    },
                    new AddressPlaneClassProperty {
                        Zipcode = 2002955, Address = "fuga"
                    },
                },
            };

            var serialized = JsonSerializer.Serialize(target);
            Debug.Log(Convert.ToBase64String(serialized));
            var tmp = System.Text.Encoding.UTF8.GetString(serialized);
            Debug.Log(tmp);

            var deserialized = JsonSerializer.Deserialize <PersonPlaneClassProperty>(serialized);
            Debug.Log(deserialized.ToString());
        }

        {
            var target = new AddressRenamedProperty
            {
                Zipcode         = 3003924,
                Address         = "foobar",
                TelephoneNumber = "0312345678",
            };

            var serialized = JsonSerializer.Serialize(target);
            Debug.Log(Convert.ToBase64String(serialized));
            var tmp = System.Text.Encoding.UTF8.GetString(serialized);
            Debug.Log(tmp);

            var deserialized = JsonSerializer.Deserialize <AddressRenamedProperty>(serialized);
            Debug.Log(deserialized.ToString());
        }
    }