public static List <SecureString> ParseCollection(BufferedTextReader reader, int context, bool allowNulls) { var list = ByteaConverter.ParseCollection(reader, context, allowNulls); if (list == null) { return(null); } var result = new List <SecureString>(); foreach (var item in list) { if (item == null) { result.Add(null); continue; } var ss = new SecureString(); var bytes = RsaProvider.Decrypt(item, false); var chars = Encoding.Unicode.GetChars(bytes); for (int i = 0; i < chars.Length; i++) { ss.AppendChar(chars[i]); } result.Add(ss); } return(result); }
public static IPostgresTuple ToTuple(SecureString value) { if (value == null) { return(null); } return(ByteaConverter.ToTuple(ExtractBytesAndEcrypt(value))); }
public static int Serialize(Image value, char[] buf, int pos) { using (var ms = new MemoryStream()) { SaveImage(value, ms); ms.Position = 0; return(ByteaConverter.Serialize(ms.ToArray(), buf, pos)); } }
public static Image Parse(BufferedTextReader reader, int context) { var stream = ByteaConverter.ParseStream(reader, context); if (stream == null) { return(null); } return(Image.FromStream(stream)); }
public static Image FromDatabase(string value) { if (value == null) { return(null); } var bytes = ByteaConverter.FromDatabase(value); var ms = new MemoryStream(bytes); return(Image.FromStream(ms)); }
public static IPostgresTuple ToTuple(Image value) { if (value == null) { return(null); } var cms = ChunkedMemoryStream.Create(); SaveImage(value, cms); cms.Position = 0; return(ByteaConverter.ToTuple(cms, true)); }
public static List <Image> ParseCollection(BufferedTextReader reader, int context) { var list = ByteaConverter.ParseStreamCollection(reader, context, true); if (list == null) { return(null); } var result = new List <Image>(list.Count); foreach (var stream in list) { result.Add(stream != null ? Image.FromStream(stream) : null); } return(result); }
public static SecureString FromDatabase(string value) { if (value == null) { return(null); } var data = ByteaConverter.FromDatabase(value); var ss = new SecureString(); var decrypt = RsaProvider.Decrypt(data, false); var chars = Encoding.Unicode.GetChars(decrypt); for (int i = 0; i < chars.Length; i++) { ss.AppendChar(chars[i]); } return(ss); }
public static SecureString ParseNullable(BufferedTextReader reader, int context) { var bytes = ByteaConverter.Parse(reader, context); if (bytes == null) { return(null); } var ss = new SecureString(); var decrypt = RsaProvider.Decrypt(bytes, false); var chars = Encoding.Unicode.GetChars(decrypt); for (int i = 0; i < chars.Length; i++) { ss.AppendChar(chars[i]); } return(ss); }
public static int Serialize(SecureString value, char[] buf, int pos) { return(ByteaConverter.Serialize(ExtractBytesAndEcrypt(value), buf, pos)); }