public virtual object Deserialize(string input, Type type) { lock (_lock) { for (var i = 0; i < encoders.Count; i++) { try { ITypeEncoder encoder = encoders[i]; if (!encoder.IsSupport(type)) { continue; } return(encoder.Decode(type, input)); } catch (Exception) { } } } throw new NotSupportedException(string.Format("This value \"{0}\" cannot be converted to the type \"{1}\"", input, type.Name)); }
public virtual string Serialize(object value) { lock (_lock) { for (var i = 0; i < encoders.Count; i++) { try { ITypeEncoder encoder = encoders[i]; if (!encoder.IsSupport(value.GetType())) { continue; } return(encoder.Encode(value)); } catch (Exception) { } } } throw new NotSupportedException(string.Format("Unsupported type, this value \"{0}\" cannot be serialized", value)); }
public virtual string Serialize(object value) { lock (_lock) { for (int i = 0; i < _encoders.Count; i++) { try { ITypeEncoder encoder = _encoders[i]; if (!encoder.IsSupport(value.GetType())) { continue; } return(encoder.Encode(value)); } catch (Exception e) { Log.Error(e); } } } throw new NotSupportedException($"Unsupported type, this value \"{value}\" cannot be serialized"); }
public virtual string Serialize(object value) { lock (_lock) { for (int i = 0; i < encoders.Count; i++) { try { ITypeEncoder encoder = encoders[i]; if (!encoder.IsSupport(value.GetType())) { continue; } return(encoder.Encode(value)); } catch (Exception) { } } } throw new NotSupportedException(); }
public virtual object Deserialize(string input, Type type) { lock (_lock) { for (int i = 0; i < encoders.Count; i++) { try { ITypeEncoder encoder = encoders[i]; if (!encoder.IsSupport(type)) { continue; } return(encoder.Decode(type, input)); } catch (Exception) { } } } throw new NotSupportedException(); }