internal override void UnloadDictionary(object token) { if (_isDisposed) { return; } var data = (Tuple <CultureInfo, String>)token; CultureInfo culture = data.Item1; string filePath = data.Item2; new FileIOPermission(FileIOPermissionAccess.AllAccess, filePath).Demand(); _customDictionaryFilesLock.WaitOne(); try { _customDictionaryFiles[culture].RemoveAll((str) => str == filePath); } finally { _customDictionaryFilesLock.Release(); } SpellCheckerFactory.UnregisterUserDictionary(filePath, culture.IetfLanguageTag); File.Delete(filePath); }
internal override void UnloadDictionary(object token) { if (_isDisposed) { return; } var data = (Tuple <string, string>)token; string ietfLanguageTag = data.Item1; string filePath = data.Item2; try { new FileIOPermission(FileIOPermissionAccess.AllAccess, filePath).Demand(); using (new SpellerCOMActionTraceLogger(this, SpellerCOMActionTraceLogger.Actions.UnregisterUserDictionary)) { SpellCheckerFactory.UnregisterUserDictionary(filePath, ietfLanguageTag); } FileHelper.DeleteTemporaryFile(filePath); } catch (SecurityException) { } }
internal override void UnloadDictionary(object token) { if (_isDisposed) { return; } var data = (Tuple <string, string>)token; string ietfLanguageTag = data.Item1; string filePath = data.Item2; new FileIOPermission(FileIOPermissionAccess.AllAccess, filePath).Demand(); _customDictionaryFilesLock.WaitOne(); try { _customDictionaryFiles[ietfLanguageTag].RemoveAll((str) => str == filePath); } finally { _customDictionaryFilesLock.Release(); } using (new SpellerCOMActionTraceLogger(this, SpellerCOMActionTraceLogger.Actions.UnregisterUserDictionary)) { SpellCheckerFactory.UnregisterUserDictionary(filePath, ietfLanguageTag); } File.Delete(filePath); }
private void ClearDictionaries(bool disposing = false) { if (this._isDisposed) { return; } if (this._customDictionaryFiles != null) { foreach (KeyValuePair <string, List <string> > keyValuePair in this._customDictionaryFiles) { string key = keyValuePair.Key; foreach (string text in keyValuePair.Value) { try { new FileIOPermission(FileIOPermissionAccess.AllAccess, text).Demand(); using (new SpellerCOMActionTraceLogger(this, SpellerCOMActionTraceLogger.Actions.UnregisterUserDictionary)) { SpellCheckerFactory.UnregisterUserDictionary(text, key, true); } FileHelper.DeleteTemporaryFile(text); } catch { } } } this._customDictionaryFiles.Clear(); } if (disposing) { this._customDictionaryFiles = null; } }
/// <summary> /// Unloads a given custom dictionary /// </summary> /// <param name="token"></param> internal override void UnloadDictionary(object token) { if (_isDisposed) return; var data = (Tuple<string, string>)token; string ietfLanguageTag = data.Item1; string filePath = data.Item2; using (new SpellerCOMActionTraceLogger(this, SpellerCOMActionTraceLogger.Actions.UnregisterUserDictionary)) { SpellCheckerFactory.UnregisterUserDictionary(filePath, ietfLanguageTag); } FileHelper.DeleteTemporaryFile(filePath); }
private void ClearDictionaries(bool isDisposeOrFinalize = false) { if (_isDisposed || (_customDictionaryFilesLock == null)) { // Locks are not initialized => Dispose called from within the constructor. // Likely this platform is not supported - do not process further. return; } _customDictionaryFilesLock.WaitOne(); try { if (_customDictionaryFiles != null) { foreach (KeyValuePair <CultureInfo, List <string> > items in _customDictionaryFiles) { CultureInfo culture = items.Key; foreach (string filePath in items.Value) { try { new FileIOPermission(FileIOPermissionAccess.AllAccess, filePath).Demand(); SpellCheckerFactory.UnregisterUserDictionary(filePath, culture.IetfLanguageTag); File.Delete(filePath); } catch { // Do nothing - Continue to make a best effort // attempt at unregistering custom dictionaries } } } _customDictionaryFiles.Clear(); } } finally { if (isDisposeOrFinalize) { _customDictionaryFiles = null; } _customDictionaryFilesLock.Release(); } }
private void ClearDictionaries(bool disposing = false) { if (_isDisposed) { // Likely this platform is not supported - do not process further. return; } if (_customDictionaryFiles != null) { foreach (KeyValuePair <string, List <string> > items in _customDictionaryFiles) { string ietfLanguageTag = items.Key; foreach (string filePath in items.Value) { try { new FileIOPermission(FileIOPermissionAccess.AllAccess, filePath).Demand(); using (new SpellerCOMActionTraceLogger(this, SpellerCOMActionTraceLogger.Actions.UnregisterUserDictionary)) { SpellCheckerFactory.UnregisterUserDictionary(filePath, ietfLanguageTag); } FileHelper.DeleteTemporaryFile(filePath); } catch { // Do nothing - Continue to make a best effort // attempt at unregistering custom dictionaries } } } _customDictionaryFiles.Clear(); } if (disposing) { _customDictionaryFiles = null; } }
internal override void UnloadDictionary(object token) { if (this._isDisposed) { return; } Tuple <string, string> tuple = (Tuple <string, string>)token; string item = tuple.Item1; string item2 = tuple.Item2; try { new FileIOPermission(FileIOPermissionAccess.AllAccess, item2).Demand(); using (new SpellerCOMActionTraceLogger(this, SpellerCOMActionTraceLogger.Actions.UnregisterUserDictionary)) { SpellCheckerFactory.UnregisterUserDictionary(item2, item, true); } FileHelper.DeleteTemporaryFile(item2); } catch (SecurityException) { } }
private void ClearDictionaries(bool isDisposeOrFinalize = false) { if (_isDisposed || (_customDictionaryFilesLock == null)) { // Locks are not initialized => Dispose called from within the constructor. // Likely this platform is not supported - do not process further. return; } try { _customDictionaryFilesLock.WaitOne(); if (_customDictionaryFiles != null) { foreach (KeyValuePair <string, List <string> > items in _customDictionaryFiles) { string ietfLanguageTag = items.Key; foreach (string filePath in items.Value) { try { new FileIOPermission(FileIOPermissionAccess.AllAccess, filePath).Demand(); using (new SpellerCOMActionTraceLogger(this, SpellerCOMActionTraceLogger.Actions.UnregisterUserDictionary)) { SpellCheckerFactory.UnregisterUserDictionary(filePath, ietfLanguageTag); } File.Delete(filePath); } catch { // Do nothing - Continue to make a best effort // attempt at unregistering custom dictionaries } } } _customDictionaryFiles.Clear(); } } catch (ObjectDisposedException) { // _customeDictionaryFilesLock might throw ObjectDisposedException // if it has been disposed before reaching ClearDictionaries. // We will simply handle the exception and abort gracefully. // // Setting _customDictionaryFilesLock to null here would // ensure that the call into Release() in the finally block would // not throw again. _customDictionaryFilesLock = null; } finally { if (isDisposeOrFinalize) { _customDictionaryFiles = null; } try { _customDictionaryFilesLock?.Release(); } catch (ObjectDisposedException) { // do nothing } finally { _customDictionaryFilesLock = null; } } }