31 lines
918 B
C#
31 lines
918 B
C#
using LANCommander.Data;
|
|
using LANCommander.Data.Models;
|
|
using LANCommander.Models;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
namespace LANCommander.Services
|
|
{
|
|
public class ScriptService : BaseDatabaseService<Script>
|
|
{
|
|
public ScriptService(DatabaseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
|
{
|
|
}
|
|
|
|
public static IEnumerable<Snippet> GetSnippets()
|
|
{
|
|
var files = Directory.GetFiles(@"Snippets", "*.ps1", SearchOption.AllDirectories);
|
|
|
|
return files.Select(f =>
|
|
{
|
|
var split = f.Split('\\');
|
|
|
|
return new Snippet()
|
|
{
|
|
Name = Path.GetFileNameWithoutExtension(f),
|
|
Group = split[1],
|
|
Content = File.ReadAllText(f)
|
|
};
|
|
});
|
|
}
|
|
}
|
|
}
|