public static string FromModel <T>(T model, XmlOptions options) { try { return(ExtensibleMarkupLanguage.ModelToXml <T>(model, options)); } catch (Exception ex) { throw new FormatSerializeException(Constants.Format.SERIALIZE_ERROR_MESSAGE, ex, FormatRange.Xml, model); } }
public Response <string> FromModel <T>(T model, XmlOptions options) { var response = new Response <string>(); try { var json = ExtensibleMarkupLanguage.ModelToXml <T>(model, options); response = response.With(json); } catch (Exception ex) { ex.LogValue($"Error deserializing format to type {typeof(T).FullName}: {ex}"); } return(response); }
public Maybe <string, FormatSerializeException> FromModel <T>(T model, XmlOptions options) { var maybe = new Maybe <string, FormatSerializeException>(); try { var xml = ExtensibleMarkupLanguage.ModelToXml <T>(model, options); maybe = maybe.With(xml); } catch (Exception ex) { ex.LogValue($"Error serializing format to type {typeof(T).FullName}: {ex}"); maybe = maybe.With(new FormatSerializeException(Constants.Format.SERIALIZE_ERROR_MESSAGE, ex, FormatRange.Xml, model)); } return(maybe); }