Revision: 33358
Updated Code
at October 11, 2010 20:33 by dzr_gregory
Updated Code
using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; namespace ConnectionClasses { [Serializable] public abstract class Connection { public int ID { get; set; } public String Name { get; set; } public string SerializeToBase64String() { return Connection.SerializeToBase64String(this); } public static string SerializeToBase64String(Connection connection) { using (var ms = new MemoryStream()) { new BinaryFormatter().Serialize(ms, connection); ms.Seek(0, SeekOrigin.Begin); return Convert.ToBase64String(ms.ToArray()); } } public static Connection DeserializeFromBase64String(String str) { using (var ms = new MemoryStream(Convert.FromBase64String(str))) { ms.Seek(0, SeekOrigin.Begin); return (Connection) new BinaryFormatter().Deserialize(ms); } } } }
Revision: 33357
Updated Code
at October 8, 2010 05:28 by dzr_gregory
Updated Code
using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; namespace RemoteClient.ConnectionClasses { [Serializable] public abstract class Connection { public String Name { get; set; } public abstract String GetDetailsText(); public abstract String GetIconPath(); public abstract bool UIAdd(out Connection c); public abstract bool UIEdit(ref Connection c); public abstract void Execute(); public static string SerializeToBase64String(Connection connection) { using (var ms = new MemoryStream()) { new BinaryFormatter().Serialize(ms, connection); ms.Seek(0, SeekOrigin.Begin); return Convert.ToBase64String(ms.ToArray()); } } public static Connection DeserializeFromBase64String(String str) { using (var ms = new MemoryStream(Convert.FromBase64String(str))) { ms.Seek(0, SeekOrigin.Begin); return (Connection) new BinaryFormatter().Deserialize(ms); } } } }
Revision: 33356
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 8, 2010 05:03 by dzr_gregory
Initial Code
using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; namespace RemoteClient.ConnectionClasses { /// <summary> /// Базовый клаÑÑ Ð¿Ð¾Ð´ÐºÐ»ÑŽÑ‡ÐµÐ½Ð¸Ñ /// </summary> [Serializable] public abstract class Connection { public String Name { get; set; } public abstract String GetDetailsText(); public abstract String GetIconPath(); public abstract bool UIAdd(out Connection c); public abstract bool UIEdit(ref Connection c); public abstract void Execute(); public static string SerializeToBase64String(Connection connection) { using (var ms = new MemoryStream()) { new BinaryFormatter().Serialize(ms, connection); ms.Seek(0, SeekOrigin.Begin); return Convert.ToBase64String(ms.ToArray()); } } public static Connection DeserializeFromBase64String(String str) { using (var ms = new MemoryStream(Convert.FromBase64String(str))) { ms.Seek(0, SeekOrigin.Begin); return (Connection) new BinaryFormatter().Deserialize(ms); } } } }
Initial URL
Initial Description
Initial Title
Class serialization/deserialization using Base64 encoding
Initial Tags
c
Initial Language
C#