Esempio n. 1
0
 internal static GeneralHelpInfo Load(System.Xml.XmlNode xmlNode)
 {
     GeneralHelpInfo info = new GeneralHelpInfo(xmlNode);
     if (string.IsNullOrEmpty(info.Name))
     {
         return null;
     }
     info.AddCommonHelpProperties();
     return info;
 }
Esempio n. 2
0
        internal static GeneralHelpInfo Load(System.Xml.XmlNode xmlNode)
        {
            GeneralHelpInfo info = new GeneralHelpInfo(xmlNode);

            if (string.IsNullOrEmpty(info.Name))
            {
                return(null);
            }
            info.AddCommonHelpProperties();
            return(info);
        }
Esempio n. 3
0
 internal static GeneralHelpInfo Load(XmlNode xmlNode)
 {
     using (GeneralHelpInfo.tracer.TraceMethod())
     {
         GeneralHelpInfo generalHelpInfo = new GeneralHelpInfo(xmlNode);
         if (string.IsNullOrEmpty(generalHelpInfo.Name))
         {
             return((GeneralHelpInfo)null);
         }
         generalHelpInfo.AddCommonHelpProperties();
         return(generalHelpInfo);
     }
 }
        /// <summary>
        /// Create a GeneralHelpInfo object from an XmlNode.
        /// </summary>
        /// <param name="xmlNode">xmlNode that contains help info</param>
        /// <returns>GeneralHelpInfo object created</returns>
        internal static GeneralHelpInfo Load(XmlNode xmlNode)
        {
            GeneralHelpInfo generalHelpInfo = new GeneralHelpInfo(xmlNode);

            if (String.IsNullOrEmpty(generalHelpInfo.Name))
            {
                return(null);
            }

            generalHelpInfo.AddCommonHelpProperties();

            return(generalHelpInfo);
        }
Esempio n. 5
0
        /// <summary>
        /// Create a GeneralHelpInfo object from an XmlNode.
        /// </summary>
        /// <param name="xmlNode">xmlNode that contains help info</param>
        /// <returns>GeneralHelpInfo object created</returns>
        internal static GeneralHelpInfo Load(XmlNode xmlNode)
        {
            GeneralHelpInfo generalHelpInfo = new GeneralHelpInfo(xmlNode);

            if (String.IsNullOrEmpty(generalHelpInfo.Name))
                return null;

            generalHelpInfo.AddCommonHelpProperties();

            return generalHelpInfo;
        }
Esempio n. 6
0
 private void LoadHelpFile(string helpFile)
 {
     if (!string.IsNullOrEmpty(helpFile))
     {
         XmlDocument document;
         try
         {
             document = InternalDeserializer.LoadUnsafeXmlDocument(new FileInfo(helpFile), false, null);
         }
         catch (IOException exception)
         {
             ErrorRecord item = new ErrorRecord(exception, "HelpFileLoadFailure", ErrorCategory.OpenError, null)
             {
                 ErrorDetails = new ErrorDetails(Assembly.GetExecutingAssembly(), "HelpErrors", "HelpFileLoadFailure", new object[] { helpFile, exception.Message })
             };
             base.HelpSystem.LastErrors.Add(item);
             return;
         }
         catch (SecurityException exception2)
         {
             ErrorRecord record2 = new ErrorRecord(exception2, "HelpFileNotAccessible", ErrorCategory.OpenError, null)
             {
                 ErrorDetails = new ErrorDetails(Assembly.GetExecutingAssembly(), "HelpErrors", "HelpFileNotAccessible", new object[] { helpFile, exception2.Message })
             };
             base.HelpSystem.LastErrors.Add(record2);
             return;
         }
         catch (XmlException exception3)
         {
             ErrorRecord record3 = new ErrorRecord(exception3, "HelpFileNotValid", ErrorCategory.SyntaxError, null)
             {
                 ErrorDetails = new ErrorDetails(Assembly.GetExecutingAssembly(), "HelpErrors", "HelpFileNotValid", new object[] { helpFile, exception3.Message })
             };
             base.HelpSystem.LastErrors.Add(record3);
             return;
         }
         System.Xml.XmlNode node = null;
         if (document.HasChildNodes)
         {
             for (int i = 0; i < document.ChildNodes.Count; i++)
             {
                 System.Xml.XmlNode node2 = document.ChildNodes[i];
                 if ((node2.NodeType == XmlNodeType.Element) && (string.Compare(node2.Name, "conceptuals", StringComparison.OrdinalIgnoreCase) == 0))
                 {
                     node = node2;
                     break;
                 }
             }
         }
         if (node != null)
         {
             using (base.HelpSystem.Trace(helpFile))
             {
                 if (node.HasChildNodes)
                 {
                     for (int j = 0; j < node.ChildNodes.Count; j++)
                     {
                         System.Xml.XmlNode xmlNode = node.ChildNodes[j];
                         if ((xmlNode.NodeType == XmlNodeType.Element) && (string.Compare(xmlNode.Name, "conceptual", StringComparison.OrdinalIgnoreCase) == 0))
                         {
                             HelpInfo helpInfo = null;
                             helpInfo = GeneralHelpInfo.Load(xmlNode);
                             if (helpInfo != null)
                             {
                                 base.HelpSystem.TraceErrors(helpInfo.Errors);
                                 base.AddCache(helpInfo.Name, helpInfo);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// Load help file for HelpInfo objects. The HelpInfo objects will be
        /// put into help cache.
        /// </summary>
        /// <remarks>
        /// 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.
        /// </remarks>
        /// <param name="helpFile"></param>
        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);
                            }
                        }
                    }
                }
            }
        }
 private void LoadHelpFile(string helpFile)
 {
     using (GeneralHelpProvider.tracer.TraceMethod())
     {
         if (string.IsNullOrEmpty(helpFile))
         {
             return;
         }
         XmlDocument xmlDocument = new XmlDocument();
         try
         {
             xmlDocument.Load(helpFile);
         }
         catch (IOException ex)
         {
             this.HelpSystem.LastErrors.Add(new ErrorRecord((Exception)ex, "HelpFileLoadFailure", ErrorCategory.OpenError, (object)null)
             {
                 ErrorDetails = new ErrorDetails(Assembly.GetExecutingAssembly(), "HelpErrors", "HelpFileLoadFailure", new object[2]
                 {
                     (object)helpFile,
                     (object)ex.Message
                 })
             });
             return;
         }
         catch (SecurityException ex)
         {
             this.HelpSystem.LastErrors.Add(new ErrorRecord((Exception)ex, "HelpFileNotAccessible", ErrorCategory.OpenError, (object)null)
             {
                 ErrorDetails = new ErrorDetails(Assembly.GetExecutingAssembly(), "HelpErrors", "HelpFileNotAccessible", new object[2]
                 {
                     (object)helpFile,
                     (object)ex.Message
                 })
             });
             return;
         }
         catch (XmlException ex)
         {
             this.HelpSystem.LastErrors.Add(new ErrorRecord((Exception)ex, "HelpFileNotValid", ErrorCategory.SyntaxError, (object)null)
             {
                 ErrorDetails = new ErrorDetails(Assembly.GetExecutingAssembly(), "HelpErrors", "HelpFileNotValid", new object[2]
                 {
                     (object)helpFile,
                     (object)ex.Message
                 })
             });
             return;
         }
         XmlNode xmlNode = (XmlNode)null;
         if (xmlDocument.HasChildNodes)
         {
             for (int i = 0; i < xmlDocument.ChildNodes.Count; ++i)
             {
                 XmlNode childNode = xmlDocument.ChildNodes[i];
                 if (childNode.NodeType == XmlNodeType.Element && string.Compare(childNode.Name, "conceptuals", StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     xmlNode = childNode;
                     break;
                 }
             }
         }
         if (xmlNode == null)
         {
             return;
         }
         using (this.HelpSystem.Trace(helpFile))
         {
             if (!xmlNode.HasChildNodes)
             {
                 return;
             }
             for (int i = 0; i < xmlNode.ChildNodes.Count; ++i)
             {
                 XmlNode childNode = xmlNode.ChildNodes[i];
                 if (childNode.NodeType == XmlNodeType.Element && string.Compare(childNode.Name, "conceptual", StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     HelpInfo helpInfo = (HelpInfo)GeneralHelpInfo.Load(childNode);
                     if (helpInfo != null)
                     {
                         this.HelpSystem.TraceErrors(helpInfo.Errors);
                         this.AddCache(helpInfo.Name, helpInfo);
                     }
                 }
             }
         }
     }
 }