This part 3 of my 6 part series on the EditingContext.
EditingContext is used by our primary hosting application, Visual Studio, to provide concrete implementations of certain services. The example that we will talk about here is the IExpressionEditorService. Now, one thing that we would have really liked to have done in vs2010 is to provide a way to use the intellisense enabled VB editor that you see within VS inside a rehosted app. For various reasons, we were not able to ship with that dependency in the .NET framework. However, we needed a mechanism for our primary host to have the intellisense experience (and similarly, you could build an experience, or maybe we’ll ship one in the future for rehosted apps).
Let’s look at the design of IExpressionEditorService:
Inside the ExpressionTextBox control, when the control needs to render the editor, it has code that looks like the following (note, if it can’t find an instance, it skips and just uses a plain old text box):
if (this.Context.Services.GetService<IExpressionEditorService>() != null)
Using the following overload of CreateExpressionEditor:
Now, what happens is that inside the code that we ship in the Microsoft.VisualStudio.Activities.Addin.dll, there is both a concrete implementation of this type, as well as the code which will publish an instance of this to the editing context. Remember, this is the same thing that you can do in your app for a these host provided services. In a subsequent post, I will get into more details of what are the ones that the designer has built in (like IExpressionEditorService).