Example #1
0
        private List <ISESnippet> LoadDiskSnippets(string folderPath, bool recurseSubFolders)
        {
            List <ISESnippet> list = new List <ISESnippet>();

            string[] array = null;
            try
            {
                array = Directory.GetFiles(folderPath, "*.snippets.ps1xml", recurseSubFolders ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
            }
            catch (ArgumentException)
            {
                List <ISESnippet> result = list;
                return(result);
            }
            catch (IOException)
            {
                List <ISESnippet> result = list;
                return(result);
            }
            catch (UnauthorizedAccessException)
            {
                List <ISESnippet> result = list;
                return(result);
            }
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text  = array2[i];
                string text2 = WPFHelper.ReadIfRunnable(text, this.authManager);
                if (text2 != null)
                {
                    StringReader textReader = new StringReader(text2);
                    try
                    {
                        XPathDocument docNav = new XPathDocument(textReader);
                        ISESnippetCollection.ParseAddToList(text, docNav, list);
                    }
                    catch (XmlException)
                    {
                    }
                    catch (ArgumentException)
                    {
                    }
                }
            }
            return(list);
        }
Example #2
0
        private List <ISESnippet> LoadOneDiskSnippetXmlFile(string fullFilePathName)
        {
            if (!fullFilePathName.EndsWith(".snippets.ps1xml", StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException(Strings.Format(GuiStrings.SnippetWrongExtensionFormat, new object[]
                {
                    ".snippets.ps1xml"
                }));
            }
            List <ISESnippet> result;

            try
            {
                string            s          = WPFHelper.ReadIfRunnable(fullFilePathName, this.authManager, true);
                StringReader      textReader = new StringReader(s);
                XPathDocument     docNav     = new XPathDocument(textReader);
                List <ISESnippet> list       = new List <ISESnippet>();
                ISESnippetCollection.ParseAddToList(fullFilePathName, docNav, list, true);
                result = list;
            }
            catch (XmlException innerException)
            {
                throw new InvalidOperationException(Strings.Format(GuiStrings.SnippetBadXmlFormat, new object[]
                {
                    fullFilePathName
                }), innerException);
            }
            catch (InvalidOperationException)
            {
                throw;
            }
            catch (Exception innerException2)
            {
                throw new InvalidOperationException(Strings.Format(GuiStrings.SnippetLoadFileMissing, new object[]
                {
                    fullFilePathName
                }), innerException2);
            }
            return(result);
        }
Example #3
0
 private static int ParseAddToList(string filename, XPathDocument docNav, List <ISESnippet> loadDestination)
 {
     return(ISESnippetCollection.ParseAddToList(filename, docNav, loadDestination, false));
 }
Example #4
0
 internal static int InternalAccessToParseAddToList(string filename, XPathDocument docNav, List <ISESnippet> loadDestination)
 {
     return(ISESnippetCollection.ParseAddToList(filename, docNav, loadDestination));
 }