public IEnumerable <T> GetContents <T> () where T : class { //check whether the ViewContent can return the type directly T ret = (T)Window.ActiveViewContent.GetContent(typeof(T)); if (ret != null) { yield return(ret); } //check the primary viewcontent //not sure if this is the right thing to do, but things depend on this behaviour if (Window.ViewContent != Window.ActiveViewContent) { ret = (T)Window.ViewContent.GetContent(typeof(T)); if (ret != null) { yield return(ret); } } //no, so look through the TexteditorExtensions as well TextEditorExtension nextExtension = editorExtension; while (nextExtension != null) { if (typeof(T).IsAssignableFrom(nextExtension.GetType())) { yield return(nextExtension as T); } nextExtension = nextExtension.Next as TextEditorExtension; } }
public object GetContent(Type type) { //check whether the ViewContent can return the type directly object ret = Window.ActiveViewContent.GetContent(type); if (ret != null) { return(ret); } //check the primary viewcontent //not sure if this is the right thing to do, but things depend on this behaviour if (Window.ViewContent != Window.ActiveViewContent) { ret = Window.ViewContent.GetContent(type); if (ret != null) { return(ret); } } //no, so look through the TexteditorExtensions as well TextEditorExtension nextExtension = editorExtension; while (nextExtension != null) { if (type.IsAssignableFrom(nextExtension.GetType())) { return(nextExtension); } nextExtension = nextExtension.Next as TextEditorExtension; } return(null); }