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); }
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); }