Created DataFilterOptions.

pull/179/head
Halil İbrahim Kalkan 7 years ago
parent adf83d4e25
commit f5fd28d413

@ -3,6 +3,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Data
@ -59,11 +60,14 @@ namespace Volo.Abp.Data
}
}
private readonly AsyncLocal<DataFilterItem> _filter;
private readonly DataFilterOptions _options;
public DataFilter()
private readonly AsyncLocal<DataFilterState> _filter;
public DataFilter(IOptions<DataFilterOptions> options)
{
_filter = new AsyncLocal<DataFilterItem>();
_options = options.Value;
_filter = new AsyncLocal<DataFilterState>();
}
public IDisposable Enable()
@ -97,7 +101,7 @@ namespace Volo.Abp.Data
return;
}
_filter.Value = new DataFilterItem { IsEnabled = true }; //TODO: Get from default setting!
_filter.Value = _options.DefaultStates.GetOrDefault(typeof(TFilter))?.Clone() ?? new DataFilterState(true);
}
}
}

@ -1,7 +0,0 @@
namespace Volo.Abp.Data
{
internal class DataFilterItem
{
public bool IsEnabled { get; set; }
}
}

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace Volo.Abp.Data
{
public class DataFilterOptions
{
public Dictionary<Type, DataFilterState> DefaultStates { get; }
public DataFilterOptions()
{
DefaultStates = new Dictionary<Type, DataFilterState>();
}
}
}

@ -0,0 +1,17 @@
namespace Volo.Abp.Data
{
public class DataFilterState
{
public bool IsEnabled { get; set; }
public DataFilterState(bool isEnabled)
{
IsEnabled = isEnabled;
}
public DataFilterState Clone()
{
return new DataFilterState(IsEnabled);
}
}
}
Loading…
Cancel
Save