コード例 #1
0
 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);
     }
 }
コード例 #2
0
 public static T ToModel <T>(string xml)
 {
     try
     {
         return(ExtensibleMarkupLanguage.XmlToModel <T>(xml));
     }
     catch (Exception ex)
     {
         throw new FormatDeserializeException(Constants.Format.DESERIALIZE_ERROR_MESSAGE, ex, FormatRange.Xml, typeof(T), xml);
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        public Response <T> ToModel <T>(string xml)
        {
            var response = new Response <T>();

            try
            {
                var model = ExtensibleMarkupLanguage.XmlToModel <T>(xml);
                response = response.With(model);
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error deserializing format to type {typeof(T).FullName}: {ex}");
            }

            return(response);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public Maybe <T, FormatDeserializeException> ToModel <T>(string xml)
        {
            var maybe = new Maybe <T, FormatDeserializeException>();

            try
            {
                var model = ExtensibleMarkupLanguage.XmlToModel <T>(xml);
                maybe = maybe.With(model);
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error deserializing format to type {typeof(T).FullName}: {ex}");
                maybe = maybe.With(new FormatDeserializeException(Constants.Format.DESERIALIZE_ERROR_MESSAGE, ex, FormatRange.Xml, typeof(T), xml));
            }

            return(maybe);
        }