/// <summary> /// Destroys object /// </summary> /// <param name="disposing">Flag, allowing destruction of /// managed objects contained in fields of class</param> private void Dispose(bool disposing) { if (!_disposed) { _disposed = true; _lastException = null; if (_siteItems != null) { _siteItems.Clear(); _siteItems = null; } if (_dispatch != null) { ComHelpers.ReleaseComObject(ref _dispatch, !disposing); _dispatch = null; } if (_activeScriptParse != null) { _activeScriptParse.Dispose(); _activeScriptParse = null; } _activeScript = null; } }
/// <summary> /// Determines each column's width. /// </summary> /// <param name="range">Range with columns to examine.</param> /// <returns>An array of integers representing column widths. /// Caveat: This array is 1-based!</returns> private int[] ColumnWidths(Range range) { Range columns = range.Columns; long numColumns = columns.Count; int[] widths = new int[numColumns + 1]; Logger.Info("ColumnWidths: Computing widths of {0} columns", numColumns); for (long i = 1; i <= numColumns; i++) { Range column = columns[i]; Range cells = column.Cells; for (int j = 1; j <= cells.Count; j++) { Range cell = cells[j]; int w = ValueToString(cell.Value2).Length; if (w > widths[i]) { widths[i] = w; } ComHelpers.ReleaseComObject(cell); if (IsCancellationRequested) { break; } } ComHelpers.ReleaseComObject(cells); ComHelpers.ReleaseComObject(column); if (IsCancellationRequested) { break; } } ComHelpers.ReleaseComObject(columns); return(widths); }
/// <summary> /// Destroys object /// </summary> /// <param name="disposing">Flag, allowing destruction of /// managed objects contained in fields of class</param> private void Dispose(bool disposing) { if (_disposedFlag.Set()) { _dispatcher.Invoke(() => { if (_dispatch != null) { ComHelpers.ReleaseComObject(ref _dispatch, !disposing); _dispatch = null; } if (_activeScriptWrapper != null) { _activeScriptWrapper.Dispose(); _activeScriptWrapper = null; } }); if (disposing) { if (_debuggingStarted && _debugDocuments != null) { foreach (UIntPtr debugDocumentKey in _debugDocuments.Keys) { var debugDocumentValue = _debugDocuments[debugDocumentKey]; debugDocumentValue.Close(); } _debugDocuments.Clear(); } if (_processDebugManagerWrapper != null) { _processDebugManagerWrapper.RemoveApplication(_debugApplicationCookie); _debugApplicationWrapper.Close(); } if (_hostItems != null) { _hostItems.Clear(); } _lastException = null; } } }
/// <summary> /// Destroys object /// </summary> /// <param name="disposing">Flag, allowing destruction of /// managed objects contained in fields of class</param> private void Dispose(bool disposing) { if (_disposedFlag.Set()) { _dispatcher.Invoke(() => { if (_dispatch != null) { ComHelpers.ReleaseComObject(ref _dispatch, !disposing); _dispatch = null; } _activeScriptGarbageCollector = null; ComHelpers.ReleaseAndEmpty(ref _pActiveScriptGarbageCollector); if (_activeScriptParse != null) { _activeScriptParse.Dispose(); _activeScriptParse = null; } if (_activeScript != null) { _activeScript.Close(); Marshal.FinalReleaseComObject(_activeScript); _activeScript = null; } ComHelpers.ReleaseAndEmpty(ref _pActiveScript); }); if (disposing) { if (_hostItems != null) { _hostItems.Clear(); } _lastException = null; } } }