Ejemplo n.º 1
0
        /// <summary>
        /// Recreates the object using serialization, to ensure it's not a subclass.
        /// If it's a subclass it may not serlialize properly to xml (different root element tag name)
        /// </summary>
        /// <param name="profile"></param>
        /// <returns></returns>
        private DeviceProfile ReserializeProfile(DeviceProfile profile)
        {
            if (profile.GetType() == typeof(DeviceProfile))
            {
                return(profile);
            }

            var json = _jsonSerializer.SerializeToString(profile);

            return(_jsonSerializer.DeserializeFromString <DeviceProfile>(json));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Recreates the object using serialization, to ensure it's not a subclass.
        /// If it's a subclass it may not serialize properly to xml (different root element tag name).
        /// </summary>
        /// <param name="profile">The device profile.</param>
        /// <returns>The re-serialized device profile.</returns>
        private DeviceProfile ReserializeProfile(DeviceProfile profile)
        {
            if (profile.GetType() == typeof(DeviceProfile))
            {
                return(profile);
            }

            var json = JsonSerializer.Serialize(profile, _jsonOptions);

            return(JsonSerializer.Deserialize <DeviceProfile>(json, _jsonOptions));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Recreates the object using serialization, to ensure it's not a subclass.
        /// If it's a subclass it may not serialize properly to xml (different root element tag name).
        /// </summary>
        /// <param name="profile">The device profile.</param>
        /// <returns>The re-serialized device profile.</returns>
        private DeviceProfile ReserializeProfile(DeviceProfile profile)
        {
            if (profile.GetType() == typeof(DeviceProfile))
            {
                return(profile);
            }

            var json = JsonSerializer.Serialize(profile, _jsonOptions);

            // Output can't be null if the input isn't null
            return(JsonSerializer.Deserialize <DeviceProfile>(json, _jsonOptions) !);
        }