Inheritance: System.EventArgs
        public void RestoreBackup(IApiContext apiContext)
        {
            if (apiContext.Request.Type != JTokenType.Object)
            {
                throw new NotSupportedException();
            }

            var eventArgs = new BackupEventArgs(apiContext.Request);
            RestoringBackup?.Invoke(this, eventArgs);
        }
        public void CreateBackup(IApiContext apiContext)
        {
            var backup = new JObject
            {
                ["Type"] = "HA4IoT.Backup",
                ["Timestamp"] = DateTime.Now.ToString("O"),
                ["Version"] = 1
            };

            var eventArgs = new BackupEventArgs(backup);
            CreatingBackup?.Invoke(this, eventArgs);

            apiContext.Response = backup;
        }
        private void RestoreBackup(BackupEventArgs backupEventArgs)
        {
            if (backupEventArgs.Backup.Property(BackupKeyName) == null)
            {
                return;
            }

            var resources = backupEventArgs.Backup[BackupKeyName].Value<List<Resource>>();

            lock (_syncRoot)
            {
                _resources.Clear();
                _resources.AddRange(resources);
            }
        }
 private void CreateBackup(BackupEventArgs backupEventArgs)
 {
     lock (_syncRoot)
     {
         backupEventArgs.Backup[BackupKeyName] = JToken.FromObject(_resources);
     }
 }