43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using xCommons.Extensions;
|
|
using xModels.Dtos;
|
|
|
|
namespace xModels.Extensions
|
|
{
|
|
public static class XModelExtensions
|
|
{
|
|
/// <summary>
|
|
/// Check to XDevice instance to be same or not
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="dest"></param>
|
|
/// <returns></returns>
|
|
public static bool IsSameAs(this XDeviceDto source, XDeviceDto dest)
|
|
{
|
|
//
|
|
if (source.IsNull() ||
|
|
dest.IsNull())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//
|
|
var isSame = source.Os.ToNormalString() == dest.Os.ToNormalString() &&
|
|
source.OsVersion.ToNormalString() == dest.OsVersion.ToNormalString() &&
|
|
source.Browser.ToNormalString() == dest.Browser.ToNormalString() &&
|
|
source.UserAgent.ToNormalString() == dest.UserAgent.ToNormalString() &&
|
|
source.DeviceType == dest.DeviceType;
|
|
|
|
//
|
|
return isSame;
|
|
}
|
|
|
|
public static IEnumerable<T> AsEnumerable<T, TKey, TIndex>(
|
|
this IEnumerable<XBaseIndexedDto<T, TKey, TIndex>> source
|
|
)
|
|
{
|
|
return source.Select(i => i.Item);
|
|
}
|
|
}
|
|
} |