/// <summary> /// Populates a default CurrentAppSimulator implementation based off of what's available in the WMAppManifest.xml file /// </summary> /// <returns>A CurrentAppSimulator instance populated via the contents of the WMAppManifest.xml file</returns> private static CurrentAppSimulator DefaultAppSimulator() { var appProperties = new AppListing(); appProperties.ListingInformation = new ListingInformation(); var appManifestXml = XDocument.Load( "WMAppManifest.xml"); using (var rdr = appManifestXml.CreateReader(ReaderOptions.None)) { rdr.ReadToDescendant("App"); if (!rdr.IsStartElement()) { throw new System.FormatException("WMAppManifest.xml is missing."); } var productId = rdr.GetAttribute("ProductID"); appProperties.AppId = Guid.Parse(productId); appProperties.LinkUri = new Uri(string.Format("https://store.windows.com/en-US/{0}", appProperties.AppId.ToString())); appProperties.ListingInformation.CurrentMarket = RegionInfo.CurrentRegion.TwoLetterISORegionName; appProperties.ListingInformation.Description = rdr.GetAttribute("Description"); appProperties.ListingInformation.Name = rdr.GetAttribute("Title"); appProperties.ListingInformation.FormattedPrice = string.Format("{0}{1}", RegionInfo.CurrentRegion .ISOCurrencySymbol, 0.00d); } return(new CurrentAppSimulator(appProperties, DefaultLicenseInformation(), DefaultMethodResults())); }
private CurrentAppSimulator(AppListing listingInformation, LicenseInformation licenseInformation, IDictionary <string, bool> methodResults) { _listingInformation = listingInformation; _licenseInformation = licenseInformation; _methodResults = methodResults; }
internal static string CreateAppPurchaseReceipt(AppListing listing) { var purchaseDate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"); var certificateId = String.Empty; var licenseType = "Full"; var deviceId = Guid.NewGuid(); var recieptId = Guid.NewGuid(); return(string.Format(AppReceiptXml, purchaseDate, certificateId, deviceId, recieptId, AppId, licenseType)); }
private static AppListing GetListingFromXml(IEnumerable <XElement> listingNodes) { var resultantListing = new AppListing(); var listingInfo = new ListingInformation(); var node = listingNodes.First(); { var appNode = node.Element("App"); resultantListing.AppId = Guid.Parse((string)appNode.Element("AppId")); resultantListing.LinkUri = new Uri((string)appNode.Element("LinkUri")); listingInfo.CurrentMarket = appNode.Element("CurrentMarket").SafeRead(); //Parse out the correct ISO country code for the current market based on the region information included in the XML file if (listingInfo.CurrentMarket == null) { listingInfo.CurrentMarket = RegionInfo.CurrentRegion.TwoLetterISORegionName; //use current region by default } else { listingInfo.CurrentMarket = new RegionInfo(listingInfo.CurrentMarket).TwoLetterISORegionName; } var marketData = appNode.Element("MarketData"); listingInfo.Description = marketData.Element("Description").SafeRead(); listingInfo.Name = (string)marketData.Element("Name"); listingInfo.FormattedPrice = string.Format("{0}{1}", (string)marketData.Element("CurrencySymbol"), Double.Parse(marketData.Element("Price").SafeRead("0.00")).ToString("0.00", CultureInfo.CurrentUICulture)); //Products foreach (var product in node.Elements("Product")) { var productListing = new ProductListing(); productListing.ProductId = product.Attribute("ProductId").SafeRead(); var iapMarketData = product.Element("MarketData"); productListing.Description = iapMarketData.Element("Description").SafeRead(); productListing.Name = iapMarketData.Element("Name").SafeRead(); productListing.FormattedPrice = string.Format("{0}{1}", (string)iapMarketData.Element("CurrencySymbol"), Double.Parse(iapMarketData.Element("Price").SafeRead("0.00")).ToString("0.00", CultureInfo.CurrentUICulture)); productListing.ProductType = (ProductType)iapMarketData.Element("ProductType").SafeRead(ProductType.Unknown); listingInfo.ProductListings.Add(productListing.ProductId, productListing); } } resultantListing.ListingInformation = listingInfo; return(resultantListing); }