mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-15 06:09:09 +00:00
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files. Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks. Separate PR coming to update contribution document for new source files: #6140 Manually reviewed each change. Fix #6073
137 lines
4.1 KiB
C#
137 lines
4.1 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
using System.Xml;
|
|
|
|
namespace System.Management.Automation
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// Class MamlClassHelpInfo keeps track of help information to be returned by
|
|
/// class help provider.
|
|
///
|
|
/// </summary>
|
|
internal class MamlClassHelpInfo : HelpInfo
|
|
{
|
|
/// <summary>
|
|
/// Constructor for custom HelpInfo object creation.
|
|
/// </summary>
|
|
/// <param name="helpObject"></param>
|
|
/// <param name="helpCategory"></param>
|
|
internal MamlClassHelpInfo(PSObject helpObject, HelpCategory helpCategory)
|
|
{
|
|
HelpCategory = helpCategory;
|
|
_fullHelpObject = helpObject;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Convert a XMLNode to HelpInfo object.
|
|
/// </summary>
|
|
/// <param name="xmlNode"></param>
|
|
/// <param name="helpCategory"></param>
|
|
private MamlClassHelpInfo(XmlNode xmlNode, HelpCategory helpCategory)
|
|
{
|
|
HelpCategory = helpCategory;
|
|
|
|
MamlNode mamlNode = new MamlNode(xmlNode);
|
|
_fullHelpObject = mamlNode.PSObject;
|
|
|
|
this.Errors = mamlNode.Errors;
|
|
_fullHelpObject.TypeNames.Clear();
|
|
_fullHelpObject.TypeNames.Add("PSClassHelpInfo");
|
|
}
|
|
|
|
/// <summary>
|
|
/// PSObject representation on help.
|
|
/// </summary>
|
|
private PSObject _fullHelpObject;
|
|
|
|
#region Load
|
|
|
|
/// <summary>
|
|
/// Create a MamlClassHelpInfo object from an XmlNode.
|
|
/// </summary>
|
|
/// <param name="xmlNode">xmlNode that contains help info</param>
|
|
/// <param name="helpCategory">help category this maml object fits into</param>
|
|
/// <returns>MamlCommandHelpInfo object created</returns>
|
|
internal static MamlClassHelpInfo Load(XmlNode xmlNode, HelpCategory helpCategory)
|
|
{
|
|
MamlClassHelpInfo mamlClassHelpInfo = new MamlClassHelpInfo(xmlNode, helpCategory);
|
|
|
|
if (String.IsNullOrEmpty(mamlClassHelpInfo.Name))
|
|
return null;
|
|
|
|
mamlClassHelpInfo.AddCommonHelpProperties();
|
|
|
|
return mamlClassHelpInfo;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Helper Methods and Overloads
|
|
|
|
/// <summary>
|
|
/// Clone the help info object.
|
|
/// </summary>
|
|
/// <returns>MamlClassHelpInfo object.</returns>
|
|
internal MamlClassHelpInfo Copy()
|
|
{
|
|
MamlClassHelpInfo result = new MamlClassHelpInfo(_fullHelpObject.Copy(), this.HelpCategory);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clone the help object with a new category.
|
|
/// </summary>
|
|
/// <param name="newCategoryToUse"></param>
|
|
/// <returns>MamlClassHelpInfo</returns>
|
|
internal MamlClassHelpInfo Copy(HelpCategory newCategoryToUse)
|
|
{
|
|
MamlClassHelpInfo result = new MamlClassHelpInfo(_fullHelpObject.Copy(), newCategoryToUse);
|
|
result.FullHelp.Properties["Category"].Value = newCategoryToUse;
|
|
return result;
|
|
}
|
|
|
|
internal override string Name
|
|
{
|
|
get
|
|
{
|
|
string tempName = string.Empty;
|
|
var title = _fullHelpObject.Properties["title"];
|
|
|
|
if (title != null && title.Value != null)
|
|
{
|
|
tempName = title.Value.ToString();
|
|
}
|
|
|
|
return tempName;
|
|
}
|
|
}
|
|
|
|
internal override string Synopsis
|
|
{
|
|
get
|
|
{
|
|
string tempSynopsis = string.Empty;
|
|
var intro = _fullHelpObject.Properties["introduction"];
|
|
|
|
if (intro != null && intro.Value != null)
|
|
{
|
|
tempSynopsis = intro.Value.ToString();
|
|
}
|
|
|
|
return tempSynopsis;
|
|
}
|
|
}
|
|
|
|
internal override HelpCategory HelpCategory { get; }
|
|
|
|
internal override PSObject FullHelp
|
|
{
|
|
get { return _fullHelpObject; }
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|