/// <summary> /// Creates the node. /// </summary> /// <param name="parentNode">The parent node.</param> /// <param name="element">The element.</param> /// <returns></returns> internal static IExplorerNode CreateNode(IExplorerNode parentNode, FeatureElementInfo element) { Dictionary <object, object> annotations = new Dictionary <object, object>(); annotations.Add(typeof(FeatureElementInfo), element); return(parentNode.ChildNodes.Add(ExplorerNodeIds.FeatureElementNode, String.Format("{0} ({1})", element.Name, element.ElementType), annotations)); }
public static string GetElementDefinition(ISharePointCommandContext context, FeatureElementInfo elementInfo) { SPFeatureDefinition definition = SPFarm.Local.FeatureDefinitions[elementInfo.FeatureID]; SPElementDefinition element = definition.GetElementDefinitions(CultureInfo.CurrentCulture) .OfType <SPElementDefinition>() .Where(searchElement => searchElement.ElementType == elementInfo.ElementType) .Where(searchElement => GetNameFromNode(searchElement.XmlDefinition) == elementInfo.Name) .FirstOrDefault(); return(element.XmlDefinition.OuterXml); }
/// <summary> /// Handles the DoubleClick event of the ElementNode control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Microsoft.VisualStudio.SharePoint.Explorer.ExplorerNodeEventArgs"/> instance containing the event data.</param> static void ElementNode_DoubleClick(object sender, ExplorerNodeEventArgs e) { FeatureElementInfo elementInfo = e.Node.Annotations.GetValue <FeatureElementInfo>(); XDocument document = XDocument.Parse(e.Node.Context.SharePointConnection.ExecuteCommand <FeatureElementInfo, string>(FeatureSharePointCommandIds.GetElementDefinition, elementInfo)); XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; settings.NewLineOnAttributes = true; settings.Indent = true; StringBuilder text = new StringBuilder(); using (StringWriter stringWriter = new StringWriter(text)) using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, settings)) { document.WriteTo(xmlWriter); } e.Node.Context.ShowMessageBox(text.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information); }