Browse Source

IDocument now derives from IServiceProvider.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
26e7380e5b
  1. 52
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs
  2. 13
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  3. 2
      src/Libraries/NRefactory/ICSharpCode.Editor/IDocument.cs
  4. 3
      src/Libraries/NRefactory/ICSharpCode.Editor/ReadOnlyDocument.cs

52
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs

@ -5,10 +5,10 @@ using System; @@ -5,10 +5,10 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Globalization;
using System.Threading;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
@ -440,6 +440,21 @@ namespace ICSharpCode.AvalonEdit.Document @@ -440,6 +440,21 @@ namespace ICSharpCode.AvalonEdit.Document
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler UpdateFinished;
void IDocument.StartUndoableAction()
{
BeginUpdate();
}
void IDocument.EndUndoableAction()
{
EndUpdate();
}
IDisposable IDocument.OpenUndoGroup()
{
return RunUpdate();
}
#endregion
#region Fire events after update
@ -897,19 +912,36 @@ namespace ICSharpCode.AvalonEdit.Document @@ -897,19 +912,36 @@ namespace ICSharpCode.AvalonEdit.Document
throw new NotImplementedException();
}
void IDocument.StartUndoableAction()
{
throw new NotImplementedException();
}
#region Service Provider
IServiceProvider serviceProvider;
void IDocument.EndUndoableAction()
{
throw new NotImplementedException();
/// <summary>
/// Gets/Sets the service provider associated with this document.
/// By default, every TextDocument has its own ServiceContainer; and has the document itself
/// registered as <see cref="IDocument"/> and <see cref="TextDocument"/>.
/// </summary>
public IServiceProvider ServiceProvider {
get {
VerifyAccess();
if (serviceProvider == null) {
var container = new ServiceContainer();
container.AddService(typeof(IDocument), this);
container.AddService(typeof(TextDocument), this);
}
return serviceProvider;
}
set {
VerifyAccess();
if (value == null)
throw new ArgumentNullException();
serviceProvider = value;
}
}
IDisposable IDocument.OpenUndoGroup()
object IServiceProvider.GetService(Type serviceType)
{
throw new NotImplementedException();
return this.ServiceProvider.GetService(serviceType);
}
#endregion
}
}

13
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -1638,9 +1638,18 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -1638,9 +1638,18 @@ namespace ICSharpCode.AvalonEdit.Rendering
get { return services; }
}
object IServiceProvider.GetService(Type serviceType)
/// <summary>
/// Retrieves a service from the text view.
/// If the service is not found in the <see cref="Services"/> container,
/// this method will also look for it in the current document's service provider.
/// </summary>
public object GetService(Type serviceType)
{
return services.GetService(serviceType);
object instance = services.GetService(serviceType);
if (instance == null && document != null) {
instance = document.ServiceProvider.GetService(serviceType);
}
return instance;
}
void ConnectToTextView(object obj)

2
src/Libraries/NRefactory/ICSharpCode.Editor/IDocument.cs

@ -10,7 +10,7 @@ namespace ICSharpCode.Editor @@ -10,7 +10,7 @@ namespace ICSharpCode.Editor
/// Line and column counting starts at 1.
/// Offset counting starts at 0.
/// </summary>
public interface IDocument : ITextSource
public interface IDocument : ITextSource, IServiceProvider
{
/// <summary>
/// Gets/Sets the text of the whole document..

3
src/Libraries/NRefactory/ICSharpCode.Editor/ReadOnlyDocument.cs

@ -312,8 +312,7 @@ namespace ICSharpCode.Editor @@ -312,8 +312,7 @@ namespace ICSharpCode.Editor
return textSource.IndexOfAny(anyOf, startIndex, count);
}
/// <inheritdoc/>
public object GetService(Type serviceType)
object IServiceProvider.GetService(Type serviceType)
{
return null;
}

Loading…
Cancel
Save