コード例 #1
0
        public void Update(ProductSummary summary)
        {
            Guard.IsNotNull(summary, nameof(summary));

            // Set base properties
            Title = summary.Title;
            if (summary.RatingCount > 0)
            {
                ReviewSummary = new ReviewSummary
                {
                    AverageRating = summary.AverageRating,
                    ReviewCount   = summary.RatingCount
                };
            }
            Price   = summary.Price;
            StoreId = summary.ProductId;
            UpdateUrn();

            // Set MS Store package properties
            Images.Clear();
            if (summary.Images != null)
            {
                foreach (ImageItem img in summary.Images)
                {
                    Images.Add(new MicrosoftStoreImage(img));
                }
            }
        }
コード例 #2
0
        public void Update(CardModel card)
        {
            Guard.IsNotNull(card, nameof(card));

            // Set base properties
            Title       = card.Title;
            Description = card.Description ?? card.LongDescription;
            if (card.RatingsCount != null)
            {
                ReviewSummary = new ReviewSummary
                {
                    AverageRating = card.AverageRating,
                    // TODO: Parse into int. Examples:
                    // 2K -> 2000; 1.2M -> 1200000
                    //ReviewCount = card.RatingsCount
                };
            }
            Price        = card.Price;
            DisplayPrice = card.DisplayPrice;
            StoreId      = card.ProductId;
            UpdateUrn();

            // Set MS Store package properties
            Categories = card.Categories;
            Images.Clear();
            if (card.Images != null)
            {
                foreach (ImageItem img in card.Images)
                {
                    Images.Add(new MicrosoftStoreImage(img));
                }
            }

            PackageBase internalPackage = InternalPackage;

            if (!IsWinGet)
            {
                var package = (ModernPackage <ProductDetails>)internalPackage;
                package.PackageFamilyName = card.PackageFamilyNames?[0];
                internalPackage           = package;
            }
            Type = internalPackage.Type;
            CopyProperties(ref internalPackage);
            InternalPackage = internalPackage;
        }
コード例 #3
0
        public void Update(RatingSummary ratingSummary)
        {
            Guard.IsNotNull(ratingSummary, nameof(ratingSummary));

            ReviewSummary = new ReviewSummary
            {
                AverageRating    = ratingSummary.AverageRating,
                ReviewCount      = ratingSummary.ReviewCount,
                Star1Count       = ratingSummary.Star1Count,
                Star2Count       = ratingSummary.Star2Count,
                Star3Count       = ratingSummary.Star3Count,
                Star4Count       = ratingSummary.Star4Count,
                Star5Count       = ratingSummary.Star5Count,
                Star1ReviewCount = ratingSummary.Star1ReviewCount,
                Star2ReviewCount = ratingSummary.Star2ReviewCount,
                Star3ReviewCount = ratingSummary.Star3ReviewCount,
                Star4ReviewCount = ratingSummary.Star4ReviewCount,
                Star5ReviewCount = ratingSummary.Star5ReviewCount
            };
        }
コード例 #4
0
        public void Update(ProductDetails product)
        {
            Guard.IsNotNull(product, nameof(product));
            Model = product;

            // Set base properties
            Title         = product.Title;
            PublisherId   = product.PublisherId;
            DeveloperName = product.PublisherName;  // TODO: This should be the developer name, but the MS Store has an empty string
            ReleaseDate   = product.LastUpdateDateUtc;
            Description   = product.Description;
            Version       = product.Version;
            if (product.RatingCount > 0)
            {
                ReviewSummary = new ReviewSummary
                {
                    AverageRating = product.AverageRating,
                    ReviewCount   = product.RatingCount
                };
            }
            Price        = product.Price;
            DisplayPrice = product.DisplayPrice;
            ShortTitle   = product.ShortTitle;
            Website      = Link.Create(product.AppWebsiteUrl, ShortTitle + " website");
            StoreId      = product.ProductId;
            UpdateUrn();

            // Set MS Store package properties
            Notes      = product.Notes;
            Features   = product.Features;
            Categories = product.Categories;
            PrivacyUri = Link.Create(product.PrivacyUri, ShortTitle + " privacy policy");
            Platforms  = product.Platforms;
            if (product.SupportUris != null)
            {
                foreach (SupportUri uri in product.SupportUris.Where(u => u.Uri != null))
                {
                    SupportUrls.Add(new(uri.Uri, ShortTitle + " support"));
                }
            }
            Ratings = product.ProductRatings;
            PermissionsRequested         = product.PermissionsRequested;
            PackageAndDeviceCapabilities = product.PackageAndDeviceCapabilities;
            AllowedPlatforms             = product.AllowedPlatforms;
            WarningMessages = product.WarningMessages;
            Images.Clear();
            if (product.Images != null)
            {
                foreach (ImageItem img in product.Images)
                {
                    Images.Add(new MicrosoftStoreImage(img));
                }
            }

            PackageBase internalPackage = InternalPackage;

            if (!IsWinGet)
            {
                var package = (ModernPackage <ProductDetails>)internalPackage;
                package.PackageFamilyName    = product.PackageFamilyNames?[0];
                package.PublisherDisplayName = product.PublisherName;
                internalPackage = package;
            }
            Type = internalPackage.Type;
            CopyProperties(ref internalPackage);
            InternalPackage = internalPackage;
        }