本文整理汇总了C#中Customer.InjectFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.InjectFrom方法的具体用法?C# Customer.InjectFrom怎么用?C# Customer.InjectFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer.InjectFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldIgnoreProperties
public void ShouldIgnoreProperties()
{
var customer = GetCustomer();
var c1 = new Customer();
c1.InjectFrom(new LoopInjection(new[] { "FirstName" }), customer);
Assert.IsNull(c1.FirstName);
Assert.AreEqual(customer.LastName, c1.LastName);
}
示例2: ToShopifyModel
public static Customer ToShopifyModel(this CustomerInfo customer, StorefrontModel.WorkContext workContext, StorefrontModel.Common.IStorefrontUrlBuilder urlBuilder)
{
var result = new Customer();
result.InjectFrom<StorefrontModel.Common.NullableAndEnumValueInjecter>(customer);
result.Name = customer.FullName;
result.DefaultAddress = customer.DefaultAddress.ToShopifyModel();
result.DefaultBillingAddress = customer.DefaultBillingAddress.ToShopifyModel();
result.DefaultShippingAddress = customer.DefaultShippingAddress.ToShopifyModel();
if (customer.Tags != null)
{
result.Tags = customer.Tags.ToList();
}
if (customer.Addresses != null)
{
var addresses = customer.Addresses.Select(a => a.ToShopifyModel()).ToList();
// Add virtual ID to each address
var id = 1;
foreach (var address in addresses)
{
address.Id = id.ToString(CultureInfo.InvariantCulture);
id++;
}
//TODO: make customer.Addresses as IPagedList
result.Addresses = new StorefrontModel.Common.StorefrontPagedList<Address>(addresses, 1, 10, addresses.Count, page => workContext.RequestUrl.SetQueryParameter("page", page.ToString()).ToString());
}
if (customer.Orders != null)
{
var orders = customer.Orders.Select(o => o.ToShopifyModel(urlBuilder)).ToList();
result.Orders = new StorefrontModel.Common.StorefrontPagedList<Order>(orders, customer.Orders, customer.Orders.GetPageUrl);
}
if (customer.QuoteRequests != null)
{
var quoteRequests = customer.QuoteRequests.Select(qr => qr.ToShopifyModel()).ToList();
result.QuoteRequests = new StorefrontModel.Common.StorefrontPagedList<QuoteRequest>(quoteRequests, customer.QuoteRequests, customer.QuoteRequests.GetPageUrl);
}
return result;
}