예제 #1
0
 internal static FaqHelpInfo Load(System.Xml.XmlNode xmlNode)
 {
     FaqHelpInfo info = new FaqHelpInfo(xmlNode);
     if (string.IsNullOrEmpty(info.Name))
     {
         return null;
     }
     info.AddCommonHelpProperties();
     return info;
 }
예제 #2
0
        internal static FaqHelpInfo Load(System.Xml.XmlNode xmlNode)
        {
            FaqHelpInfo info = new FaqHelpInfo(xmlNode);

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

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

            faqHelpInfo.AddCommonHelpProperties();

            return(faqHelpInfo);
        }
예제 #5
0
 private void LoadFaqDiv(XmlNode xmlNode)
 {
     if (xmlNode == null)
     {
         return;
     }
     for (int i = 0; i < xmlNode.ChildNodes.Count; ++i)
     {
         XmlNode childNode = xmlNode.ChildNodes[i];
         if (childNode.NodeType == XmlNodeType.Element && string.Compare(childNode.Name, "faqEntry", StringComparison.OrdinalIgnoreCase) == 0)
         {
             HelpInfo helpInfo = (HelpInfo)FaqHelpInfo.Load(childNode);
             if (helpInfo != null)
             {
                 this.HelpSystem.TraceErrors(helpInfo.Errors);
                 this.AddCache(helpInfo.Name, helpInfo);
             }
         }
     }
 }
예제 #6
0
 private void LoadFaqDiv(System.Xml.XmlNode xmlNode)
 {
     if (xmlNode != null)
     {
         for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
         {
             System.Xml.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)
                 {
                     base.HelpSystem.TraceErrors(helpInfo.Errors);
                     base.AddCache(helpInfo.Name, helpInfo);
                 }
             }
         }
     }
 }
예제 #7
0
 private void LoadHelpFile(string helpFile)
 {
     using (FaqHelpProvider.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, "faq", 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, "faqEntry", StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     HelpInfo helpInfo = (HelpInfo)FaqHelpInfo.Load(childNode);
                     if (helpInfo != null)
                     {
                         this.HelpSystem.TraceErrors(helpInfo.Errors);
                         this.AddCache(helpInfo.Name, helpInfo);
                     }
                 }
                 else if (childNode.NodeType == XmlNodeType.Element && string.Compare(childNode.Name, "faqDiv", StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     this.LoadFaqDiv(childNode);
                 }
             }
         }
     }
 }
예제 #8
0
        /// <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(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);
                        }
                    }
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Create a FaqHelpInfo object from an XmlNode.
        /// </summary>
        /// <param name="xmlNode">xmlNode that contains help info</param>
        /// <returns>FaqHelpInfo object created</returns>
        internal static FaqHelpInfo Load(XmlNode xmlNode)
        {
            FaqHelpInfo faqHelpInfo = new FaqHelpInfo(xmlNode);

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

            faqHelpInfo.AddCommonHelpProperties();

            return faqHelpInfo;
        }
예제 #10
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, "faq", 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, "faqEntry", StringComparison.OrdinalIgnoreCase) == 0))
                         {
                             HelpInfo helpInfo = null;
                             helpInfo = FaqHelpInfo.Load(xmlNode);
                             if (helpInfo != null)
                             {
                                 base.HelpSystem.TraceErrors(helpInfo.Errors);
                                 base.AddCache(helpInfo.Name, helpInfo);
                             }
                         }
                         else if ((xmlNode.NodeType == XmlNodeType.Element) && (string.Compare(xmlNode.Name, "faqDiv", StringComparison.OrdinalIgnoreCase) == 0))
                         {
                             this.LoadFaqDiv(xmlNode);
                         }
                     }
                 }
             }
         }
     }
 }