wabbajack/Wabbajack.BuildServer/Extensions.cs

29 lines
827 B
C#
Raw Normal View History

2020-01-08 04:41:50 +00:00
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
2020-01-09 04:42:25 +00:00
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Logging;
2020-01-08 04:41:50 +00:00
using MongoDB.Driver;
using MongoDB.Driver.Linq;
2020-01-09 04:42:25 +00:00
using Wabbajack.Common;
2020-01-08 04:41:50 +00:00
namespace Wabbajack.BuildServer
{
public static class Extensions
{
public static async Task<T> FindOneAsync<T>(this IMongoCollection<T> coll, Expression<Func<T, bool>> expr)
{
return (await coll.AsQueryable().Where(expr).Take(1).ToListAsync()).FirstOrDefault();
}
2020-01-09 04:42:25 +00:00
public static void UseJobManager(this IApplicationBuilder b)
{
var manager = (JobManager)b.ApplicationServices.GetService(typeof(JobManager));
var tsk = manager.JobScheduler();
manager.StartJobRunners();
}
2020-01-08 04:41:50 +00:00
}
}