本文整理汇总了C#中Product.LoadXElement方法的典型用法代码示例。如果您正苦于以下问题:C# Product.LoadXElement方法的具体用法?C# Product.LoadXElement怎么用?C# Product.LoadXElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.LoadXElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddProduct
public void AddProduct(Product product)
{
var variants = product.Variants;
product.Variants = null;
product.Options = variants[0].Options;
variants[0].Options = null;
product.VariantsAttributes = new[] { variants[0] };
var x = product.ToXElement();
var data = downloadWebPage(getFullUrl("/admin/products.xml"), HttpMethod.POST, x.ToString());
var xx = XDocument.Parse(data).Root;
product.LoadXElement(xx);
if (variants.Length > 1)
{
for (int i = 1; i < variants.Length; i++)
{
var variant = variants[i];
for (int j = 0; j < variant.Options.Length; j++)
{
variant.Options[j].OptionNameID = product.Variants[0].OptionValues[j].OptionNameID;
}
AddVariant(variant, product.ID);
}
}
}
示例2: GetProducts
public IEnumerable<Product> GetProducts(int? categoryID = null, int? collectionID = null, int? page = null, int limit = 50)
{
var url = "admin/products.xml";
var currentPage = page ?? 1;
if (categoryID != null) url += "?category_id=" + categoryID;
if (collectionID != null) url += "?collection_id=" + collectionID;
while (true)
{
var data = downloadWebPage(getFullUrl(url + "?page=" + currentPage + "&limit=" + limit), HttpMethod.GET);
var x = XDocument.Parse(data);
if (x.Root.Elements().Count() == 0) break;
foreach (var item in x.Root.Elements())
{
var prod = new Product();
prod.LoadXElement(item);
yield return prod;
}
if (page != null) break;
currentPage++;
}
}
示例3: UpdateProduct
public void UpdateProduct(Product product)
{
var x = product.ToXElement(false);
var data = downloadWebPage(getFullUrl("/admin/products/" + product.ID + ".xml"), HttpMethod.PUT, x.ToString());
var xx = XDocument.Parse(data).Root;
product.LoadXElement(xx);
}
示例4: GetProduct
public Product GetProduct(int productID)
{
var data = downloadWebPage(getFullUrl("admin/products/" + productID + ".xml"), HttpMethod.GET);
var x = XDocument.Parse(data).Root;
var prod = new Product();
prod.LoadXElement(x);
return prod;
}