1 / 18

Разработка расширений для Visual Studio 2010

Максим Павловский twitter : @ paulousky http://www.maxpaulousky.com. Разработка расширений для Visual Studio 2010. Необходимые инструменты. Visual Studio 2010 Professional или лучше Visual Studio 2010 SDK. Создание , отладка и публикация расширений. Разработка в Visual Studio 2010 ;

hammer
Download Presentation

Разработка расширений для Visual Studio 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Максим Павловский twitter: @paulousky http://www.maxpaulousky.com Разработка расширений для Visual Studio 2010

  2. Необходимые инструменты • Visual Studio 2010 Professional или лучше • Visual Studio 2010 SDK

  3. Создание, отладка и публикация расширений • Разработка в Visual Studio 2010; • Из чего состоит проект расширения Visual Studio Package; • Запуск и отладка в Visual Studio 2010experimental instance; • Публикация в Visual Studio Gallery.

  4. Visual Studio Gallery

  5. Создание расширения для Visual Studio Демонстрация

  6. Основа расширения • Реализация Microsoft.VisualStudio.Shell.Package; • Использование IServiceProvider для доступа к различным составляющим Visual Studio

  7. Сервисы Visual Studio • IVsSolution; • IVsStatusbar • IVsOutputWindowPane; • IVsWebBrowsingService; • IVsToolWindowToolbarHost; • etc.

  8. Примеры использования сервисов • private IEnumerable<IVsHierarchy> GetProjects(__VSENUMPROJFLAGS flags, GuidprojectGuid){IEnumHierarchiesenumHier;solution.GetProjectEnum((uint)flags, ref projectGuid, out enumHier);uint fetched = 1;IVsHierarchy[] hier = new IVsHierarchy[10];while (fetched > 0){ErrorHandler.ThrowOnFailure( enumHier.Next(10, hier, out fetched));for (int n = 0; n < fetched; ++n)yield return hier[n];}yield break;}

  9. Примеры использования сервисов • Bitmap bitmap = … • IntPtrbitmapHdc =  bitmap.GetHbitmap(); • Object bitmapObjHdc = (Object)bitmapHdc; • //Start animation • intisTurnedOn = 1 • statusbar.Animation(isTurnedOn, ref bitmapObjHdc); • //Set progress text and progress bar value • intInProgress = 1; • intcurrentValue = 50; • int Total = 100; • string message = “Processing”;statusbar.Progress(ref statusBarId, InProgress, message, currentValue, total));

  10. Примеры использования сервисов • IVsOutputWindow output = provider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; • //Guid of your outputwindowGuidoutputPaneGuid = new Guid(…);output.CreatePane(ref outputPaneGuid, “Test", 1, 1); • IVsOutputWindowPane pane;output.GetPane(ref outputPaneGuid, out pane);pane.Activate(); • pane.OutputString(“Output message”);

  11. Обработка проектов • Получение типа (asp.net, библиотека, windows service etc), языка (c#, VB) проекта; • Получениесвойств проекта; • Получение элементов проекта (файлы, папки, классы, простанства имён и т.д.); • Обработка reference assemblies проекта.

  12. Получение типа и языка проекта • private IEnumerable<string> GetProjectTypeGuids(Project project){string projectTypeGuids = string.Empty;IVsHierarchy hierarchy = GetVsHierarchy(project);if (hierarchy as IVsAggregatableProject != null)(hierarchy as IVsAggregatableProject).GetAggregateProjectTypeGuids(out projectTypeGuids);if (string.IsNullOrWhiteSpace(projectTypeGuids))return Enumerable.Empty<string>();return projectTypeGuids.Split(';').ToList();}

  13. Поиск всех классов проекта • ProjectItems items = project.ProjectItems;foreach (ProjectItem item in items){if (item.FileCodeModel == null)continue;foreach (CodeElement element in item.FileCodeModel.CodeElements){if (element.Kind == vsCMElement.vsCMElementNamespace){foreach (CodeElementelemenentNin  (element asCodeNamespace).Members){if (elemenentN.Kind ==  • vsCMElement.vsCMElementClass)return true; } } }}

  14. Изменение reference assemblies проекта • project.References.Add(<path_to_assembly>); • project.References.AddProject(projectReference.SourceProject);

  15. Алгоритм минимизации XAP файлов

  16. XapsMinifier. Уменьшение размера Silverilightприложений Демонстрация

  17. Полезные ссылки • XapsMinifierhttp://bit.ly/XapsMin; • Visual Studio Gallery; http://visualstudiogallery.msdn.microsoft.com/ • Visual Studio SDK Reference http://msdn.microsoft.com/en-us/library/bb166217.aspx • VS extensibility resources http://www.mztools.com/resources_vsnet_addins.aspx

  18. Спасибо! Ваши отзывы будут очень полезны

More Related