DocSpace-client/common/services/ASC.Feed.Aggregator/Configuration/FeedSettings.cs

47 lines
1.2 KiB
C#
Raw Normal View History

2020-06-03 14:53:58 +00:00
using System;
using ASC.Common.Utils;
using Microsoft.Extensions.Configuration;
namespace ASC.Feed.Configuration
{
public class FeedSettings
{
public string ServerRoot { get; set; }
public TimeSpan AggregatePeriod { get; set; }
public TimeSpan AggregateInterval { get; set; }
public TimeSpan RemovePeriod { get; set; }
2020-06-04 10:54:13 +00:00
public static FeedSettings GetInstance(IConfiguration configuration)
{
var result = configuration.GetSetting<FeedSettings>("feed");
if (string.IsNullOrEmpty(result.ServerRoot))
{
result.ServerRoot = "http://*/";
}
if (result.AggregatePeriod == TimeSpan.Zero)
{
result.AggregatePeriod = TimeSpan.FromMinutes(5);
}
if (result.AggregateInterval == TimeSpan.Zero)
{
result.AggregateInterval = TimeSpan.FromDays(14);
}
if (result.RemovePeriod == TimeSpan.Zero)
{
result.RemovePeriod = TimeSpan.FromDays(1);
}
return result;
}
2020-06-03 14:53:58 +00:00
}
}