Browse Source

Some minor refactorings.

pull/107/head
Sebastian Stehle 9 years ago
parent
commit
36061ad094
  1. 2
      src/Squidex.Domain.Apps.Core/Contents/NamedContentData.cs
  2. 28
      src/Squidex.Infrastructure/Log/Internal/ConsoleLogProcessor.cs
  3. 2
      src/Squidex.Infrastructure/Log/Internal/FileLogProcessor.cs
  4. 4
      src/Squidex.Infrastructure/Timers/CompletionTimer.cs
  5. 2
      src/Squidex/Controllers/Api/Apps/AppClientsController.cs
  6. 2
      src/Squidex/Controllers/Api/Apps/AppContributorsController.cs
  7. 2
      src/Squidex/Controllers/Api/Apps/AppLanguagesController.cs
  8. 2
      src/Squidex/Controllers/Api/Apps/AppsController.cs
  9. 2
      src/Squidex/Controllers/Api/Assets/AssetContentController.cs
  10. 2
      src/Squidex/Controllers/Api/Assets/AssetsController.cs
  11. 2
      src/Squidex/Controllers/Api/History/HistoryController.cs
  12. 2
      src/Squidex/Controllers/Api/Languages/LanguagesController.cs
  13. 2
      src/Squidex/Controllers/Api/Ping/PingController.cs
  14. 2
      src/Squidex/Controllers/Api/Plans/AppPlansController.cs
  15. 2
      src/Squidex/Controllers/Api/Schemas/SchemaFieldsController.cs
  16. 2
      src/Squidex/Controllers/Api/Schemas/SchemasController.cs
  17. 2
      src/Squidex/Controllers/Api/Statistics/UsagesController.cs
  18. 2
      src/Squidex/Controllers/Api/UI/UIController.cs
  19. 2
      src/Squidex/Controllers/Api/Users/UsersController.cs
  20. 2
      src/Squidex/Controllers/Api/Webhooks/WebhooksController.cs
  21. 4
      src/Squidex/Controllers/ContentApi/ContentsController.cs
  22. 2
      src/Squidex/Controllers/UI/Profile/ProfileController.cs

2
src/Squidex.Domain.Apps.Core/Contents/NamedContentData.cs

@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Core.Contents
return result; return result;
} }
public NamedContentData ToApiModel(Schema schema, LanguagesConfig languagesConfig, IReadOnlyCollection<Language> languagePreferences = null, bool excludeHidden = true) public NamedContentData ToApiModel(Schema schema, LanguagesConfig languagesConfig, bool excludeHidden = true)
{ {
Guard.NotNull(schema, nameof(schema)); Guard.NotNull(schema, nameof(schema));
Guard.NotNull(languagesConfig, nameof(languagesConfig)); Guard.NotNull(languagesConfig, nameof(languagesConfig));

28
src/Squidex.Infrastructure/Log/Internal/ConsoleLogProcessor.cs

@ -13,7 +13,7 @@ using System.Threading.Tasks;
namespace Squidex.Infrastructure.Log.Internal namespace Squidex.Infrastructure.Log.Internal
{ {
public class ConsoleLogProcessor : IDisposable public class ConsoleLogProcessor : DisposableObjectBase
{ {
private readonly IConsole console; private readonly IConsole console;
private const int MaxQueuedMessages = 1024; private const int MaxQueuedMessages = 1024;
@ -54,19 +54,23 @@ namespace Squidex.Infrastructure.Log.Internal
processor.ProcessLogQueue(); processor.ProcessLogQueue();
} }
public void Dispose() protected override void DisposeObject(bool disposing)
{ {
messageQueue.CompleteAdding(); if (disposing)
try
{
outputTask.Wait(1500);
}
catch (TaskCanceledException)
{
}
catch (AggregateException ex) when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is TaskCanceledException)
{ {
messageQueue.CompleteAdding();
messageQueue.Dispose();
try
{
outputTask.Wait(1500);
}
catch (TaskCanceledException)
{
}
catch (AggregateException ex) when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is TaskCanceledException)
{
}
} }
} }
} }

2
src/Squidex.Infrastructure/Log/Internal/FileLogProcessor.cs

@ -83,7 +83,7 @@ namespace Squidex.Infrastructure.Log.Internal
if (i == Retries) if (i == Retries)
{ {
Console.WriteLine("Failed to write to log file '{0}': {1}", path, ex); Console.WriteLine($"Failed to write to log file '{path}': {ex}");
} }
} }
} }

4
src/Squidex.Infrastructure/Timers/CompletionTimer.cs

@ -30,7 +30,7 @@ namespace Squidex.Infrastructure.Timers
Guard.NotNull(callback, nameof(callback)); Guard.NotNull(callback, nameof(callback));
Guard.GreaterThan(delayInMs, 0, nameof(delayInMs)); Guard.GreaterThan(delayInMs, 0, nameof(delayInMs));
runTask = RunInternal(delayInMs, initialDelay, callback); runTask = RunInternalAsync(delayInMs, initialDelay, callback);
} }
public Task StopAsync() public Task StopAsync()
@ -50,7 +50,7 @@ namespace Squidex.Infrastructure.Timers
} }
} }
private async Task RunInternal(int delay, int initialDelay, Func<CancellationToken, Task> callback) private async Task RunInternalAsync(int delay, int initialDelay, Func<CancellationToken, Task> callback)
{ {
try try
{ {

2
src/Squidex/Controllers/Api/Apps/AppClientsController.cs

@ -25,7 +25,7 @@ namespace Squidex.Controllers.Api.Apps
[MustBeAppOwner] [MustBeAppOwner]
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Apps")] [SwaggerTag(nameof(Apps))]
public sealed class AppClientsController : ControllerBase public sealed class AppClientsController : ControllerBase
{ {
public AppClientsController(ICommandBus commandBus) public AppClientsController(ICommandBus commandBus)

2
src/Squidex/Controllers/Api/Apps/AppContributorsController.cs

@ -26,7 +26,7 @@ namespace Squidex.Controllers.Api.Apps
[MustBeAppOwner] [MustBeAppOwner]
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Apps")] [SwaggerTag(nameof(Apps))]
public sealed class AppContributorsController : ControllerBase public sealed class AppContributorsController : ControllerBase
{ {
private readonly IAppPlansProvider appPlansProvider; private readonly IAppPlansProvider appPlansProvider;

2
src/Squidex/Controllers/Api/Apps/AppLanguagesController.cs

@ -28,7 +28,7 @@ namespace Squidex.Controllers.Api.Apps
/// </summary> /// </summary>
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Apps")] [SwaggerTag(nameof(Apps))]
public sealed class AppLanguagesController : ControllerBase public sealed class AppLanguagesController : ControllerBase
{ {
public AppLanguagesController(ICommandBus commandBus) public AppLanguagesController(ICommandBus commandBus)

2
src/Squidex/Controllers/Api/Apps/AppsController.cs

@ -27,7 +27,7 @@ namespace Squidex.Controllers.Api.Apps
/// </summary> /// </summary>
[Authorize] [Authorize]
[ApiExceptionFilter] [ApiExceptionFilter]
[SwaggerTag("Apps")] [SwaggerTag(nameof(Apps))]
public sealed class AppsController : ControllerBase public sealed class AppsController : ControllerBase
{ {
private readonly IAppRepository appRepository; private readonly IAppRepository appRepository;

2
src/Squidex/Controllers/Api/Assets/AssetContentController.cs

@ -25,7 +25,7 @@ namespace Squidex.Controllers.Api.Assets
/// </summary> /// </summary>
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Assets")] [SwaggerTag(nameof(Assets))]
public sealed class AssetContentController : ControllerBase public sealed class AssetContentController : ControllerBase
{ {
private readonly IAssetStore assetStorage; private readonly IAssetStore assetStorage;

2
src/Squidex/Controllers/Api/Assets/AssetsController.cs

@ -35,7 +35,7 @@ namespace Squidex.Controllers.Api.Assets
/// </summary> /// </summary>
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Assets")] [SwaggerTag(nameof(Assets))]
public sealed class AssetsController : ControllerBase public sealed class AssetsController : ControllerBase
{ {
private readonly IAssetRepository assetRepository; private readonly IAssetRepository assetRepository;

2
src/Squidex/Controllers/Api/History/HistoryController.cs

@ -24,7 +24,7 @@ namespace Squidex.Controllers.Api.History
[MustBeAppEditor] [MustBeAppEditor]
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("History")] [SwaggerTag(nameof(History))]
public sealed class HistoryController : ControllerBase public sealed class HistoryController : ControllerBase
{ {
private readonly IHistoryEventRepository historyEventRepository; private readonly IHistoryEventRepository historyEventRepository;

2
src/Squidex/Controllers/Api/Languages/LanguagesController.cs

@ -21,7 +21,7 @@ namespace Squidex.Controllers.Api.Languages
/// </summary> /// </summary>
[Authorize] [Authorize]
[ApiExceptionFilter] [ApiExceptionFilter]
[SwaggerTag("Languages")] [SwaggerTag(nameof(Languages))]
public sealed class LanguagesController : Controller public sealed class LanguagesController : Controller
{ {
/// <summary> /// <summary>

2
src/Squidex/Controllers/Api/Ping/PingController.cs

@ -18,7 +18,7 @@ namespace Squidex.Controllers.Api.Ping
[MustBeAppReader] [MustBeAppReader]
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Ping")] [SwaggerTag(nameof(Ping))]
public sealed class PingController : Controller public sealed class PingController : Controller
{ {
/// <summary> /// <summary>

2
src/Squidex/Controllers/Api/Plans/AppPlansController.cs

@ -27,7 +27,7 @@ namespace Squidex.Controllers.Api.Plans
/// </summary> /// </summary>
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Plans")] [SwaggerTag(nameof(Plans))]
public sealed class AppPlansController : ControllerBase public sealed class AppPlansController : ControllerBase
{ {
private readonly IAppPlansProvider appPlansProvider; private readonly IAppPlansProvider appPlansProvider;

2
src/Squidex/Controllers/Api/Schemas/SchemaFieldsController.cs

@ -22,7 +22,7 @@ namespace Squidex.Controllers.Api.Schemas
[MustBeAppDeveloper] [MustBeAppDeveloper]
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Schemas")] [SwaggerTag(nameof(Schemas))]
public sealed class SchemaFieldsController : ControllerBase public sealed class SchemaFieldsController : ControllerBase
{ {
public SchemaFieldsController(ICommandBus commandBus) public SchemaFieldsController(ICommandBus commandBus)

2
src/Squidex/Controllers/Api/Schemas/SchemasController.cs

@ -29,7 +29,7 @@ namespace Squidex.Controllers.Api.Schemas
/// </summary> /// </summary>
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Schemas")] [SwaggerTag(nameof(Schemas))]
public sealed class SchemasController : ControllerBase public sealed class SchemasController : ControllerBase
{ {
private readonly ISchemaRepository schemaRepository; private readonly ISchemaRepository schemaRepository;

2
src/Squidex/Controllers/Api/Statistics/UsagesController.cs

@ -26,7 +26,7 @@ namespace Squidex.Controllers.Api.Statistics
[MustBeAppEditor] [MustBeAppEditor]
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Statistics")] [SwaggerTag(nameof(Statistics))]
public sealed class UsagesController : ControllerBase public sealed class UsagesController : ControllerBase
{ {
private readonly IUsageTracker usageTracker; private readonly IUsageTracker usageTracker;

2
src/Squidex/Controllers/Api/UI/UIController.cs

@ -21,7 +21,7 @@ namespace Squidex.Controllers.Api.UI
/// Manages ui settings and configs. /// Manages ui settings and configs.
/// </summary> /// </summary>
[ApiExceptionFilter] [ApiExceptionFilter]
[SwaggerTag("UI")] [SwaggerTag(nameof(UI))]
public sealed class UIController : Controller public sealed class UIController : Controller
{ {
private readonly MyUIOptions uiOptions; private readonly MyUIOptions uiOptions;

2
src/Squidex/Controllers/Api/Users/UsersController.cs

@ -29,7 +29,7 @@ namespace Squidex.Controllers.Api.Users
/// Readonly API to retrieve information about squidex users. /// Readonly API to retrieve information about squidex users.
/// </summary> /// </summary>
[ApiExceptionFilter] [ApiExceptionFilter]
[SwaggerTag("Users")] [SwaggerTag(nameof(Users))]
public sealed class UsersController : Controller public sealed class UsersController : Controller
{ {
private static readonly byte[] AvatarBytes; private static readonly byte[] AvatarBytes;

2
src/Squidex/Controllers/Api/Webhooks/WebhooksController.cs

@ -27,7 +27,7 @@ namespace Squidex.Controllers.Api.Webhooks
/// </summary> /// </summary>
[ApiExceptionFilter] [ApiExceptionFilter]
[AppApi] [AppApi]
[SwaggerTag("Webhooks")] [SwaggerTag(nameof(Webhooks))]
[MustBeAppDeveloper] [MustBeAppDeveloper]
public sealed class WebhooksController : ControllerBase public sealed class WebhooksController : ControllerBase
{ {

4
src/Squidex/Controllers/ContentApi/ContentsController.cs

@ -96,7 +96,7 @@ namespace Squidex.Controllers.ContentApi
if (item.Data != null) if (item.Data != null)
{ {
itemModel.Data = item.Data.ToApiModel(contents.Schema.SchemaDef, App.LanguagesConfig, null, !isFrontendClient); itemModel.Data = item.Data.ToApiModel(contents.Schema.SchemaDef, App.LanguagesConfig, !isFrontendClient);
} }
return itemModel; return itemModel;
@ -120,7 +120,7 @@ namespace Squidex.Controllers.ContentApi
{ {
var isFrontendClient = User.IsFrontendClient(); var isFrontendClient = User.IsFrontendClient();
response.Data = content.Content.Data.ToApiModel(content.Schema.SchemaDef, App.LanguagesConfig, null, !isFrontendClient); response.Data = content.Content.Data.ToApiModel(content.Schema.SchemaDef, App.LanguagesConfig, !isFrontendClient);
} }
Response.Headers["ETag"] = new StringValues(content.Content.Version.ToString()); Response.Headers["ETag"] = new StringValues(content.Content.Version.ToString());

2
src/Squidex/Controllers/UI/Profile/ProfileController.cs

@ -76,7 +76,7 @@ namespace Squidex.Controllers.UI.Profile
[HttpGet] [HttpGet]
[Route("/account/profile/login-add-callback/")] [Route("/account/profile/login-add-callback/")]
public Task<IActionResult> AddLoginCallback(string remoteError = null) public Task<IActionResult> AddLoginCallback()
{ {
return MakeChangeAsync(async user => return MakeChangeAsync(async user =>
{ {

Loading…
Cancel
Save