In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to expand VS2010 Server Resource Manager", the explanation content in the article is simple and clear, easy to learn and understand, please follow the idea of Xiaobian slowly in-depth, together to study and learn "how to expand VS2010 Server Resource Manager"!
SharePoint Server Explorer is a new feature of Visual Studio 2010 that is provided by Visual Studio Tools for SharePoint.
If you only need to browse SharePoint site content (site columns, content types, features, etc.) from Visual Studio, then the default features are great for you. By default, however, SharePoint Server Explorer can do little more than show what is available in a Web site.
As you can see, there are very few items in the context menu. Below is the notification list properties panel. This property is stored in Annotations. To understand what annotations are, you can think of them as a class with attributes. These properties are what we see in the properties panel below:
This is read-only.
Can I expand?
The next question you must ask (if you're a SharePoint developer) is--can I extend this to add custom commands or nodes to SharePoint Server Explorer?
The answer is yes. You can extend SharePoint Server Explorer to include:
1) Create a new node
2) Expand existing nodes
Can you give me an example?
Let's take a functional node as an example.
The function node displays all the activated functions of the website. If you right-click on a feature, you'll see a few items.
It would be cool if you could add "disable" to the context menu and click to disable the selected function:)
[By the way, this screenshot is a real extension, not Photoshop:)]
Understanding SharePoint Server Explorer
Before you start writing an extension in earnest, you must understand the different types of nodes in SharePoint Server Resource Rollers:
In this case, we are interested in Feature Node.
began
MSDN has a great article on how to extend Visual Studio Tools for SharePoint
Here is a graphical representation of what we will be doing:
1. Create a new class and implement the IExplorerNodeTypeExtension interface
2. Handling events
3. Access the attributes of the node through Annotations
4. SharePoint operations performed through the client object model
*** STEP
Create a Windows class library project and add the following references
the second step
Create a class and implement the interface IExplorerNodeTypeExtension:
the third step
What we're interested in is adding an item to the context menu that handles the event NodeMenuItemsRequested. This is done in the Initialize method:
public void Initialize(IExplorerNodeType nodeType) { nodeType.NodeMenuItemsRequested += new EventHandler (nodeType_NodeMenuItemsRequested); }
Add an event handler below:
void nodeType_NodeMenuItemsRequested(object sender, ExplorerNodeMenuItemsRequestedEventArgs e) { IMenuItem deactivating Menu = e.MenuItems.Add("deactivate"); deactivating Menu.Click += new EventHandler(deactivateMenu_Click); }
We added a menu item to the event handler and handled its own click event.
the fourth step
To disable a feature, we first need to know the Definition Id of the feature. This value already exists in the Properties panel of the function:
In order to access this property, we need the Annotations object. Here is the code to access the functional properties:
IFeatureNodeInfo fn = e.Node.Annotations[typeof(IFeatureNodeInfo)] as IFeatureNodeInfo; definitionId = fn.Id; featureName = fn.Name;
Next we need to get the website where the feature is located. Because Server Explorer has already instantiated the connection to this site, we can get it directly from the current context.
IExplorerNodeContext siteContext = e.Node.Context;
Here's what the event handler code looks like now:
void nodeType_NodeMenuItemsRequested(object sender, ExplorerNodeMenuItemsRequestedEventArgs e) { siteContext = e.Node.Context; IFeatureNodeInfo fn = e.Node.Annotations[typeof(IFeatureNodeInfo)] as IFeatureNodeInfo; definitionId = fn.Id; featureName = fn.Name; IMenuItem deactivating Menu = e.MenuItems.Add("Deactivate"); deactivating Menu.Click += new EventHandler(deactivating Menu_Click); }
the fifth step
We can now write deactivation code in the event handler for the new menu item via the client object model:
void deactivate Menu_Click(object sender, MenuItemEventArgs e) { if (MessageBox.Show(confirmationMessage,String.Format("deactivate {0} feature",featureName), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { IExplorerNode parentFeatureNode = e.Owner as IExplorerNode; IExplorerNode featureNode = parentFeatureNode.ParentNode; ClientContext clientContext = new ClientContext(siteContext.SiteUrl.AbsoluteUri); Web site = clientContext.Web; FeatureCollection siteFeatures = site.Features; clientContext.Load(site, s => s.Title, s => s.Features); siteFeatures.Remove(definitionId, false); clientContext.ExecuteQuery(); clientContext.Dispose(); featureNode.Refresh(); } }
It's really simple. Query and return only Web and Features objects, and then Remove the feature from the site.
You can also implement asynchronous invocations through the asynchronous mode of the client object model.
Deploy the extension
To be able to deploy this extension, we need to include it in a.vsix package.
You can apply the VSIX template to create.vsix packages.
Include the extension in the manifest file.
Select Content as MEF Component and Extension Project as Source.
Compile the project and generate the appropriate.vsix package, then install it.
The "deactivation extension" developed for Feature Node is complete
Now look at the context menu, our menu items have appeared:
When you click on it, a confirmation message pops up:
Clicking Yes will deactivate the feature and refresh the feature node tree view.
Thank you for reading, the above is "how to extend the VS2010 Server Resource Manager" content, after learning this article, I believe we have a deeper understanding of how to extend the VS2010 Server Resource Manager this issue, the specific use of the situation also needs to be verified. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.