order.cs

来自「C#高级编程第6版随书源代码 值得下载」· CS 代码 · 共 57 行

CS
57
字号
using System;
using System.Collections.Generic;

namespace Wrox.ProCSharp.EnterpriseServices
{
   [Serializable]
   public class Order
   {
      public static Order Create(string customerId, DateTime orderDate, 
                      string shipAddress, string shipCity, string shipCountry)
      {
         return new Order()
         {
            CustomerId = customerId,
            OrderDate = orderDate,
            ShipAddress = shipAddress,
            ShipCity = shipCity,
            ShipCountry = shipCountry
         };
      }

      public Order()
      {
      }

      internal void SetOrderId(int orderId)
      {
         this.OrderId = orderId;
      }

      public void AddOrderLine(OrderLine orderLine)
      {
         orderLines.Add(orderLine);
      }

      private List<OrderLine> orderLines = new List<OrderLine>();

      public int OrderId { get; private set; }
      public string CustomerId { get; private set; }
      public DateTime OrderDate { get; private set; }
      public string ShipAddress { get; private set; }
      public string ShipCity { get; private set; }
      public string ShipCountry { get; private set; }

      public OrderLine[] OrderLines
      {
          get
          {
              OrderLine[] ol = new OrderLine[orderLines.Count];
              orderLines.CopyTo(ol);
              return ol;
          }
      }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?