/// <summary> /// This routine handles the Save button on the Examples page /// It adds the new record to the tree. /// If this is already in the tree it updates it with the latest /// info in the page. /// </summary> /// <param name="sender"> </param> /// <param name="args"> </param> public void AddExample_Click( object sender, RoutedEventArgs args ) { var SelectedNode = (TreeViewItem) NavigationControl1.CmdletTreeView.SelectedItem; if ( SelectedNode != null ) { int count = SelectedNode.Items.Count; if ( MainWindow.ExamplesControl1.ExampleNameTextBox.Text == "" ) { MainWindow.ExamplesControl1.ExampleNameTextBox.Text = "Example " + ( count + 1 ).ToString(); } if ( MainWindow.ExamplesControl1.ExampleID.Text == "" ) //This is a new example { //Add new exampe info. var ParentNode = new TreeViewItem(); if ( (String) SelectedNode.Header == "Examples" ) { ParentNode = (TreeViewItem) SelectedNode.Parent; } else { ParentNode = (TreeViewItem) SelectedNode.Parent; ParentNode = (TreeViewItem) ParentNode.Parent; } var Cmdletdesc = (cmdletDescription) ParentNode.DataContext; var examDetails = new example(); examDetails.ExampleCmd = MainWindow.ExamplesControl1.ExampleCommandTextBox.Text; examDetails.ExampleDescription = MainWindow.ExamplesControl1.ExampleDescriptionTextBox.Text; examDetails.ExampleName = MainWindow.ExamplesControl1.ExampleNameTextBox.Text; examDetails.ExampleOutput = MainWindow.ExamplesControl1.ExampleOutputTextBox.Text; examDetails.ExampleID = count; var NewExampleNode = new TreeViewItem(); NewExampleNode.DataContext = examDetails; NewExampleNode.Header = examDetails.ExampleName; if ( Cmdletdesc.Examples == null ) { var Examples = new Collection<example>(); Examples.Add( examDetails ); Cmdletdesc.Examples = Examples; SelectedNode.DataContext = Examples; } else { Cmdletdesc.Examples.Add( examDetails ); } MainWindow.ResetExamplesPage(); if ( (String) SelectedNode.Header == "Examples" ) { if ( sender != null ) { SelectedNode.Items.Add( NewExampleNode ); SelectedNode.IsExpanded = true; //int count = SelectedNode.Items.Count; var ChildNode = (TreeViewItem) SelectedNode.Items[count]; ChildNode.IsSelected = true; } else { SelectedNode.Items.Add( NewExampleNode ); SelectedNode.IsExpanded = true; } } } else //this is an existing example { //Update Example info. if ( SelectedNode.Header.ToString() == "Examples" ) { var examDetails = (Collection<example>) SelectedNode.DataContext; var examDetail = new example(); examDetail.ExampleCmd = MainWindow.ExamplesControl1.ExampleCommandTextBox.Text; examDetail.ExampleDescription = MainWindow.ExamplesControl1.ExampleDescriptionTextBox.Text; examDetail.ExampleName = MainWindow.ExamplesControl1.ExampleNameTextBox.Text; examDetail.ExampleOutput = MainWindow.ExamplesControl1.ExampleOutputTextBox.Text; examDetails.Add( examDetail ); //SelectedNode.Header = this.ExampleNameTextBox.Text; } else { var examDetails = (example) SelectedNode.DataContext; examDetails.ExampleCmd = MainWindow.ExamplesControl1.ExampleCommandTextBox.Text; examDetails.ExampleDescription = MainWindow.ExamplesControl1.ExampleDescriptionTextBox.Text; examDetails.ExampleName = MainWindow.ExamplesControl1.ExampleNameTextBox.Text; examDetails.ExampleOutput = MainWindow.ExamplesControl1.ExampleOutputTextBox.Text; SelectedNode.Header = MainWindow.ExamplesControl1.ExampleNameTextBox.Text; } } } }
/// <summary> /// This is the OnPaste routine. If the action is paste, /// it calls the correct paste function above. /// </summary> /// <param name="sender"> </param> /// <param name="e"> </param> public void OnPaste( object sender, RoutedEventArgs e ) { var SelectedItem = (TreeViewItem) NavigationControl1.CmdletTreeView.SelectedItem; switch ( MainWindow.ClipBoardRecord.TypeName ) { case "cmdlet description info": if ( SelectedItem.DataContext is cmdletDescription ) { var copiedinfo = (cmdletDescription) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedCmdlet = (cmdletDescription) SelectedItem.DataContext; selectedCmdlet.ShortDescription = copiedinfo.ShortDescription; selectedCmdlet.LongDescription = copiedinfo.LongDescription; selectedCmdlet.InputType = copiedinfo.InputType; selectedCmdlet.InputDesc = copiedinfo.InputDesc; selectedCmdlet.OutputType = copiedinfo.OutputType; selectedCmdlet.OutputDesc = copiedinfo.OutputDesc; selectedCmdlet.Note = copiedinfo.Note; SelectedItem.DataContext = selectedCmdlet; doDefaultTreeViewSelectionChange(); } else { MessageBox.Show( "You have placed " + MainWindow.ClipBoardRecord.TypeName + " type on the tools clip board.\nMake sure to paste it on a matching node type.", "Error pasting copied record", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } break; case "parameters description info": if ( SelectedItem.DataContext is Collection<parameterDecription> ) { var copiedParameters = (Collection<parameterDecription>) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedParameters = (Collection<parameterDecription>) SelectedItem.DataContext; foreach ( parameterDecription param in selectedParameters ) { foreach ( parameterDecription copiedparam in copiedParameters ) { if ( param.Name == copiedparam.Name ) { copyParameterInfo( param, copiedparam ); break; } } } SelectedItem.DataContext = selectedParameters; doDefaultTreeViewSelectionChange(); } else { MessageBox.Show( "You have placed " + MainWindow.ClipBoardRecord.TypeName + " type on the tools clip board.\nMake sure to paste it on a matching node type.", "Error pasting copied record", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } break; case "parameter decription info": if ( SelectedItem.DataContext is parameterDecription ) { var copiedParameter = (parameterDecription) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedPrameter = (parameterDecription) SelectedItem.DataContext; copyParameterInfo( selectedPrameter, copiedParameter ); SelectedItem.DataContext = selectedPrameter; doDefaultTreeViewSelectionChange(); } else { MessageBox.Show( "You have placed " + MainWindow.ClipBoardRecord.TypeName + " type on the tools clip board.\nMake sure to paste it on a matching node type.", "Error pasting copied record", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } break; case "example info": if ( SelectedItem.DataContext is Collection<example> || SelectedItem.DataContext is example ) { if ( SelectedItem.DataContext is Collection<example> ) { var copiedExample = (example) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedExamples = (Collection<example>) SelectedItem.DataContext; var newExample = new example(); copyExample( newExample, copiedExample, selectedExamples.Count ); selectedExamples.Add( newExample ); SelectedItem.DataContext = selectedExamples; } else { var parentNode = (TreeViewItem) SelectedItem.Parent; var ParentExamples = (Collection<example>) parentNode.DataContext; var copiedExample = (example) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedExample = (example) SelectedItem.DataContext; copyExample( selectedExample, copiedExample, ParentExamples.Count ); SelectedItem.DataContext = selectedExample; } doDefaultTreeViewSelectionChange(); } else { MessageBox.Show( "You have placed " + MainWindow.ClipBoardRecord.TypeName + " type on the tools clip board.\nMake sure to paste it on a matching node type.", "Error pasting copied record", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } break; case "examples description info": if ( SelectedItem.DataContext is Collection<example> ) { var copiedExamples = (Collection<example>) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedExamples = (Collection<example>) SelectedItem.DataContext; foreach ( example copiedExample in copiedExamples ) { var newExample = new example(); copyExample( newExample, copiedExample, selectedExamples.Count ); selectedExamples.Add( newExample ); } SelectedItem.DataContext = selectedExamples; doDefaultTreeViewSelectionChange(); } else { MessageBox.Show( "You have placed " + MainWindow.ClipBoardRecord.TypeName + " type on the tools clip board.\nMake sure to paste it on a matching node type.", "Error pasting copied record", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } break; case "related link info": if ( SelectedItem.DataContext is relatedlink || SelectedItem.DataContext is Collection<relatedlink> ) { if ( SelectedItem.DataContext is Collection<relatedlink> ) { var copiedLink = (relatedlink) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedLinks = (Collection<relatedlink>) SelectedItem.DataContext; var newrelatedlink = new relatedlink(); copyLink( newrelatedlink, copiedLink, selectedLinks.Count ); selectedLinks.Add( newrelatedlink ); SelectedItem.DataContext = selectedLinks; } else { var parentNode = (TreeViewItem) SelectedItem.Parent; var ParentLinks = (Collection<relatedlink>) parentNode.DataContext; var copiedLink = (relatedlink) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedLink = (relatedlink) SelectedItem.DataContext; copyLink( selectedLink, copiedLink, ParentLinks.Count ); SelectedItem.DataContext = selectedLink; } doDefaultTreeViewSelectionChange(); } else { MessageBox.Show( "You have placed " + MainWindow.ClipBoardRecord.TypeName + " type on the tools clip board.\nMake sure to paste it on a matching node type.", "Error pasting copied record", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } break; case "related links info": if ( SelectedItem.DataContext is Collection<relatedlink> ) { var copiedLinks = (Collection<relatedlink>) MainWindow.ClipBoardRecord.ClipBoardItem; var selectedLinks = (Collection<relatedlink>) SelectedItem.DataContext; foreach ( relatedlink copiedLink in copiedLinks ) { var newLink = new relatedlink(); copyLink( newLink, copiedLink, selectedLinks.Count ); selectedLinks.Add( newLink ); } SelectedItem.DataContext = selectedLinks; doDefaultTreeViewSelectionChange(); } else { MessageBox.Show( "You have placed " + MainWindow.ClipBoardRecord.TypeName + " type on the tools clip board.\nMake sure to paste it on a matching node type.", "Error pasting copied record", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } break; } }
/// <summary> /// This one pastes one example at a time /// </summary> /// <param name="selectedExample"> </param> /// <param name="copiedExample"> </param> /// <param name="count"> </param> public void copyExample( example selectedExample, example copiedExample, int count ) { MainWindow.ExamplesControl1.ExampleCommandTextBox.Text = copiedExample.ExampleCmd; MainWindow.ExamplesControl1.ExampleDescriptionTextBox.Text = copiedExample.ExampleDescription; MainWindow.ExamplesControl1.ExampleOutputTextBox.Text = copiedExample.ExampleOutput; MainWindow.ExamplesControl1.ExampleNameTextBox.Text = copiedExample.ExampleName; AddExample_Click( null, null ); }
/// <summary> /// Write the Example section in the text viewer. /// </summary> /// <param name="examp"> </param> /// <returns> </returns> public String writeExample( example examp ) { String ExampleStream; ExampleStream = " -------------------------- " + examp.ExampleName + " --------------------------\r\n\r\n"; ExampleStream += " C:\\PS>" + examp.ExampleCmd + "\r\n\r\n"; ExampleStream += " " + examp.ExampleDescription + "\r\n\r\n"; ExampleStream += " " + examp.ExampleOutput + "\r\n\r\n"; return ExampleStream; }
/// <summary> /// This routine removes examples from the tree. /// </summary> /// <param name="sender"> </param> /// <param name="args"> </param> public void DeleteExample_Click( object sender, RoutedEventArgs args ) { if ( ExamplesControl1.ExampleID.Text == "" ) { //Safe to simply reset the Examples page. MainWindow.ResetExamplesPage(); } else //We must remove the current record from the Examples list { var selectedNode = (TreeViewItem) MainWindow.NavControl.CmdletTreeView.SelectedItem; var ParentNode = (TreeViewItem) selectedNode.Parent; var CmdletNode = (TreeViewItem) ParentNode.Parent; ParentNode.IsSelected = true; //int ItemToRemove = selectedNode.Items.IndexOf(); // var selectedCmdlet = (cmdletDescription) CmdletNode.DataContext; var selectedExample = (example) selectedNode.DataContext; foreach ( cmdletDescription mycmdlet in MainWindow.CmdletsHelps ) { if ( mycmdlet.CmdletName == selectedCmdlet.CmdletName ) { Collection<example> myExamples = mycmdlet.Examples; var exampletoRemove = new example(); foreach ( example myexample in myExamples ) { if ( myexample.ExampleID == selectedExample.ExampleID ) { exampletoRemove = myexample; } } if ( exampletoRemove.ExampleID.ToString() != null ) { mycmdlet.Examples.Remove( exampletoRemove ); ParentNode.Items.Remove( selectedNode ); } } } } }
/// <summary> /// This is the static method which Asim helped me with. /// I get all the Cmdlet Mamal info from here. /// I need to pass the cmdletDescription record before adding it to the CmdletHelps collection. /// </summary> public static cmdletDescription GetExistingHelpInfo( cmdletDescription CmdletHelp, String CmdletName, String path) { //String path1 = @"C:\Windows\System32\WindowsPowerShell\v1.0\en-US\Microsoft.PowerShell.Commands.Management.dll-Help.xml"; var doc = new XmlDocument(); doc.Load( path ); var ns = new XmlNamespaceManager( doc.NameTable ); ns.AddNamespace( "", "http://msh" ); ns.AddNamespace( "command", "http://schemas.microsoft.com/maml/dev/command/2004/10" ); ns.AddNamespace( "maml", "http://schemas.microsoft.com/maml/2004/10" ); ns.AddNamespace( "dev", "http://schemas.microsoft.com/maml/dev/2004/10" ); XmlNodeList commandNodes = doc.SelectNodes( "//command:command", ns ); foreach ( XmlNode commandNode in commandNodes ) { XmlNode nameNode = commandNode.SelectSingleNode( "command:details/command:name", ns ); if ( nameNode.InnerText.Trim().ToLower() == CmdletName.ToLower() ) { // MessageBox.Show(commandNode.OuterXml); XmlNode tempNode = null; tempNode = commandNode.SelectSingleNode( "command:details/maml:description", ns ); if ( tempNode != null ) { CmdletHelp.OldShortDescription = CmdletHelp.ShortDescription = tempNode.InnerText.Trim(); } tempNode = commandNode.SelectSingleNode( "maml:description", ns ); if ( tempNode != null ) { CmdletHelp.OldLongDescription = CmdletHelp.LongDescription = tempNode.InnerText.Trim(); } tempNode = commandNode.SelectSingleNode( "command:inputTypes/command:inputType/dev:type/maml:name", ns ); if ( tempNode != null ) { CmdletHelp.OldInputType = CmdletHelp.InputType = tempNode.InnerText.Trim(); } tempNode = commandNode.SelectSingleNode( "command:inputTypes/command:inputType/dev:type/maml:description", ns ); if ( tempNode != null ) { CmdletHelp.OldInputDesc = CmdletHelp.InputDesc = tempNode.InnerText.Trim(); } tempNode = commandNode.SelectSingleNode( "command:returnValues/command:returnValue/dev:type/maml:name", ns ); if ( tempNode != null ) { CmdletHelp.OldOutputType = CmdletHelp.OutputType = tempNode.InnerText.Trim(); } tempNode = commandNode.SelectSingleNode( "command:returnValues/command:returnValue/dev:type/maml:description", ns ); if ( tempNode != null ) { CmdletHelp.OldOutputDesc = CmdletHelp.OutputDesc = tempNode.InnerText.Trim(); } tempNode = commandNode.SelectSingleNode( "maml:alertSet/maml:alert", ns ); if ( tempNode != null ) { CmdletHelp.OldNote = CmdletHelp.Note = tempNode.InnerText.Trim(); } XmlNodeList exampleNodes = commandNode.SelectNodes( "command:examples/command:example", ns ); int exampleCount = 0; var CmdletExamples = new Collection<example>(); foreach ( XmlNode exampleNode in exampleNodes ) { var CmdletExample = new example(); tempNode = exampleNode.SelectSingleNode( "maml:title", ns ); if ( tempNode != null ) { CmdletExample.OldExampleName = CmdletExample.ExampleName = tempNode.InnerText.Trim().Replace( "-", "" ); if ( CmdletExample.ExampleName.Length == 0 || CmdletExample.ExampleName.Replace( " ", "" ) == "" ) { CmdletExample.ExampleName = CmdletExample.OldExampleName = "Unkown"; } } CmdletExample.ExampleID = exampleCount; tempNode = exampleNode.SelectSingleNode( "dev:code", ns ); if ( tempNode != null ) { CmdletExample.OldExampleCmd = CmdletExample.ExampleCmd = tempNode.InnerText.Trim(); } tempNode = exampleNode.SelectSingleNode( "dev:remarks", ns ); if ( tempNode != null ) { int NodeCount = 0; foreach ( XmlNode DescriptionNode in tempNode ) { if ( NodeCount == 0 ) { CmdletExample.OldExampleDescription = CmdletExample.ExampleDescription = DescriptionNode.InnerText.Trim(); } else { CmdletExample.OldExampleOutput += DescriptionNode.InnerText.Trim(); CmdletExample.ExampleOutput = CmdletExample.OldExampleOutput; } NodeCount++; } } tempNode = exampleNode.SelectSingleNode( "command:commandLines", ns ); if ( tempNode != null ) { CmdletExample.OldExampleOutput += tempNode.InnerText.Trim(); CmdletExample.ExampleOutput = CmdletExample.OldExampleOutput; } exampleCount++; CmdletExamples.Add( CmdletExample ); } CmdletHelp.Examples = CmdletExamples; var RelatedLinks = new Collection<relatedlink>(); XmlNodeList NodeLinks = commandNode.SelectNodes( "maml:relatedLinks/maml:navigationLink", ns ); int LinkCount = 0; foreach ( XmlNode linkNode in NodeLinks ) { var RelatedLink = new relatedlink(); tempNode = linkNode.SelectSingleNode( "maml:linkText", ns ); if ( tempNode != null ) { RelatedLink.OldLinkText = RelatedLink.LinkText = tempNode.InnerText.Trim(); if ( RelatedLink.LinkText.Length == 0 ) { RelatedLink.LinkText = RelatedLink.LinkText = "Unkown"; } } RelatedLink.LinkID = LinkCount; LinkCount++; RelatedLinks.Add( RelatedLink ); } CmdletHelp.RelatedLinks = RelatedLinks; //iterate through parameters XmlNodeList parameterNodes = commandNode.SelectNodes( "command:parameters/command:parameter", ns ); if ( CmdletHelp.ParameterDecription != null ) { foreach ( parameterDecription CmdletParameter in CmdletHelp.ParameterDecription ) { //maml:description foreach ( XmlNode parameterNode in parameterNodes ) { tempNode = parameterNode.SelectSingleNode( "maml:name", ns ); if ( tempNode != null ) { if ( CmdletParameter.Name.ToLower() == tempNode.InnerText.Trim().ToLower() ) { tempNode = parameterNode.SelectSingleNode( "maml:description", ns ); if ( tempNode != null ) { CmdletParameter.OldDescription = CmdletParameter.NewDescription = tempNode.InnerText.Trim(); } tempNode = parameterNode.SelectSingleNode( "dev:defaultValue", ns ); if ( tempNode != null ) { CmdletParameter.DefaultValue = CmdletParameter.OldDefaultValue = tempNode.InnerText.Trim(); } tempNode = parameterNode.SelectSingleNode( "@globbing", ns ); if ( tempNode.Value.ToLower().Trim() == "true" ) { CmdletParameter.Globbing = CmdletParameter.OldGlobbing = true; } else { CmdletParameter.Globbing = CmdletParameter.OldGlobbing = false; } } } } } } //I do not have code parameters. Get only help ones and mark them in red. foreach ( XmlNode parameterNode in parameterNodes ) { Boolean ParameterFound = false; tempNode = parameterNode.SelectSingleNode( "maml:name", ns ); String ParameterName = tempNode.InnerText.Trim(); if ( CmdletHelp.ParameterDecription != null ) { foreach ( parameterDecription CmdletParameter in CmdletHelp.ParameterDecription ) { if ( CmdletParameter.Name.ToLower() == ParameterName.ToLower() ) { ParameterFound = true; break; } } } if ( ParameterFound == false ) { //Get help parameter. var CmdletParameter = new parameterDecription(); CmdletParameter.HelpOnlyParameter = true; MainWindow.ObsoleteInfo = true; tempNode = parameterNode.SelectSingleNode( "maml:name", ns ); if ( tempNode != null ) { // if (CmdletParameter.Name.ToLower() == tempNode.InnerText.Trim().ToLower()) // { tempNode = parameterNode.SelectSingleNode( "maml:description", ns ); if ( tempNode != null ) { CmdletParameter.OldDescription = CmdletParameter.NewDescription = tempNode.InnerText.Trim(); } tempNode = parameterNode.SelectSingleNode( "dev:defaultValue", ns ); if ( tempNode != null ) { CmdletParameter.DefaultValue = CmdletParameter.OldDefaultValue = tempNode.InnerText.Trim(); } tempNode = parameterNode.SelectSingleNode( "@globbing", ns ); if ( tempNode.Value.ToLower().Trim() == "true" ) { CmdletParameter.Globbing = CmdletParameter.OldGlobbing = true; } else { CmdletParameter.Globbing = CmdletParameter.OldGlobbing = false; } tempNode = parameterNode.SelectSingleNode( "@pipelineInput", ns ); if ( tempNode != null ) { if ( tempNode.Value.ToLower().Trim() == "true (ByPropertyName)" ) { CmdletParameter.VFPBPN = CmdletParameter.VFPBPN = true; } else if ( tempNode.Value.ToLower().Trim() == "true (ByValue, ByPropertyName)" ) { CmdletParameter.VFPBPN = CmdletParameter.VFPBPN = true; CmdletParameter.VFP = CmdletParameter.VFP = true; } else if ( tempNode.Value.ToLower().Trim() == "true (ByValue)" ) { CmdletParameter.VFP = CmdletParameter.VFP = true; } else { CmdletParameter.VFPBPN = CmdletParameter.VFPBPN = false; CmdletParameter.VFP = CmdletParameter.VFP = false; } } tempNode = parameterNode.SelectSingleNode( "@position", ns ); if ( tempNode != null ) { CmdletParameter.Position = tempNode.Value.ToLower().Trim(); } tempNode = parameterNode.SelectSingleNode( "@required", ns ); if ( tempNode != null ) { if ( tempNode.Value.ToLower().Trim() == "true" ) { CmdletParameter.isMandatory = true; } } tempNode = parameterNode.SelectSingleNode( "dev:type/maml:name", ns ); if ( tempNode != null ) { if ( tempNode.InnerText != null ) { CmdletParameter.ParameterType = tempNode.InnerText.Trim().ToLower(); } } CmdletParameter.Name = ParameterName; CmdletParameter.CmdletName = CmdletName; if ( CmdletHelp.ParameterDecription == null ) { CmdletHelp.ParameterDecription = new Collection<parameterDecription>(); } CmdletHelp.ParameterDecription.Add( CmdletParameter ); } } } // break; } } return CmdletHelp; }
public XmlWriter createExampleItemSection( XmlWriter writer, example result ) { try { //Start a <command:example> section writer.WriteRaw( " <command:example>\r\n" ); //writer.WriteComment("Example item section"); writer.WriteRaw( " <maml:title>\r\n" ); if ( result.ExampleName != null ) { String ExampleTitle = HttpUtility.HtmlEncode( "-------------- " + result.ExampleName.Replace( "-", "" ).Trim() + " --------------" ); writer.WriteRaw( ExampleTitle ); } writer.WriteRaw( " </maml:title>\r\n" ); //Introduction writer.WriteRaw( " <maml:introduction>\r\n" ); writer.WriteRaw( " <maml:para>C:\\PS></maml:para>\r\n" ); writer.WriteRaw( "C:\\PS>" ); writer.WriteRaw( " </maml:introduction>\r\n" ); // writer.WriteRaw(); //Dev code section writer.WriteRaw( " <dev:code>" ); //writer.WriteRaw("Command to run"); writer.WriteRaw( HttpUtility.HtmlEncode( result.ExampleCmd ) ); writer.WriteRaw( "</dev:code>\r\n" ); //Dev remarks: Example description writer.WriteRaw( " <dev:remarks>\r\n" ); //writer.WriteComment("Example description"); writer.WriteRaw( " <maml:para>" ); writer.WriteRaw( HttpUtility.HtmlEncode( result.ExampleDescription ) ); writer.WriteRaw( "</maml:para>\r\n" ); writer.WriteRaw( " <maml:para></maml:para>\r\n" ); writer.WriteRaw( " <maml:para></maml:para>\r\n" ); writer.WriteRaw( " <maml:para>" ); writer.WriteRaw( HttpUtility.HtmlEncode( result.ExampleOutput ) ); writer.WriteRaw( "\r\n </maml:para>\r\n" ); writer.WriteRaw( " <maml:para></maml:para>\r\n" ); writer.WriteRaw( " </dev:remarks>\r\n" ); //writer.WriteRaw(); //Example output section writer.WriteRaw( " <command:commandLines>\r\n" ); //writer.WriteComment("Example Output"); writer.WriteRaw( " <command:commandLine>\r\n" ); writer.WriteRaw( " <command:commandText>\r\n" ); //writer.WriteComment("Example output section"); //writer.WriteRaw(HttpUtility.HtmlEncode(result.ExampleOutput)); writer.WriteRaw( " </command:commandText>\r\n" ); writer.WriteRaw( " </command:commandLine>\r\n" ); writer.WriteRaw( " </command:commandLines>\r\n" ); //End example secion writer.WriteRaw( " </command:example>\r\n" ); //<command:example> // <maml:title> // <!-- EXAMPLE 1--> // </maml:title> // <maml:introduction> // <maml:para>C:\PS></maml:para> // </maml:introduction> // <dev:code><!-- Command to run --></dev:code> // <dev:remarks> // <maml:para><!-- Example description--></maml:para> // <maml:para></maml:para> // <maml:para></maml:para> // <maml:para> </maml:para> // <maml:para></maml:para> // </dev:remarks> // <command:commandLines> // <command:commandLine> // <command:commandText><!-- Example output section--></command:commandText> // </command:commandLine> // </command:commandLines> //</command:example> } catch ( Exception ex ) { MessageBox.Show( ex.Message, "Error writing the XML File.", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } return writer; }