public static T DeserializeDataContract <T>([NotNull] this TextReader thisValue, T defaultValue, bool verifyObjectName = false, DataContractSerializerSettings settings = null, XmlReaderSettings xmlOptions = null, XmlParserContext xmlContext = null) { XmlReaderSettings opt = xmlOptions ?? XmlReaderHelper.CreateSettings(); XmlParserContext context = xmlContext ?? XmlReaderHelper.CreateParserContext(opt.NameTable); using (XmlReader reader = XmlReader.Create(thisValue, opt, context)) { try { return(reader.DeserializeDataContract(defaultValue, verifyObjectName, settings)); } catch { return(defaultValue); } } }