mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
resharper optimizations and annotations
This commit is contained in:
parent
30d98d17c9
commit
3734925298
11 changed files with 30 additions and 8 deletions
|
|
@ -15,6 +15,7 @@
|
|||
<Folder Include="wwwroot\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="10.4.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace FilterLists.Api.DependencyInjection.Extensions
|
|||
{
|
||||
public static class ConfigureServicesCollection
|
||||
{
|
||||
public static IServiceCollection AddFilterListsApi(this IServiceCollection services)
|
||||
public static void AddFilterListsApi(this IServiceCollection services)
|
||||
{
|
||||
services.AddMvc()
|
||||
.AddJsonOptions(options =>
|
||||
|
|
@ -13,7 +13,6 @@ public static IServiceCollection AddFilterListsApi(this IServiceCollection servi
|
|||
//TODO: determine why null values still get returned
|
||||
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
|
||||
});
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
using System.IO;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace FilterLists.Api
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class Program
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using FilterLists.Api.DependencyInjection.Extensions;
|
||||
using FilterLists.Data.DependencyInjection.Extensions;
|
||||
using FilterLists.Services.DependencyInjection.Extensions;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -25,8 +26,9 @@ public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|||
loggerFactory.AddDebug();
|
||||
}
|
||||
|
||||
public IConfigurationRoot Configuration { get; }
|
||||
private IConfigurationRoot Configuration { get; }
|
||||
|
||||
[UsedImplicitly]
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddFilterListsRepositories(Configuration);
|
||||
|
|
@ -34,6 +36,7 @@ public void ConfigureServices(IServiceCollection services)
|
|||
services.AddFilterListsApi();
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseMvc();
|
||||
|
|
|
|||
|
|
@ -11,15 +11,13 @@ namespace FilterLists.Data.DependencyInjection.Extensions
|
|||
{
|
||||
public static class ConfigureServicesCollection
|
||||
{
|
||||
public static IServiceCollection AddFilterListsRepositories(this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
public static void AddFilterListsRepositories(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddSingleton(c => configuration);
|
||||
services.AddEntityFramework()
|
||||
.AddDbContext<FilterListsDbContext>(options =>
|
||||
options.UseMySQL(configuration.GetConnectionString("FilterListsConnection")));
|
||||
services.TryAddScoped<IListRepository, ListRepository>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="10.4.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
|
||||
<PackageReference Include="SapientGuardian.EntityFrameworkCore.MySql" Version="7.1.23" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Data.Models
|
||||
{
|
||||
|
|
@ -11,15 +12,18 @@ public abstract class BaseEntity
|
|||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[UsedImplicitly]
|
||||
public long Id { get; set; }
|
||||
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
//TODO: Implement http://stackoverflow.com/a/38102266/2343739 so DefaultValue takes effect in db automatically
|
||||
//For now, manually execute on new tables: InitializeNewTableBaseEntityDefaults.sql
|
||||
[DefaultValue("CURRENT_TIMESTAMP")]
|
||||
[UsedImplicitly]
|
||||
public DateTime AddedDateUtc { get; set; }
|
||||
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
[UsedImplicitly]
|
||||
public DateTime? ModifiedDateUtc { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +1,52 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Data.Models
|
||||
{
|
||||
public class List : BaseEntity
|
||||
{
|
||||
[MaxLength(1022)]
|
||||
[UsedImplicitly]
|
||||
public string Description { get; set; }
|
||||
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
[UsedImplicitly]
|
||||
public string DescriptionSourceUrl { get; set; }
|
||||
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
[UsedImplicitly]
|
||||
public string DonateUrl { get; set; }
|
||||
|
||||
[MaxLength(126)]
|
||||
[MinLength(7)]
|
||||
[UsedImplicitly]
|
||||
public string Email { get; set; }
|
||||
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
[UsedImplicitly]
|
||||
public string ForumUrl { get; set; }
|
||||
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
[UsedImplicitly]
|
||||
public string HomeUrl { get; set; }
|
||||
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
[UsedImplicitly]
|
||||
public string IssuesUrl { get; set; }
|
||||
|
||||
[MaxLength(126)]
|
||||
[UsedImplicitly]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
[UsedImplicitly]
|
||||
public string ViewUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -3,9 +3,11 @@
|
|||
using FilterLists.Data.Contexts;
|
||||
using FilterLists.Data.Models;
|
||||
using FilterLists.Data.Repositories.Contracts;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Data.Repositories.Implementations
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListRepository : IListRepository
|
||||
{
|
||||
private readonly FilterListsDbContext _filterListsDbContext;
|
||||
|
|
|
|||
|
|
@ -7,10 +7,9 @@ namespace FilterLists.Services.DependencyInjection.Extensions
|
|||
{
|
||||
public static class ConfigureServicesCollection
|
||||
{
|
||||
public static IServiceCollection AddFilterListsServices(this IServiceCollection services)
|
||||
public static void AddFilterListsServices(this IServiceCollection services)
|
||||
{
|
||||
services.TryAddScoped<IListService, ListService>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,11 @@
|
|||
using FilterLists.Data.Models;
|
||||
using FilterLists.Data.Repositories.Contracts;
|
||||
using FilterLists.Services.Contracts;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.Implementations
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListService : IListService
|
||||
{
|
||||
private readonly IListRepository _listRepository;
|
||||
|
|
|
|||
Loading…
Reference in a new issue