Ejemplo n.º 1
0
        /// <inheritdoc/>
        public void AddValue(string key, object value, Type type = null)
        {
            if (type == null)
            {
                type = value == null ? typeof(object) : value.GetType();
            }

            data[key] = new XunitSerializationTriple(key, value, type);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a triple for a key/value pair of data in a complex object
        /// </summary>
        /// <param name="triple">The triple to be serialized</param>
        /// <returns>The serialized version of the triple</returns>
        public static string SerializeTriple(XunitSerializationTriple triple)
        {
            var serializedType  = SerializationHelper.GetTypeNameForSerialization(triple.Type);
            var serializedValue = Serialize(triple.Value);

            // Leaving off the colon is how we indicate null-ness
            if (serializedValue == null)
            {
                return($"{triple.Key}:{serializedType}");
            }

            return($"{triple.Key}:{serializedType}:{serializedValue}");
        }