public void Serialize(Stream targetStream, WsConfig config) { try { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(WsSerializableConfig)); WsSerializableConfig serializableConfig = new WsSerializableConfig(config); serializer.WriteObject(targetStream, serializableConfig); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } }
public WsConfig Deserialize(Stream sourceStream) { try { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(WsSerializableConfig)); WsSerializableConfig serializableConfig = (WsSerializableConfig)serializer.ReadObject(sourceStream); return(new WsConfig(serializableConfig, _onChange, _protector)); } catch (Exception ex) { Trace.TraceError(ex.ToString()); return(new WsConfig()); } }
internal WsConfig(WsSerializableConfig serializableConfig, Action onChange, IDataProtector protector) { DeviceUuid = serializableConfig.DeviceUuid; Accounts = serializableConfig.Accounts.Select(c => new WsAccount(c, onChange, protector)).ToArray(); }