当前位置: 首页>>代码示例>>C#>>正文


C# Customer.InjectFrom方法代码示例

本文整理汇总了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);
 }
开发者ID:tidusjar,项目名称:ValueInjecter,代码行数:9,代码来源:LoopInjectionTests.cs

示例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;
        }
开发者ID:afandylamusu,项目名称:vc-community,代码行数:43,代码来源:CustomerConverter.cs


注:本文中的Customer.InjectFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。