mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-01-12 10:22:04 +01:00
- Samsung .zip loader: auto-detect UTF-16 endianness and allow to change encoding after loading to UTF-16 LE/BE (some files use Little Endian format and show chinese characters when loaded with the default Big Endian format) - Customized column order is now preserved across file formats and input sources - Note about LG WebOS 5 files (e.g. CX series): It is still unclear what exact firmware version and conditions are needed to properly import a channel list. Users reported about varying success of an import, reaching from not possible at all, only after a factory reset, importing the same list twice or working just fine. The problems is not related to ChanSort, as it can be reproduced by exporting a list to USB, swapping channels in the TV's menu and trying to loading the previously exported list back. The TV may keep the swapped channels and show inconsistencies between the channel list in the settings menu and the EPG. - upgrade to DevExpress 20.1.4
61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ChanSort
|
|
{
|
|
/// <summary>
|
|
/// The DelegateComparer class is used as an adapter to use a simple delegate method in places
|
|
/// where an IComparer interface is expected
|
|
/// </summary>
|
|
public class DelegateComparer : IComparer
|
|
{
|
|
private readonly Func<object,object,int> handler;
|
|
private readonly bool reverse;
|
|
|
|
|
|
/// <summary>
|
|
/// Create a new DelegateComparer
|
|
/// </summary>
|
|
/// <param name="handler">The method used to compare two objects</param>
|
|
public DelegateComparer(Func<object, object, int> handler)
|
|
{
|
|
this.handler = handler;
|
|
}
|
|
|
|
public DelegateComparer(Func<object, object, int> handler, bool reverse) : this(handler)
|
|
{
|
|
this.reverse=reverse;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Compares two objects by delegating the request to the handler-delegate
|
|
/// </summary>
|
|
public int Compare(object o1, object o2)
|
|
{
|
|
int r=this.handler(o1, o2);
|
|
return this.reverse ? -r : +r;
|
|
}
|
|
}
|
|
|
|
public class DelegateComparer<T> : IComparer<T>, IComparer
|
|
{
|
|
private readonly Func<T, T, int> handler;
|
|
private readonly bool reverse;
|
|
|
|
public DelegateComparer(Func<T,T,int> handler, bool reverse = false)
|
|
{
|
|
this.handler = handler;
|
|
this.reverse = reverse;
|
|
}
|
|
|
|
public int Compare(T x, T y)
|
|
{
|
|
var r = handler(x, y);
|
|
return reverse ? -r : r;
|
|
}
|
|
|
|
int IComparer.Compare(object x, object y) => this.Compare((T) x, (T) y);
|
|
}
|
|
}
|