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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor; using ICSharpCode.Editor;
@ -440,6 +440,21 @@ namespace ICSharpCode.AvalonEdit.Document
/// </summary> /// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks> /// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler UpdateFinished; public event EventHandler UpdateFinished;
void IDocument.StartUndoableAction()
{
BeginUpdate();
}
void IDocument.EndUndoableAction()
{
EndUpdate();
}
IDisposable IDocument.OpenUndoGroup()
{
return RunUpdate();
}
#endregion #endregion
#region Fire events after update #region Fire events after update
@ -897,19 +912,36 @@ namespace ICSharpCode.AvalonEdit.Document
throw new NotImplementedException(); throw new NotImplementedException();
} }
void IDocument.StartUndoableAction() #region Service Provider
{ IServiceProvider serviceProvider;
throw new NotImplementedException();
}
void IDocument.EndUndoableAction() /// <summary>
{ /// Gets/Sets the service provider associated with this document.
throw new NotImplementedException(); /// 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
get { return services; } 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) void ConnectToTextView(object obj)

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

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

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

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

Loading…
Cancel
Save