示例#1
0
 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());
     }
 }
示例#2
0
 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());
     }
 }
示例#3
0
 internal WsConfig(WsSerializableConfig serializableConfig, Action onChange, IDataProtector protector)
 {
     DeviceUuid = serializableConfig.DeviceUuid;
     Accounts   = serializableConfig.Accounts.Select(c => new WsAccount(c, onChange, protector)).ToArray();
 }