Пример #1
0
        public virtual void BuildCommandSet() {
            // It is allowed here not to have host. The reason is that we allow using controller classes
            // without host as long as derived controller is adding commands manually. Without host there is
            // no composition service and hence we are unable to import command factories.
            if (EditorShell.Current.CompositionService != null) {
                var importComposer = new ContentTypeImportComposer<ICommandFactory>(EditorShell.Current.CompositionService);
                var commandFactories = importComposer.GetAll(TextBuffer.ContentType.TypeName);

                foreach (var factory in commandFactories) {
                    var commands = factory.GetCommands(TextView, TextBuffer);
                    AddCommandSet(commands);
                }
            }
        }
Пример #2
0
        public virtual void BuildCommandSet()
        {
            // It is allowed here not to have host. The reason is that we allow using controller classes
            // without host as long as derived controller is adding commands manually. Without host there is
            // no composition service and hence we are unable to import command factories.
            if (_shell.CompositionService != null)
            {
                var importComposer   = new ContentTypeImportComposer <ICommandFactory>(_shell.CompositionService);
                var commandFactories = importComposer.GetAll(TextBuffer.ContentType.TypeName);

                foreach (var factory in commandFactories)
                {
                    var commands = factory.GetCommands(TextView, TextBuffer);
                    AddCommandSet(commands);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Retrieves all services of a particular type available for the content type.
        /// </summary>
        /// <typeparam name="T">Service type</typeparam>
        /// <param name="contentType">Content (file) type such as 'R' or 'Markdown'</param>
        /// <returns>Collection of service instances, if any</returns>
        public IEnumerable <T> GetAllServices <T>(string contentType) where T : class
        {
            var importComposer = new ContentTypeImportComposer <T>(_compositionService);

            return(importComposer.GetAll(contentType));
        }