- Snippet Manager is .NET library that enables to work with Visual Studio snippets.
- The library is distributed as
- .NET Framework 4.0
- .NET Standard 1.3
- Portable Class Library (Profile 259)
- .NET Framework 4.5
- Windows 8.0
- Windows Phone 8.1
- Windows Phone 8.0
- .NET Standard 1.0
using Pihrtsoft.Snippets;
using Pihrtsoft.Snippets.Comparers;
using Pihrtsfot.Snippets.Validations;
public static IEnumerable<Snippet> LoadSnippets(string directoryPath)
{
return SnippetSerializer.DeserializeFiles(directoryPath, SearchOption.AllDirectories)
.SelectMany(f => f.Snippets));
}
public static IEnumerable<SnippetValidationResult> ValidateSnippets(IEnumerable<Snippet> snippets)
{
SnippetValidator validator = SnippetValidator.CreateDefaultValidator();
foreach (Snippet snippet in snippets)
{
foreach (SnippetValidationResult result in validator.Validate(snippet))
yield return result;
}
}
public static IEnumerable<IGrouping<string, Snippet>> FindDuplicateShortcuts(IEnumerable<Snippet> snippets)
{
foreach (IGrouping<string, Snippet> grouping in SnippetUtility.FindDuplicateShortcuts(snippets))
yield return grouping;
}
public static IEnumerable<Snippet> GetChangedSnippets(IEnumerable<Snippet> snippets)
{
var equalityComparer = new SnippetDeepEqualityComparer();
foreach (Snippet snippet in snippets)
{
var clone = (Snippet)snippet.Clone();
clone.Literals.Sort();
clone.Keywords.Sort();
clone.Namespaces.Sort();
// do some other processing
if (!equalityComparer.Equals(snippet, clone))
yield return clone;
}
}