/* * GNU AFFERO GENERAL PUBLIC LICENSE * Version 3, 19 November 2007 * Copyright (C) 2007 Free Software Foundation, Inc. * Everyone is permitted to copy and distribute verbatim copies * of this license document, but changing it is not allowed. */ using System.IO; using System.Runtime.Serialization.Formatters.Binary; namespace PrusaSL1Reader.Extensions { public static class ObjectExtensions { /// /// Converts a string into a target type /// /// Target type to convert into /// Value /// Converted value into target type public static T Convert(this object input) { return StringExtensions.Convert(input.ToString()); } public static object DeserializeFromBytes(byte[] bytes) { var formatter = new BinaryFormatter(); using (var stream = new MemoryStream(bytes)) { return formatter.Deserialize(stream); } } } }