Beispiel #1
0
 void Update()
 {
     if (Item != null)
     {
         // Automatically update the item's layer
         ItemReceived.Invoke();
     }
 }
 public bool DeepEquals(DestinyVendorReceipt?other)
 {
     return(other is not null &&
            CurrencyPaid.DeepEqualsList(other.CurrencyPaid) &&
            (ItemReceived is not null ? ItemReceived.DeepEquals(other.ItemReceived) : other.ItemReceived is null) &&
            LicenseUnlockHash == other.LicenseUnlockHash &&
            PurchasedByCharacterId == other.PurchasedByCharacterId &&
            RefundPolicy == other.RefundPolicy &&
            SequenceNumber == other.SequenceNumber &&
            TimeToExpiration == other.TimeToExpiration &&
            ExpiresOn == other.ExpiresOn);
 }
 public void Update(DestinyVendorReceipt?other)
 {
     if (other is null)
     {
         return;
     }
     if (!CurrencyPaid.DeepEqualsList(other.CurrencyPaid))
     {
         CurrencyPaid = other.CurrencyPaid;
         OnPropertyChanged(nameof(CurrencyPaid));
     }
     if (!ItemReceived.DeepEquals(other.ItemReceived))
     {
         ItemReceived.Update(other.ItemReceived);
         OnPropertyChanged(nameof(ItemReceived));
     }
     if (LicenseUnlockHash != other.LicenseUnlockHash)
     {
         LicenseUnlockHash = other.LicenseUnlockHash;
         OnPropertyChanged(nameof(LicenseUnlockHash));
     }
     if (PurchasedByCharacterId != other.PurchasedByCharacterId)
     {
         PurchasedByCharacterId = other.PurchasedByCharacterId;
         OnPropertyChanged(nameof(PurchasedByCharacterId));
     }
     if (RefundPolicy != other.RefundPolicy)
     {
         RefundPolicy = other.RefundPolicy;
         OnPropertyChanged(nameof(RefundPolicy));
     }
     if (SequenceNumber != other.SequenceNumber)
     {
         SequenceNumber = other.SequenceNumber;
         OnPropertyChanged(nameof(SequenceNumber));
     }
     if (TimeToExpiration != other.TimeToExpiration)
     {
         TimeToExpiration = other.TimeToExpiration;
         OnPropertyChanged(nameof(TimeToExpiration));
     }
     if (ExpiresOn != other.ExpiresOn)
     {
         ExpiresOn = other.ExpiresOn;
         OnPropertyChanged(nameof(ExpiresOn));
     }
 }
        public bool Equals(DestinyVendorReceipt input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     CurrencyPaid == input.CurrencyPaid ||
                     (CurrencyPaid != null && CurrencyPaid.SequenceEqual(input.CurrencyPaid))
                     ) &&
                 (
                     ItemReceived == input.ItemReceived ||
                     (ItemReceived != null && ItemReceived.Equals(input.ItemReceived))
                 ) &&
                 (
                     LicenseUnlockHash == input.LicenseUnlockHash ||
                     (LicenseUnlockHash.Equals(input.LicenseUnlockHash))
                 ) &&
                 (
                     PurchasedByCharacterId == input.PurchasedByCharacterId ||
                     (PurchasedByCharacterId.Equals(input.PurchasedByCharacterId))
                 ) &&
                 (
                     RefundPolicy == input.RefundPolicy ||
                     (RefundPolicy != null && RefundPolicy.Equals(input.RefundPolicy))
                 ) &&
                 (
                     SequenceNumber == input.SequenceNumber ||
                     (SequenceNumber.Equals(input.SequenceNumber))
                 ) &&
                 (
                     TimeToExpiration == input.TimeToExpiration ||
                     (TimeToExpiration.Equals(input.TimeToExpiration))
                 ) &&
                 (
                     ExpiresOn == input.ExpiresOn ||
                     (ExpiresOn != null && ExpiresOn.Equals(input.ExpiresOn))
                 ));
        }
Beispiel #5
0
        private async Task ReceiveAsync()
        {
            if (_cts != null)
            {
                throw new InvalidOperationException();
            }
            _cts             = new CancellationTokenSource();
            _receivedItemIds = new System.Collections.Concurrent.ConcurrentBag <string>();
            while (!_cts.IsCancellationRequested)
            {
                var    waitTimeMs  = 1000 * CommentRetrieveIntervalSec;
                var    accWaitTime = 0;
                string lastItemId  = null;
                try
                {
                    var(streamChecker, streamCheckerRaw) = await API.GetStreamChecker(_server, _broadcasterId, lastItemId).ConfigureAwait(false);

                    if (streamChecker.Items != null && streamChecker.Items.Count > 0)
                    {
                        var lastItem         = streamChecker.Items[streamChecker.Items.Count - 1];
                        var lastItemIdBefore = lastItemId == null ? 0 : long.Parse(lastItemId);
                        lastItemId = Math.Max(lastItemIdBefore, long.Parse(lastItem.Id)).ToString();
                    }
                    MetadataReceived?.Invoke(this, new Metadata
                    {
                        Title          = streamChecker.Telop,
                        CurrentViewers = streamChecker.CurrentViewers.ToString(),
                        TotalViewers   = streamChecker.TotalViewers.ToString(),
                        IsLive         = streamChecker.LiveId.HasValue,
                        LiveId         = streamChecker.LiveId,
                    });
                    foreach (var item in streamChecker.Items)
                    {
                        try
                        {
                            if (_receivedItemIds.Contains(item.Id))
                            {
                                continue;
                            }
                            _receivedItemIds.Add(item.Id);
                            ItemReceived?.Invoke(this, new InternalItem(item));
                        }
                        catch (ParseException ex)
                        {
                            _logger.LogException(ex);
                        }
                        catch (Exception ex)
                        {
                            _logger.LogException(ex);
                        }
                    }
                    LiveIdReceived?.Invoke(this, streamChecker.LiveId);
                }
                catch (HttpRequestException ex)
                {
                    _logger.LogException(ex);
                    string message;
                    if (ex.InnerException != null)
                    {
                        message = ex.InnerException.Message;
                    }
                    else
                    {
                        message = ex.Message;
                    }
                    SendInfo(message, InfoType.Debug);
                }
                catch (ParseException ex)
                {
                    _logger.LogException(ex);
                    SendInfo(ex.Message, InfoType.Debug);
                }
                catch (TaskCanceledException)
                {
                    break;
                }
                catch (Exception ex)
                {
                    _logger.LogException(ex);
                    //Infoでエラー内容を通知。ただし同じエラーが連続する場合は通知しない
                    SendInfo(ex.Message, InfoType.Debug);
                }
                try
                {
                    var restWait = waitTimeMs - accWaitTime;
                    if (restWait > 0)
                    {
                        await Task.Delay(restWait, _cts.Token);
                    }
                }
                catch (TaskCanceledException)
                {
                    break;
                }
            }
            _cts = null;
        }