using EgwCoreLib.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WebWindowComplex.DTO
{
///
/// Dati specifici ricevuto dal chiamante x display e calcoli
///
public class LivePayload
{
#region Public Properties
///
/// JWD Corrente
///
public string CurrJwd { get; set; } = string.Empty;
///
/// Preview SVG
///
public string SvgPreview { get; set; } = string.Empty;
///
/// Dizionario Shape da verifica JWD
///
public Dictionary DictShape { get; set; } = new Dictionary();
///
/// Dizionario XML opzioni HW da verifica JWD x GroupId
///
public Dictionary DictOptionsXml { get; set; } = new Dictionary();
///
/// Lista profili Element
///
public List ProfElementList { get; set; } = new List();
#endregion Public Properties
#region Public Methods
///
/// Override metodo di equality
///
///
///
public override bool Equals(object obj)
{
if (!(obj is LivePayload item))
return false;
if (CurrJwd != item.CurrJwd)
return false;
if (SvgPreview != item.SvgPreview)
return false;
if (!DictUtils.DictAreEqual(DictOptionsXml, item.DictOptionsXml))
return false;
if (!DictUtils.DictAreEqual(DictShape, item.DictShape))
return false;
if (ProfElementList.Count != item.ProfElementList.Count || !ProfElementList.OrderBy(x => x.GroupId).SequenceEqual(item.ProfElementList.OrderBy(x => x.GroupId)))
return false;
return true;
}
///
/// Metodo di equality limitato al controllo del JWD
///
///
///
public bool JwdEqual(object obj)
{
if ((obj == null))
return false;
if (!(obj is LivePayload item))
return false;
if (CurrJwd != item.CurrJwd)
return false;
return true;
}
///
/// Override hash method
///
///
public override int GetHashCode()
{
return base.GetHashCode();
}
///
/// Verifica di validità del Payload (solo jwd)
///
///
public bool IsValid()
{
bool jwdOK = !string.IsNullOrEmpty(CurrJwd);
return jwdOK;
}
#endregion Public Methods
}
}