C#

Extension Methods – Serialize/Deserialize as Json/XML

Cranked these out last night, hope you find it useful too 1: public static class SerializationExtensions 2: { 3: private static readonly ConcurrentDictionary<Type, XmlSerializer> XmlSerializers = 4: new ConcurrentDictionary<Type, XmlSerializer>(); 5: 6: private static readonly ConcurrentDictionary<Type, DataContractJsonSerializer> JsonSerializers = 7: new ConcurrentDictionary<Type, DataContractJsonSerializer>(); 8: 9: private static readonly JavaScriptSerializer JavaScriptSerializer = new JavaScriptSerializer(); 10: 11: …

Extension Methods – Serialize/Deserialize as Json/XML Read More »

S3 – Use using block to get the stream

When you’re using the Amazon S3 client, have you come across the occasional exception that says something like one of these exception messages: “The request was aborted: The connection was closed unexpectedly” “Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall” “Unable to read data from …

S3 – Use using block to get the stream Read More »

Extension Methods – Helpful parse methods for string

1: /// <summary> 2: /// Parses a string as a short 3: /// </summary> 4: public static short ParseShort(this string str, bool throwOnOverflow = true) 5: { 6: return str.ParseAsStruct(Convert.ToInt16, throwOnOverflow); 7: } 8:  9: /// <summary> 10: /// Parses a string as an ushort 11: /// </summary> 12: public static ushort ParseUshort(this string str, …

Extension Methods – Helpful parse methods for string Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close