Exemplo n.º 1
0
 public bool Equals(ThreatModel b)
 {
     if (Name != b.Name)
     {
         return(false);
     }
     if (Description != b.Description)
     {
         return(false);
     }
     if (ThreatSource != b.ThreatSource)
     {
         return(false);
     }
     if (Target != b.Target)
     {
         return(false);
     }
     if (!Breaches.All(x => b.Breaches.Contains(x)) || !b.Breaches.All(x => Breaches.Contains(x)))
     {
         return(false);
     }
     if (UpdateDate != b.UpdateDate)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        public async void GetBreaches(string accountName, bool async)
        {
            List <Breach> breaches;

            if (async)
            {
                breaches = await PwndAPI.GetBreachesAsync(accountName).ConfigureAwait(false);
            }
            else
            {
                breaches = PwndAPI.GetBreaches(accountName);
            }

            Breaches.Clear();

            foreach (Breach breach in breaches)
            {
                Breaches.Add(breach);
            }
        }
        /// <summary>
        /// Effettua il parsing del JSON e popola la struttura
        /// </summary>
        /// <param name="json">Oggetto JSON di cui fare il parsing</param>
        public void ParseJSON(JObject json)
        {
            Account = "";
            Breaches.Clear();

            if (Utility.SafeTryGetJSONString(json, nameof(Account), out string accountValue))
            {
                Account = accountValue;
            }
            if (Utility.SafeTryGetJSON(json, nameof(Breaches), out JToken breachesValue))
            {
                JArray breachesArray = breachesValue.ToObject <JArray>();
                foreach (JObject breachJson in breachesArray)
                {
                    BreachInfo info = new BreachInfo();
                    info.ParseJSON(breachJson);
                    Breaches.Add(info);
                }
            }
        }