57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using DTS.Common.Enums.GroupTemplates;
|
|||
|
|
|
|||
|
|
namespace DTS.Common.Interface.GroupTemplate
|
|||
|
|
{
|
|||
|
|
public interface IGroupTemplateChannel
|
|||
|
|
{
|
|||
|
|
bool Custom { get; }
|
|||
|
|
int DisplayOrder { get; set; }
|
|||
|
|
string NameOfTheChannel { get; set; }
|
|||
|
|
string Name { get; }
|
|||
|
|
bool Required { get; set; }
|
|||
|
|
bool Filter(string term);
|
|||
|
|
string ISOCode { get; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class GroupTemplateChannelComparer : IComparer<IGroupTemplateChannel>
|
|||
|
|
{
|
|||
|
|
public GroupTemplateChannelFields SortField { get; set; }
|
|||
|
|
public bool Ascending { get; set; }
|
|||
|
|
public int Compare(IGroupTemplateChannel x, IGroupTemplateChannel y)
|
|||
|
|
{
|
|||
|
|
if (x == y)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
if (null == x)
|
|||
|
|
{
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
if (null == y)
|
|||
|
|
{
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
var left = x;
|
|||
|
|
var right = y;
|
|||
|
|
if (!Ascending) { left = y; right = x; }
|
|||
|
|
switch (SortField)
|
|||
|
|
{
|
|||
|
|
case GroupTemplateChannelFields.Required:
|
|||
|
|
return left.Required.CompareTo(right.Required);
|
|||
|
|
case GroupTemplateChannelFields.Name:
|
|||
|
|
return String.Compare(left.Name, right.Name, StringComparison.Ordinal);
|
|||
|
|
case GroupTemplateChannelFields.ISOCode:
|
|||
|
|
return String.Compare(left.ISOCode, right.ISOCode, StringComparison.Ordinal);
|
|||
|
|
case GroupTemplateChannelFields.Custom:
|
|||
|
|
return left.Custom.CompareTo(right.Custom);
|
|||
|
|
case GroupTemplateChannelFields.DisplayOrder:
|
|||
|
|
return left.DisplayOrder.CompareTo(right.DisplayOrder);
|
|||
|
|
default:
|
|||
|
|
throw new ArgumentOutOfRangeException();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|