diff --git a/src/Schemas/PSMaml/Maml.xsd b/src/Schemas/PSMaml/Maml.xsd index 46aac982c7..9dd135b51e 100644 --- a/src/Schemas/PSMaml/Maml.xsd +++ b/src/Schemas/PSMaml/Maml.xsd @@ -12,7 +12,6 @@ - \ No newline at end of file diff --git a/src/Schemas/PSMaml/endUser.xsd b/src/Schemas/PSMaml/endUser.xsd index 03b9bf138a..19317c7074 100644 --- a/src/Schemas/PSMaml/endUser.xsd +++ b/src/Schemas/PSMaml/endUser.xsd @@ -19,7 +19,6 @@ --> - diff --git a/src/Schemas/PSMaml/faq.xsd b/src/Schemas/PSMaml/faq.xsd deleted file mode 100644 index 92cd580bac..0000000000 --- a/src/Schemas/PSMaml/faq.xsd +++ /dev/null @@ -1,89 +0,0 @@ - - - - - This schema definition defines the FAQ content model for the Content Studio schema. This schema is part of the base layer. - - - - - - Describes the content model for the FAQ content type. The FAQ content type is used to create frequently asked question (FAQ) documents. A document that uses the FAQ content type can consist of one or more sets of questions and answers. - - - - - Describes a titled division within a frequently asked question (FAQ) document. Each faqDiv element can contain one or more faqEntry elements. - - - - - - - - - - - - - - - - Describes a question-answer pair within a frequently asked question (FAQ) document. - - - - - - - - - - - - - - - Describes the question text for a frequently asked question (FAQ) entry. - - - - - Describes an answer to a frequently asked question (FAQ) entry. - - - - - - - - - - Specifies the name of the document author. - - - - - - - - - - - - - - - - Specifies the type of content for the document. - - - - diff --git a/src/Schemas/PSMaml/glossary.xsd b/src/Schemas/PSMaml/glossary.xsd deleted file mode 100644 index f356205f3d..0000000000 --- a/src/Schemas/PSMaml/glossary.xsd +++ /dev/null @@ -1,54 +0,0 @@ - - - - - This schema definition defines the glossary content type for the Content Studio Schema. This schema is part of the base layer. - - - - - - Describes the content model for the glossary content type. Glossary topics contain a set of terms and associated definitions. - - - - - - - - - - - - - Specifies the type of content for the document. - - - - - - - - Describes a titled section within a glossary. Each glossaryDiv element can contain one or more glossaryEntry elements. - - - - - - - - - - Specifies the class of the element. - - - - - diff --git a/src/System.Management.Automation/help/FaqHelpInfo.cs b/src/System.Management.Automation/help/FaqHelpInfo.cs deleted file mode 100644 index c5a9b69267..0000000000 --- a/src/System.Management.Automation/help/FaqHelpInfo.cs +++ /dev/null @@ -1,221 +0,0 @@ -/********************************************************************++ -Copyright (c) Microsoft Corporation. All rights reserved. ---********************************************************************/ - -using System.Collections; -using System.Xml; -using System.Diagnostics.CodeAnalysis; // for fxcop - -namespace System.Management.Automation -{ - /// - /// - /// Class FaqHelpInfo keeps track of help information to be returned by - /// faq help provider. - /// - /// - internal class FaqHelpInfo : HelpInfo - { - /// - /// Constructor for FaqHelpInfo - /// - /// - /// This constructor is can be called only from constructors of derived class - /// for FaqHelpInfo. The only way to to create a FaqHelpInfo is through - /// static function - /// Load(XmlNode node) - /// where some sanity check is done. - /// - [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "This is internal code and is verified.")] - protected FaqHelpInfo(XmlNode xmlNode) - { - MamlNode mamlNode = new MamlNode(xmlNode); - _fullHelpObject = mamlNode.PSObject; - this.Errors = mamlNode.Errors; - - _fullHelpObject.TypeNames.Clear(); - _fullHelpObject.TypeNames.Add(string.Format(Globalization.CultureInfo.InvariantCulture, - "FaqHelpInfo#{0}", Name)); - _fullHelpObject.TypeNames.Add("FaqHelpInfo"); - _fullHelpObject.TypeNames.Add("HelpInfo"); - } - - #region Basic Help Properties / Methods - - /// - /// Name of faq. - /// - /// Name of faq - internal override string Name - { - get - { - if (_fullHelpObject == null) - return ""; - - if (_fullHelpObject.Properties["Title"] == null) - return ""; - - if (_fullHelpObject.Properties["Title"].Value == null) - return ""; - - string name = _fullHelpObject.Properties["Title"].Value.ToString(); - if (name == null) - return ""; - - return name.Trim(); - } - } - - /// - /// Synopsis for this faq help. - /// - /// Synopsis for this faq help - internal override string Synopsis - { - get - { - if (_fullHelpObject == null) - return ""; - - if (_fullHelpObject.Properties["question"] == null) - return ""; - - if (_fullHelpObject.Properties["question"].Value == null) - return ""; - - string synopsis = _fullHelpObject.Properties["question"].Value.ToString(); - if (synopsis == null) - return ""; - - return synopsis.Trim(); - } - } - - /// - /// Help category for this faq help, which is constantly HelpCategory.FAQ. - /// - /// Help category for this faq help - internal override HelpCategory HelpCategory - { - get - { - return HelpCategory.FAQ; - } - } - - private PSObject _fullHelpObject; - - /// - /// Full help object for this help item. - /// - /// Full help object for this help item. - internal override PSObject FullHelp - { - get - { - return _fullHelpObject; - } - } - - /// - /// Returns true if help content in help info matches the - /// pattern contained in . - /// The underlying code will usually run pattern.IsMatch() on - /// content it wants to search. - /// FAQ help info looks for pattern in Synopsis and - /// Answers - /// - /// - /// - internal override bool MatchPatternInContent(WildcardPattern pattern) - { - Diagnostics.Assert(null != pattern, "pattern cannot be null"); - - string synopsis = Synopsis; - string answers = Answers; - - if (null == synopsis) - { - synopsis = string.Empty; - } - - if (null == Answers) - { - answers = string.Empty; - } - - return pattern.IsMatch(synopsis) || pattern.IsMatch(answers); - } - - #endregion - - #region Private Methods / Properties - - - /// - /// Answers string of this FAQ help info. - /// - private string Answers - { - get - { - if (this.FullHelp == null) - return ""; - - if (this.FullHelp.Properties["answer"] == null || - this.FullHelp.Properties["answer"].Value == null) - { - return ""; - } - - IList answerItems = FullHelp.Properties["answer"].Value as IList; - if (answerItems == null || answerItems.Count == 0) - { - return ""; - } - - Text.StringBuilder result = new Text.StringBuilder(); - foreach (object answerItem in answerItems) - { - PSObject answerObject = PSObject.AsPSObject(answerItem); - if ((null == answerObject) || - (null == answerObject.Properties["Text"]) || - (null == answerObject.Properties["Text"].Value)) - { - continue; - } - - string text = answerObject.Properties["Text"].Value.ToString(); - result.Append(text); - result.Append(Environment.NewLine); - } - - return result.ToString().Trim(); - } - } - - #endregion - - #region Load - - /// - /// Create a FaqHelpInfo object from an XmlNode. - /// - /// xmlNode that contains help info - /// FaqHelpInfo object created - internal static FaqHelpInfo Load(XmlNode xmlNode) - { - FaqHelpInfo faqHelpInfo = new FaqHelpInfo(xmlNode); - - if (String.IsNullOrEmpty(faqHelpInfo.Name)) - return null; - - faqHelpInfo.AddCommonHelpProperties(); - - return faqHelpInfo; - } - - #endregion - } -} diff --git a/src/System.Management.Automation/help/FaqHelpProvider.cs b/src/System.Management.Automation/help/FaqHelpProvider.cs deleted file mode 100644 index 86bbddf5dd..0000000000 --- a/src/System.Management.Automation/help/FaqHelpProvider.cs +++ /dev/null @@ -1,232 +0,0 @@ -/********************************************************************++ -Copyright (c) Microsoft Corporation. All rights reserved. ---********************************************************************/ - -using System.IO; -using System.Collections; -using System.Collections.ObjectModel; -using System.Xml; -using System.Reflection; - -namespace System.Management.Automation -{ - /// - /// Class FaqHelpProvider implement the help provider for faq's. - /// - /// - /// - /// Faq Help information are stored in 'faq.xml' files. These files are - /// located in the Monad / CustomShell Path as well as in the Application Base - /// of PSSnapIns - /// - internal class FaqHelpProvider : HelpProviderWithFullCache - { - /// - /// Constructor for FaqHelpProvider - /// - internal FaqHelpProvider(HelpSystem helpSystem) : base(helpSystem) - { - } - - #region Common Properties - - /// - /// Name of this provider - /// - /// Name of this provider - internal override string Name - { - get - { - return "FAQ Help Provider"; - } - } - - /// - /// Help category for this provider, which is a constant: HelpCategory.FAQ. - /// - /// Help category for this provider - internal override HelpCategory HelpCategory - { - get - { - return HelpCategory.FAQ; - } - } - - #endregion - - #region Load cache - - /// - /// Load cache for faq help's - /// - internal sealed override void LoadCache() - { - Collection files = MUIFileSearcher.SearchFiles("*.faq.xml", GetSearchPaths()); - - if (files == null) - return; - - foreach (string file in files) - { - if (!_helpFiles.ContainsKey(file)) - { - LoadHelpFile(file); - // Add this file into _helpFiles hashtable to prevent it to be loaded again. - _helpFiles[file] = 0; - } - } - } - - /// - /// Load help file for HelpInfo objects. The HelpInfo objects will be - /// put into help cache. - /// - /// - /// 1. Needs to pay special attention about error handling in this function. - /// Common errors include: file not found and invalid xml. None of these error - /// should cause help search to stop. - /// - /// - private void LoadHelpFile(string helpFile) - { - if (String.IsNullOrEmpty(helpFile)) - { - return; - } - - XmlDocument doc; - try - { - doc = InternalDeserializer.LoadUnsafeXmlDocument( - new FileInfo(helpFile), - false, /* ignore whitespace, comments, etc. */ - null); /* default maxCharactersInDocument */ - } - catch (IOException ioException) - { - ErrorRecord errorRecord = new ErrorRecord(ioException, "HelpFileLoadFailure", ErrorCategory.OpenError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(FaqHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileLoadFailure", helpFile, ioException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - catch (System.Security.SecurityException securityException) - { - ErrorRecord errorRecord = new ErrorRecord(securityException, "HelpFileNotAccessible", ErrorCategory.OpenError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(FaqHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileNotAccessible", helpFile, securityException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - catch (XmlException xmlException) - { - ErrorRecord errorRecord = new ErrorRecord(xmlException, "HelpFileNotValid", ErrorCategory.SyntaxError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(FaqHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileNotValid", helpFile, xmlException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - - XmlNode helpItemsNode = null; - - if (doc.HasChildNodes) - { - for (int i = 0; i < doc.ChildNodes.Count; i++) - { - XmlNode node = doc.ChildNodes[i]; - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "faq", StringComparison.OrdinalIgnoreCase) == 0) - { - helpItemsNode = node; - break; - } - } - } - - if (helpItemsNode == null) - return; - - using (this.HelpSystem.Trace(helpFile)) - { - if (helpItemsNode.HasChildNodes) - { - for (int i = 0; i < helpItemsNode.ChildNodes.Count; i++) - { - XmlNode node = helpItemsNode.ChildNodes[i]; - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "faqEntry", StringComparison.OrdinalIgnoreCase) == 0) - { - HelpInfo helpInfo = null; - - helpInfo = FaqHelpInfo.Load(node); - - if (helpInfo != null) - { - this.HelpSystem.TraceErrors(helpInfo.Errors); - AddCache(helpInfo.Name, helpInfo); - } - continue; - } - - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "faqDiv", StringComparison.OrdinalIgnoreCase) == 0) - { - LoadFaqDiv(node); - } - } - } - } - } - - /// - /// - /// - /// - private void LoadFaqDiv(XmlNode xmlNode) - { - if (xmlNode == null) - return; - - for (int i = 0; i < xmlNode.ChildNodes.Count; i++) - { - XmlNode node = xmlNode.ChildNodes[i]; - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "faqEntry", StringComparison.OrdinalIgnoreCase) == 0) - { - HelpInfo helpInfo = null; - - helpInfo = FaqHelpInfo.Load(node); - - if (helpInfo != null) - { - this.HelpSystem.TraceErrors(helpInfo.Errors); - AddCache(helpInfo.Name, helpInfo); - } - } - } - } - - #endregion - - # region Help Provider Interface - - /// - /// This will reset the help cache. Normally this corresponds to a - /// help culture change. - /// - internal override void Reset() - { - base.Reset(); - - _helpFiles.Clear(); - } - - #endregion - - #region Private Data - - /// - /// This is a hashtable to track which help files are loaded already. - /// - /// This will avoid one help file getting loaded again and again. - /// - private readonly Hashtable _helpFiles = new Hashtable(); - - #endregion - } -} diff --git a/src/System.Management.Automation/help/GeneralHelpInfo.cs b/src/System.Management.Automation/help/GeneralHelpInfo.cs deleted file mode 100644 index 57486da870..0000000000 --- a/src/System.Management.Automation/help/GeneralHelpInfo.cs +++ /dev/null @@ -1,130 +0,0 @@ -/********************************************************************++ -Copyright (c) Microsoft Corporation. All rights reserved. ---********************************************************************/ - -using System.Xml; -using System.Diagnostics.CodeAnalysis; // for fxcop - -namespace System.Management.Automation -{ - /// - /// - /// Class GeneralHelpInfo keeps track of help information to be returned by - /// general help provider. - /// - /// - internal class GeneralHelpInfo : HelpInfo - { - /// - /// Constructor for GeneralHelpInfo - /// - /// - /// This constructor is can be called only from constructors of derived class - /// for GeneralHelpInfo. The only way to to create a GeneralHelpInfo is through - /// static function - /// Load(XmlNode node) - /// where some sanity check is done. - /// - [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "This is internal and the code path is verified.")] - protected GeneralHelpInfo(XmlNode xmlNode) - { - MamlNode mamlNode = new MamlNode(xmlNode); - _fullHelpObject = mamlNode.PSObject; - this.Errors = mamlNode.Errors; - - _fullHelpObject.TypeNames.Clear(); - _fullHelpObject.TypeNames.Add(string.Format(Globalization.CultureInfo.InvariantCulture, - "GeneralHelpInfo#{0}", Name)); - _fullHelpObject.TypeNames.Add("GeneralHelpInfo"); - _fullHelpObject.TypeNames.Add("HelpInfo"); - } - - #region Basic Help Properties - - /// - /// Name of help content. - /// - /// Name of help content - internal override string Name - { - get - { - if (_fullHelpObject == null) - return ""; - - if (_fullHelpObject.Properties["Title"] == null) - return ""; - - if (_fullHelpObject.Properties["Title"].Value == null) - return ""; - - string name = _fullHelpObject.Properties["Title"].Value.ToString(); - if (name == null) - return ""; - - return name.Trim(); - } - } - - /// - /// Synopsis for this general help. - /// - /// Synopsis for this general help - internal override string Synopsis - { - get - { - return ""; - } - } - - /// - /// Help category for this general help, which is constantly HelpCategory.General. - /// - /// Help category for general help - internal override HelpCategory HelpCategory - { - get - { - return HelpCategory.General; - } - } - - private PSObject _fullHelpObject; - - /// - /// Full help object for this help item. - /// - /// Full help object for this help item. - internal override PSObject FullHelp - { - get - { - return _fullHelpObject; - } - } - - #endregion - - #region Load - - /// - /// Create a GeneralHelpInfo object from an XmlNode. - /// - /// xmlNode that contains help info - /// GeneralHelpInfo object created - internal static GeneralHelpInfo Load(XmlNode xmlNode) - { - GeneralHelpInfo generalHelpInfo = new GeneralHelpInfo(xmlNode); - - if (String.IsNullOrEmpty(generalHelpInfo.Name)) - return null; - - generalHelpInfo.AddCommonHelpProperties(); - - return generalHelpInfo; - } - - #endregion - } -} diff --git a/src/System.Management.Automation/help/GeneralHelpProvider.cs b/src/System.Management.Automation/help/GeneralHelpProvider.cs deleted file mode 100644 index b456963442..0000000000 --- a/src/System.Management.Automation/help/GeneralHelpProvider.cs +++ /dev/null @@ -1,200 +0,0 @@ -/********************************************************************++ -Copyright (c) Microsoft Corporation. All rights reserved. ---********************************************************************/ - -using System.IO; -using System.Collections; -using System.Collections.ObjectModel; -using System.Xml; -using System.Reflection; - -namespace System.Management.Automation -{ - /// - /// Class GeneralHelpProvider implement the help provider for general help topics. - /// - /// - /// - /// General Help information are stored in 'concept.xml' files. These files are - /// located in the Monad / CustomShell Path as well as in the Application Base - /// of PSSnapIns - /// - internal class GeneralHelpProvider : HelpProviderWithFullCache - { - /// - /// Constructor for GeneralHelpProvider - /// - internal GeneralHelpProvider(HelpSystem helpSystem) : base(helpSystem) - { - } - - #region Common Properties - - /// - /// Name of this provider - /// - /// Name of this provider - internal override string Name - { - get - { - return "General Help Provider"; - } - } - - /// - /// Help category for this provider, which is a constant: HelpCategory.Command. - /// - /// Help category for this provider - internal override HelpCategory HelpCategory - { - get - { - return HelpCategory.General; - } - } - - #endregion - - #region Load cache - - /// - /// Load cache for general help's - /// - internal sealed override void LoadCache() - { - Collection files = MUIFileSearcher.SearchFiles("*.concept.xml", GetSearchPaths()); - - if (files == null) - return; - - foreach (string file in files) - { - if (!_helpFiles.ContainsKey(file)) - { - LoadHelpFile(file); - // Add this file into _helpFiles hashtable to prevent it to be loaded again. - _helpFiles[file] = 0; - } - } - } - - /// - /// Load help file for HelpInfo objects. The HelpInfo objects will be - /// put into help cache. - /// - /// - /// 1. Needs to pay special attention about error handling in this function. - /// Common errors include: file not found and invalid xml. None of these error - /// should cause help search to stop. - /// - /// - private void LoadHelpFile(string helpFile) - { - if (String.IsNullOrEmpty(helpFile)) - { - return; - } - - XmlDocument doc; - - try - { - doc = InternalDeserializer.LoadUnsafeXmlDocument( - new FileInfo(helpFile), - false, /* ignore whitespace, comments, etc. */ - null); /* default maxCharactersInDocument */ - } - catch (IOException ioException) - { - ErrorRecord errorRecord = new ErrorRecord(ioException, "HelpFileLoadFailure", ErrorCategory.OpenError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(GeneralHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileLoadFailure", helpFile, ioException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - catch (System.Security.SecurityException securityException) - { - ErrorRecord errorRecord = new ErrorRecord(securityException, "HelpFileNotAccessible", ErrorCategory.OpenError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(GeneralHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileNotAccessible", helpFile, securityException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - catch (XmlException xmlException) - { - ErrorRecord errorRecord = new ErrorRecord(xmlException, "HelpFileNotValid", ErrorCategory.SyntaxError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(GeneralHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileNotValid", helpFile, xmlException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - - XmlNode helpItemsNode = null; - - if (doc.HasChildNodes) - { - for (int i = 0; i < doc.ChildNodes.Count; i++) - { - XmlNode node = doc.ChildNodes[i]; - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "conceptuals", StringComparison.OrdinalIgnoreCase) == 0) - { - helpItemsNode = node; - break; - } - } - } - - if (helpItemsNode == null) - return; - - using (this.HelpSystem.Trace(helpFile)) - { - if (helpItemsNode.HasChildNodes) - { - for (int i = 0; i < helpItemsNode.ChildNodes.Count; i++) - { - XmlNode node = helpItemsNode.ChildNodes[i]; - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "conceptual", StringComparison.OrdinalIgnoreCase) == 0) - { - HelpInfo helpInfo = null; - - helpInfo = GeneralHelpInfo.Load(node); - - if (helpInfo != null) - { - this.HelpSystem.TraceErrors(helpInfo.Errors); - AddCache(helpInfo.Name, helpInfo); - } - } - } - } - } - } - - #endregion - - # region Help Provider Interface - - /// - /// This will reset the help cache. Normally this corresponds to a - /// help culture change. - /// - internal override void Reset() - { - base.Reset(); - - _helpFiles.Clear(); - } - - #endregion - - #region Private Data - - /// - /// This is a hashtable to track which help files are loaded already. - /// - /// This will avoid one help file getting loaded again and again. - /// - private readonly Hashtable _helpFiles = new Hashtable(); - - #endregion - } -} diff --git a/src/System.Management.Automation/help/GlossaryHelpInfo.cs b/src/System.Management.Automation/help/GlossaryHelpInfo.cs deleted file mode 100644 index 8befd55503..0000000000 --- a/src/System.Management.Automation/help/GlossaryHelpInfo.cs +++ /dev/null @@ -1,168 +0,0 @@ -/********************************************************************++ -Copyright (c) Microsoft Corporation. All rights reserved. ---********************************************************************/ - -using System.Xml; -using System.Text; -using System.Diagnostics.CodeAnalysis; - -namespace System.Management.Automation -{ - /// - /// - /// Class GlossaryHelpInfo keeps track of help information to be returned by - /// glossary help provider. - /// - /// - internal class GlossaryHelpInfo : HelpInfo - { - /// - /// Constructor for GlossaryHelpInfo - /// - /// - /// This constructor is can be called only from constructors of derived class - /// for GlossaryHelpInfo. The only way to to create a GlossaryHelpInfo is through - /// static function - /// Load(XmlNode node) - /// where some sanity check is done. - /// - [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "This is internal code and is verified.")] - protected GlossaryHelpInfo(XmlNode xmlNode) - { - MamlNode mamlNode = new MamlNode(xmlNode); - _fullHelpObject = mamlNode.PSObject; - this.Errors = mamlNode.Errors; - - Name = GetTerm(); - - _fullHelpObject.TypeNames.Clear(); - _fullHelpObject.TypeNames.Add(string.Format(Globalization.CultureInfo.InvariantCulture, - "GlossaryHelpInfo#{0}", Name)); - _fullHelpObject.TypeNames.Add("GlossaryHelpInfo"); - _fullHelpObject.TypeNames.Add("HelpInfo"); - } - - #region Basic Help Properties - - /// - /// Name of glossary. - /// - /// Name of glossary - internal override string Name { get; } = ""; - - private string GetTerm() - { - if (_fullHelpObject == null) - return ""; - - if (_fullHelpObject.Properties["Terms"] == null) - return ""; - - if (_fullHelpObject.Properties["Terms"].Value == null) - return ""; - - PSObject terms = (PSObject)_fullHelpObject.Properties["Terms"].Value; - - if (terms.Properties["Term"] == null) - return ""; - - if (terms.Properties["Term"].Value == null) - return ""; - - if (terms.Properties["Term"].Value.GetType().Equals(typeof(PSObject))) - { - PSObject term = (PSObject)terms.Properties["Term"].Value; - return term.ToString(); - } - - if (terms.Properties["Term"].Value.GetType().Equals(typeof(PSObject[]))) - { - PSObject[] term = (PSObject[])terms.Properties["Term"].Value; - - StringBuilder result = new StringBuilder(); - for (int i = 0; i < term.Length; i++) - { - string str = term[i].ToString(); - - if (str == null) - continue; - - str = str.Trim(); - - if (String.IsNullOrEmpty(str)) - continue; - - if (result.Length > 0) - result.Append(", "); - - result.Append(str); - } - - return result.ToString(); - } - - return ""; - } - - /// - /// Synopsis for this glossary help. - /// - /// Synopsis for this glossary help - internal override string Synopsis - { - get - { - return ""; - } - } - - /// - /// Help category for this glossary help, which is constantly HelpCategory.Glossary. - /// - /// Help category for this glossary help - internal override HelpCategory HelpCategory - { - get - { - return HelpCategory.Glossary; - } - } - - private PSObject _fullHelpObject; - - /// - /// Full help object for this help item. - /// - /// Full help object for this help item. - internal override PSObject FullHelp - { - get - { - return _fullHelpObject; - } - } - - #endregion - - #region Load - - /// - /// Create a GlossaryHelpInfo object from an XmlNode. - /// - /// xmlNode that contains help info - /// GlossaryHelpInfo object created - internal static GlossaryHelpInfo Load(XmlNode xmlNode) - { - GlossaryHelpInfo glossaryHelpInfo = new GlossaryHelpInfo(xmlNode); - - if (String.IsNullOrEmpty(glossaryHelpInfo.Name)) - return null; - - glossaryHelpInfo.AddCommonHelpProperties(); - - return glossaryHelpInfo; - } - - #endregion - } -} diff --git a/src/System.Management.Automation/help/GlossaryHelpProvider.cs b/src/System.Management.Automation/help/GlossaryHelpProvider.cs deleted file mode 100644 index 592cbfb95d..0000000000 --- a/src/System.Management.Automation/help/GlossaryHelpProvider.cs +++ /dev/null @@ -1,268 +0,0 @@ -/********************************************************************++ -Copyright (c) Microsoft Corporation. All rights reserved. ---********************************************************************/ - -using System.IO; -using System.Collections; -using System.Collections.ObjectModel; -using System.Xml; -using System.Reflection; - -namespace System.Management.Automation -{ - /// - /// Class GlossaryHelpProvider implement the help provider for glossary's. - /// - /// - /// - /// Glossary Help information are stored in 'glossary.xml' files. These files are - /// located in the Monad / CustomShell Path as well as in the Application Base - /// of PSSnapIns - /// - internal class GlossaryHelpProvider : HelpProviderWithFullCache - { - /// - /// Constructor for GlossaryHelpProvider - /// - internal GlossaryHelpProvider(HelpSystem helpSystem) : base(helpSystem) - { - this.HasCustomMatch = true; - } - - #region Common Properties - - /// - /// Name of this provider - /// - /// Name of this provider - internal override string Name - { - get - { - return "Glossary Help Provider"; - } - } - - /// - /// Help category for this provider, which is a constant: HelpCategory.Command. - /// - /// Help category for this provider - internal override HelpCategory HelpCategory - { - get - { - return HelpCategory.Glossary; - } - } - - #endregion - - #region Load cache - - /// - /// This is for implementing CustomMatch algorithm to be used in - /// HelpProviderWithCache for matching a help target with keys in - /// help cache. - /// - /// For each glossary entry, it can contain multiple terms. The - /// key stored in help cache is a concatenation of keys. For example, - /// if there are two terms "foo" and "bar", the key to be used in - /// help cache will be "foo, bar". - /// - /// Because of this mangling, key "foo, bar" should match both - /// "foo" and "bar". - /// - /// - /// target to search - /// key used in cache table - /// - protected sealed override bool CustomMatch(string target, string key) - { - if (String.IsNullOrEmpty(target) || String.IsNullOrEmpty(key)) - return false; - - string[] terms = key.Split(Utils.Separators.Comma); - - for (int i = 0; i < terms.Length; i++) - { - string term = terms[i].Trim(); - - if (term.Equals(target, StringComparison.OrdinalIgnoreCase)) - return true; - } - - return false; - } - - /// - /// Load cache for glossary help's - /// - internal sealed override void LoadCache() - { - Collection files = MUIFileSearcher.SearchFiles("*.glossary.xml", GetSearchPaths()); - - if (files == null) - return; - - foreach (string file in files) - { - if (!_helpFiles.ContainsKey(file)) - { - LoadHelpFile(file); - // Add this file into _helpFiles hashtable to prevent it to be loaded again. - _helpFiles[file] = 0; - } - } - } - - /// - /// Load help file for HelpInfo objects. The HelpInfo objects will be - /// put into help cache. - /// - /// - /// 1. Needs to pay special attention about error handling in this function. - /// Common errors include: file not found and invalid xml. None of these error - /// should cause help search to stop. - /// - /// - private void LoadHelpFile(string helpFile) - { - if (String.IsNullOrEmpty(helpFile)) - { - return; - } - - XmlDocument doc; - try - { - doc = InternalDeserializer.LoadUnsafeXmlDocument( - new FileInfo(helpFile), - false, /* ignore whitespace, comments, etc. */ - null); /* default maxCharactersInDocument */ - } - catch (IOException ioException) - { - ErrorRecord errorRecord = new ErrorRecord(ioException, "HelpFileLoadFailure", ErrorCategory.OpenError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(GlossaryHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileLoadFailure", helpFile, ioException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - catch (System.Security.SecurityException securityException) - { - ErrorRecord errorRecord = new ErrorRecord(securityException, "HelpFileNotAccessible", ErrorCategory.OpenError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(GlossaryHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileNotAccessible", helpFile, securityException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - catch (XmlException xmlException) - { - ErrorRecord errorRecord = new ErrorRecord(xmlException, "HelpFileNotValid", ErrorCategory.SyntaxError, null); - errorRecord.ErrorDetails = new ErrorDetails(typeof(GlossaryHelpProvider).GetTypeInfo().Assembly, "HelpErrors", "HelpFileNotValid", helpFile, xmlException.Message); - this.HelpSystem.LastErrors.Add(errorRecord); - return; - } - - XmlNode helpItemsNode = null; - - if (doc.HasChildNodes) - { - for (int i = 0; i < doc.ChildNodes.Count; i++) - { - XmlNode node = doc.ChildNodes[i]; - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "glossary", StringComparison.OrdinalIgnoreCase) == 0) - { - helpItemsNode = node; - break; - } - } - } - - if (helpItemsNode == null) - return; - - using (this.HelpSystem.Trace(helpFile)) - { - if (helpItemsNode.HasChildNodes) - { - for (int i = 0; i < helpItemsNode.ChildNodes.Count; i++) - { - XmlNode node = helpItemsNode.ChildNodes[i]; - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "glossaryEntry", StringComparison.OrdinalIgnoreCase) == 0) - { - HelpInfo helpInfo = null; - - helpInfo = GlossaryHelpInfo.Load(node); - - if (helpInfo != null) - { - this.HelpSystem.TraceErrors(helpInfo.Errors); - AddCache(helpInfo.Name, helpInfo); - } - continue; - } - - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "glossaryDiv", StringComparison.OrdinalIgnoreCase) == 0) - { - LoadGlossaryDiv(node); - } - } - } - } - } - - /// - /// - /// - /// - private void LoadGlossaryDiv(XmlNode xmlNode) - { - if (xmlNode == null) - return; - - for (int i = 0; i < xmlNode.ChildNodes.Count; i++) - { - XmlNode node = xmlNode.ChildNodes[i]; - if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "glossaryEntry", StringComparison.OrdinalIgnoreCase) == 0) - { - HelpInfo helpInfo = null; - - helpInfo = GlossaryHelpInfo.Load(node); - - if (helpInfo != null) - { - this.HelpSystem.TraceErrors(helpInfo.Errors); - AddCache(helpInfo.Name, helpInfo); - } - } - } - } - - #endregion - - # region Help Provider Interface - - /// - /// This will reset the help cache. Normally this corresponds to a - /// help culture change. - /// - internal override void Reset() - { - base.Reset(); - - _helpFiles.Clear(); - } - - #endregion - - #region Private Data - - /// - /// This is a hashtable to track which help files are loaded already. - /// - /// This will avoid one help file getting loaded again and again. - /// - private readonly Hashtable _helpFiles = new Hashtable(); - - #endregion - } -} diff --git a/src/System.Management.Automation/help/HelpSystem.cs b/src/System.Management.Automation/help/HelpSystem.cs index 9196fcc990..66813e93e9 100644 --- a/src/System.Management.Automation/help/HelpSystem.cs +++ b/src/System.Management.Automation/help/HelpSystem.cs @@ -612,15 +612,6 @@ namespace System.Management.Automation helpProvider = new HelpFileHelpProvider(this); _helpProviders.Add(helpProvider); - helpProvider = new FaqHelpProvider(this); - _helpProviders.Add(helpProvider); - - helpProvider = new GlossaryHelpProvider(this); - _helpProviders.Add(helpProvider); - - helpProvider = new GeneralHelpProvider(this); - _helpProviders.Add(helpProvider); - helpProvider = new DefaultHelpProvider(this); _helpProviders.Add(helpProvider); }