Visual Studio MEF sử dụng một cách gần giống như các ví dụ trước khi nó tải các phần mở rộng Visual Studio. Khi Visual Studio tải đầu tiên, nó xem xét các thư mục mở rộng và tải sẵn phần mở rộng. Bây giờ chúng ta hãy nhìn vào cách các phần mở rộng được tạo ra. | CHAPTER 2 VISUAL STUDIO IDE AND MEF foreach var Part in secure Note that querying a method s metadata is slightly different and that you must instead use the property. What s This All Got to Do with Visual Studio Extensibility Visual Studio utilizes MEF in an almost identical way to the previous examples when it loads Visual Studio extensions. When Visual Studio first loads it examines the extensions directory and loads available extensions. Let s now look into how these extensions are created. Visual Studio Extensibility After you install the Visual Studio customization SDK a number of new extensibility projects are available for you to create. These projects are templates that demonstrate how to perform various hello world type customizations that you can then build on. Figure 2-15 shows these new project types. Figure 2-15. New extensibility projects are available after installing customization SDK. 33 CHAPTER 2 VISUAL STUDIO IDE AND MEF The following extensibility projects are available VSIX Project empty extension that contains just the minimum references needed and a manifest file that describes the extension Editor Margin creates a green box down the bottom of code editor frame Editor Classifier formats types of text a blue color Editor Text Adornment template highlights all instances of the letter a Editor Viewport Adornment template creates a purple box in the top right corner of IDE and a Windows Forms toolbox control Let s take a look at the Editor Margin extensibility project. Editor Margin Open up Visual Studio and create a new Editor Margin project called . 1. Open and note how it utilizes the MEF Export attribute the other attributes contain various bits of metadata utilized by the IDE Export typeof IWpfTextViewMarginProvider Name GreenBar Ensure that the margin occurs below the horizontal scrollbar Order After .