public static Tuple <HierarchyConfigData, Guid> Deserialize(XElement xelem) { var hcd = new HierarchyConfigData(); var guid = Guid.Parse(xelem.Attribute("id").Value); { var dir = xelem.Element("directories"); if (dir == null) { throw new Exception("Missing <directories> element"); } if (XElementExtensions.ParseBool(dir.Attribute("null").Value)) { hcd = null; } else { var dat = HierarchyConfigEntry.Deserialize(dir.Elements().Single()); hcd.Entry = dat; } } { var dir = xelem.Element("selectednote"); if (dir == null) { throw new Exception("Missing <selectednote> element"); } if (XElementExtensions.ParseBool(dir.Attribute("null").Value)) { hcd.SelectedNote = null; } else { hcd.SelectedNote = dir.Value; } } { var dir = xelem.Element("selectedpath"); if (dir == null) { throw new Exception("Missing <selectedpath> element"); } if (XElementExtensions.ParseBool(dir.Attribute("null").Value)) { hcd.SelectedFolder = null; } else { hcd.SelectedFolder = DirectoryPath.Deserialize(dir.Elements()); } } return(Tuple.Create(hcd, guid)); }
public override void Deserialize(XElement input) { _id = XHelper.GetChildValueGUID(input, "ID"); _title = XHelper.GetChildValueString(input, "Title"); _text = XHelper.GetChildBase64String(input, "Text"); _path = DirectoryPath.Deserialize(XHelper.GetChildrenOrEmpty(input, "Path", "PathComponent")); _tags.Synchronize(XHelper.GetChildValueStringList(input, "Tags", "Tag")); _creationDate = XHelper.GetChildValueDateTimeOffset(input, "CreationDate"); _isPinned = XHelper.GetChildValue(input, "IsPinned", false); _modificationDate = XHelper.GetChildValueDateTimeOffset(input, "ModificationDate"); }
public override void Deserialize(XElement input) { using (SuppressDirtyChanges()) { _id = XHelper.GetChildValueGUID(input, "ID"); _text = XHelper.GetChildBase64String(input, "Text"); _title = Encoding.UTF8.GetString(Convert.FromBase64String(XHelper.GetChildValueString(input, "Title"))); _path = DirectoryPath.Deserialize(XHelper.GetChildrenOrEmpty(input, "Path", "PathComponent")); _pathRemote = XHelper.GetChildValueString(input, "PathRemote"); _creationDate = XHelper.GetChildValueDateTimeOffset(input, "CreationDate"); _modificationDate = XHelper.GetChildValueDateTimeOffset(input, "ModificationDate"); } }
public override void Deserialize(XElement input) { using (SuppressDirtyChanges()) { _remoteID = XHelper.GetChildValueInt(input, "RemoteID"); _localID = XHelper.GetChildValueGUID(input, "LocalID"); _content = XHelper.GetChildBase64String(input, "Content"); Path = DirectoryPath.Deserialize(XHelper.GetChildrenOrEmpty(input, "Path", "PathComponent")); _creationDate = XHelper.GetChildValueDateTimeOffset(input, "CreationDate"); _modificationDate = XHelper.GetChildValueDateTimeOffset(input, "ModificationDate"); _remoteTimestamp = XHelper.GetChildValueInt(input, "Timestamp"); _favorite = XHelper.GetChildValue(input, "Favorite", false); _etag = XHelper.GetChildValue(input, "ETag", ""); } }
public void Deserialize(object obj, XElement root, AXMLSerializationSettings opt) { var current = PropInfo.GetValue(obj); switch (_objectType) { case SettingObjectTypeEnum.Integer: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (int)current)); return; case SettingObjectTypeEnum.Double: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (double)current)); return; case SettingObjectTypeEnum.NullableInteger: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (int?)current)); return; case SettingObjectTypeEnum.Boolean: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (bool)current)); return; case SettingObjectTypeEnum.Guid: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (Guid)current)); return; case SettingObjectTypeEnum.NGuid: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (Guid?)current)); return; case SettingObjectTypeEnum.EncryptedString: PropInfo.SetValue(obj, AlephXMLSerializerHelper.Decrypt(XHelper.GetChildValue(root, PropInfo.Name, AlephXMLSerializerHelper.Encrypt((string)current, opt)), opt)); return; case SettingObjectTypeEnum.String: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (string)current)); return; case SettingObjectTypeEnum.Enum: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, current, PropInfo.PropertyType)); break; case SettingObjectTypeEnum.RemoteStorageAccount: var currUUID = ((RemoteStorageAccount)current).ID; PropInfo.SetValue(obj, new RemoteStorageAccount(XHelper.GetChildValue(root, PropInfo.Name, currUUID), null, null)); break; case SettingObjectTypeEnum.ListRemoteStorageAccount: var list = (IList <RemoteStorageAccount>)current; var child = XHelper.GetChildOrNull(root, PropInfo.Name); if (child != null) { list.Clear(); foreach (var elem in XHelper.GetChildOrThrow(root, PropInfo.Name).Elements()) { list.Add(DeserializeRemoteStorageAccount(elem, opt)); } } break; case SettingObjectTypeEnum.CustomSerializable: var currCust = ((IAlephCustomSerializableField)current); var cchild = XHelper.GetChildOrNull(root, PropInfo.Name); if (cchild != null) { PropInfo.SetValue(obj, currCust.DeserializeNew(cchild, opt)); } break; case SettingObjectTypeEnum.DirectoryPath: var dp = DirectoryPath.Deserialize(XHelper.GetChildrenOrEmpty(root, PropInfo.Name, "PathComponent")); PropInfo.SetValue(obj, dp); break; default: throw new ArgumentOutOfRangeException(nameof(obj), _objectType, null); } }