diff options
author | Kirill Osenkov <github@osenkov.com> | 2018-12-06 02:56:21 +0300 |
---|---|---|
committer | Kirill Osenkov <github@osenkov.com> | 2018-12-06 02:56:21 +0300 |
commit | 8e7455fc88a1d7904ebd399c17c56a07e4cc796c (patch) | |
tree | 2da33b638e0435c3d5ddf996501e2cd461c210f8 /src/Text | |
parent | 30e88b1f2ce3ee9897e1f3b87c80c64292c27236 (diff) |
Update more files and bump version to 15.2.4-pre.
Diffstat (limited to 'src/Text')
5 files changed, 68 insertions, 33 deletions
diff --git a/src/Text/Impl/Commanding/EditorCommandHandlerService.cs b/src/Text/Impl/Commanding/EditorCommandHandlerService.cs index c9730e7..e057ea9 100644 --- a/src/Text/Impl/Commanding/EditorCommandHandlerService.cs +++ b/src/Text/Impl/Commanding/EditorCommandHandlerService.cs @@ -478,7 +478,7 @@ namespace Microsoft.VisualStudio.UI.Text.Commanding.Implementation public int CancelAfter => _state.IsExecutingTypingCommand ? - _textView.Options.GetOptionValue(DefaultOptions.MaximumTypingLatencyOptionId) : + _textView.Options.GetOptionValue<int>("MaximumTypingLatency") : Timeout.Infinite; public bool ShouldCancel() diff --git a/src/Text/Impl/EditorOperations/EditorOperations.cs b/src/Text/Impl/EditorOperations/EditorOperations.cs index 4672260..4cd00e0 100644 --- a/src/Text/Impl/EditorOperations/EditorOperations.cs +++ b/src/Text/Impl/EditorOperations/EditorOperations.cs @@ -25,6 +25,7 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Text.Outlining; using Microsoft.VisualStudio.Text.Tagging; + using Microsoft.VisualStudio.Text.Utilities; #if WINDOWS using Microsoft.VisualStudio.Language.Intellisense.Utilities; #endif diff --git a/src/Text/Util/TextUIUtil/BaseProxyService.cs b/src/Text/Util/TextUIUtil/BaseProxyService.cs new file mode 100644 index 0000000..0062990 --- /dev/null +++ b/src/Text/Util/TextUIUtil/BaseProxyService.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; + +namespace Microsoft.VisualStudio.Utilities +{ + /// <summary> + /// A proxy service for exposing best implementation to the MEF composition. + /// </summary> + internal abstract class BaseProxyService<T> where T : class + { + protected abstract IEnumerable<Lazy<T, IOrderable>> UnorderedImplementations { get; set; } + + private T bestImpl; + + protected virtual T BestImplementation + { + get + { + if (this.bestImpl == null) + { + var orderedImpls = Orderer.Order(UnorderedImplementations); + if (orderedImpls.Count == 0) + { + throw new ImportCardinalityMismatchException($"Expected to import at least one export of {typeof(T).FullName}, but got none."); + } + + this.bestImpl = orderedImpls[0].Value; + } + + return this.bestImpl; + } + } + } +}
\ No newline at end of file diff --git a/src/Text/Util/TextUIUtil/DefaultUIThreadOperationExecutor.cs b/src/Text/Util/TextUIUtil/DefaultUIThreadOperationExecutor.cs index e022a1c..c6c349d 100644 --- a/src/Text/Util/TextUIUtil/DefaultUIThreadOperationExecutor.cs +++ b/src/Text/Util/TextUIUtil/DefaultUIThreadOperationExecutor.cs @@ -7,14 +7,24 @@ namespace Microsoft.VisualStudio.UI.Text.Commanding.Implementation [Name("default")] internal class DefaultUIThreadOperationExecutor : IUIThreadOperationExecutor { - public IUIThreadOperationContext BeginExecute(string title, string description, bool allowCancel, bool showProgress) + public IUIThreadOperationContext BeginExecute(string title, string defaultDescription, bool allowCancellation, bool showProgress) { - return new DefaultUIThreadOperationContext(allowCancel, description); + return BeginExecute(new UIThreadOperationExecutionOptions(title, defaultDescription, allowCancellation, showProgress)); } - public UIThreadOperationStatus Execute(string title, string description, bool allowCancel, bool showProgress, Action<IUIThreadOperationContext> action) + public IUIThreadOperationContext BeginExecute(UIThreadOperationExecutionOptions executionOptions) { - var context = new DefaultUIThreadOperationContext(allowCancel, description); + return new DefaultUIThreadOperationContext(executionOptions.AllowCancellation, executionOptions.DefaultDescription); + } + + public UIThreadOperationStatus Execute(string title, string defaultDescription, bool allowCancellation, bool showProgress, Action<IUIThreadOperationContext> action) + { + return Execute(new UIThreadOperationExecutionOptions(title, defaultDescription, allowCancellation, showProgress), action); + } + + public UIThreadOperationStatus Execute(UIThreadOperationExecutionOptions executionOptions, Action<IUIThreadOperationContext> action) + { + var context = new DefaultUIThreadOperationContext(executionOptions.AllowCancellation, executionOptions.DefaultDescription); action(context); return UIThreadOperationStatus.Completed; } @@ -22,9 +32,9 @@ namespace Microsoft.VisualStudio.UI.Text.Commanding.Implementation internal class DefaultUIThreadOperationContext : AbstractUIThreadOperationContext { - public DefaultUIThreadOperationContext(bool allowCancellation, string description) - : base(allowCancellation, description) + public DefaultUIThreadOperationContext(bool allowCancellation, string defaultDescription) + : base(allowCancellation, defaultDescription) { } } -} +}
\ No newline at end of file diff --git a/src/Text/Util/TextUIUtil/UIThreadOperationExecutor.cs b/src/Text/Util/TextUIUtil/UIThreadOperationExecutor.cs index e1a92bf..592c814 100644 --- a/src/Text/Util/TextUIUtil/UIThreadOperationExecutor.cs +++ b/src/Text/Util/TextUIUtil/UIThreadOperationExecutor.cs @@ -3,43 +3,32 @@ using System.Collections.Generic; using System.ComponentModel.Composition; using Microsoft.VisualStudio.Utilities; -namespace Microsoft.VisualStudio.UI.Text.Commanding.Implementation +namespace Microsoft.VisualStudio.Text.Utilities { [Export(typeof(IUIThreadOperationExecutor))] - internal class UIThreadOperationExecutor : IUIThreadOperationExecutor + internal class UIThreadOperationExecutor : BaseProxyService<IUIThreadOperationExecutor>, IUIThreadOperationExecutor { [ImportImplementations(typeof(IUIThreadOperationExecutor))] - private IEnumerable<Lazy<IUIThreadOperationExecutor, IOrderable>> _unorderedImplementations; + protected override IEnumerable<Lazy<IUIThreadOperationExecutor, IOrderable>> UnorderedImplementations { get; set; } - private IUIThreadOperationExecutor _bestImpl; - - private IUIThreadOperationExecutor BestImplementation + public IUIThreadOperationContext BeginExecute(string title, string defaultDescription, bool allowCancellation, bool showProgress) { - get - { - if (_bestImpl == null) - { - var orderedImpls = Orderer.Order(_unorderedImplementations); - if (orderedImpls.Count == 0) - { - throw new ImportCardinalityMismatchException($"Expected to import at least one export of {typeof(IUIThreadOperationExecutor).FullName}, but got none."); - } - - _bestImpl = orderedImpls[0].Value; - } + return BestImplementation.BeginExecute(title, defaultDescription, allowCancellation, showProgress); + } - return _bestImpl; - } + public IUIThreadOperationContext BeginExecute(UIThreadOperationExecutionOptions executionOptions) + { + return BestImplementation.BeginExecute(executionOptions); } - public IUIThreadOperationContext BeginExecute(string title, string description, bool allowCancel, bool showProgress) + public UIThreadOperationStatus Execute(string title, string defaultDescription, bool allowCancellation, bool showProgress, Action<IUIThreadOperationContext> action) { - return BestImplementation.BeginExecute(title, description, allowCancel, showProgress); + return BestImplementation.Execute(title, defaultDescription, allowCancellation, showProgress, action); } - public UIThreadOperationStatus Execute(string title, string description, bool allowCancel, bool showProgress, Action<IUIThreadOperationContext> action) + public UIThreadOperationStatus Execute(UIThreadOperationExecutionOptions executionOptions, Action<IUIThreadOperationContext> action) { - return BestImplementation.Execute(title, description, allowCancel, showProgress, action); + return BestImplementation.Execute(executionOptions, action); } } -} +}
\ No newline at end of file |