public SynchronizationModule(IFilesProvider filesProvider, IDocumentApiProvider documentApiProvider, IClientAuthorizationProvider authorizationProvider) { this.filesProvider = filesProvider; this.documentApiProvider = documentApiProvider; this.authorizationProvider = authorizationProvider; authorizationProvider.LoggedIn += AuthorizationProvider_LoggedIn; authorizationProvider.LoggedOut += AuthorizationProvider_LoggedOut; filesProvider.FileAdded += FilesProvider_FileAdded; filesProvider.FileRemoved += FilesProvider_FileRemoved; this.metadata = filesProvider.Metadata; }
private void InitializeMetaData() { bool loaded = false; if (File.Exists(this.metadataPath)) { using (FileStream fs = new FileStream(this.metadataPath, FileMode.Open)) { try { this.metadata = (Metadata)this.binaryFormatter.Deserialize(fs); loaded = true; } catch (SerializationException) { loaded = false; } } } if (!loaded) { this.metadata = new Metadata(); } }
private void AuthorizationProvider_LoggedIn() { lock (this.metadata) { if (this.metadata.Username == null) { this.metadata.Username = this.authorizationProvider.Username; } else if (this.authorizationProvider.Username != this.metadata.Username) { this.metadata = this.filesProvider.CleanLocalData(); this.metadata.Username = this.authorizationProvider.Username; } } this.StartSynchronization(); }