sharee.bike-App/TINKLib/ViewModel/Map/GroupFilterMapPage.cs

68 lines
2.5 KiB
C#
Raw Normal View History

2021-05-13 20:03:07 +02:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TINK.Model;
using TINK.Model.Connector.Filter;
namespace TINK.ViewModel.Map
{
2022-09-06 16:08:19 +02:00
public class GroupFilterMapPage : IGroupFilterMapPage
{
public GroupFilterMapPage(IDictionary<string, FilterState> filterDictionary = null)
{
FilterDictionary = filterDictionary ?? new Dictionary<string, FilterState>();
Filter = filterDictionary != null
? (IGroupFilter)new IntersectGroupFilter(FilterDictionary.Where(x => x.Value == FilterState.On).Select(x => x.Key))
: new NullGroupFilter();
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
private IGroupFilter Filter { get; }
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Gets the active filters.</summary>
/// <param name="filterCollection">Filter collection to get group from.</param>
/// <returns>List of active filters.</returns>
/// <todo>Rename to ToFilterList</todo>
public IList<string> GetGroup()
{
return this.Where(x => x.Value == FilterState.On).Select(x => x.Key).ToList();
}
2021-11-07 21:28:13 +01:00
2022-09-06 16:08:19 +02:00
/// <summary> Performs filtering on response-group. </summary>
public IEnumerable<string> DoFilter(IEnumerable<string> filter = null) => Filter.DoFilter(filter);
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
private IDictionary<string, FilterState> FilterDictionary { get; }
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public FilterState this[string key] { get => FilterDictionary[key]; set => FilterDictionary[key] = value; }
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public ICollection<string> Keys => FilterDictionary.Keys;
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public ICollection<FilterState> Values => FilterDictionary.Values;
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public int Count => FilterDictionary.Count;
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public bool IsReadOnly => true;
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public void Add(string key, FilterState value) => throw new System.NotImplementedException();
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
public void Add(KeyValuePair<string, FilterState> item) => throw new System.NotImplementedException();
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public void Clear() => throw new System.NotImplementedException();
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public bool Contains(KeyValuePair<string, FilterState> item) => FilterDictionary.Contains(item);
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public bool ContainsKey(string key) => FilterDictionary.ContainsKey(key);
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public void CopyTo(KeyValuePair<string, FilterState>[] array, int arrayIndex) => FilterDictionary.CopyTo(array, arrayIndex);
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public IEnumerator<KeyValuePair<string, FilterState>> GetEnumerator() => FilterDictionary.GetEnumerator();
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public bool Remove(string key) => throw new System.NotImplementedException();
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public bool Remove(KeyValuePair<string, FilterState> item) => throw new System.NotImplementedException();
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
public bool TryGetValue(string key, out FilterState value) => FilterDictionary.TryGetValue(key, out value);
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
IEnumerator IEnumerable.GetEnumerator() => FilterDictionary.GetEnumerator();
}
2021-05-13 20:03:07 +02:00
}