예제 #1
0
        /// <summary>
        /// Полное копирование объекта
        /// </summary>
        /// <returns>Копия объекта</returns>
        public PassengerFare Copy()
        {
            var result = new PassengerFare();

            result.FareCalc = FareCalc;
            result.Quantity = Quantity;
            result.Type     = Type;
            result.PricedAs = PricedAs;
            result.Upt      = Upt;

            if (BaseFare != null)
            {
                result.BaseFare = new Money(BaseFare);
            }

            if (EquiveFare != null)
            {
                result.EquiveFare = new Money(EquiveFare);
            }
            else
            {
                result.EquiveFare = null;
            }

            if (TotalFare != null)
            {
                result.TotalFare = new Money(TotalFare);
            }

            if (Tariffs != null)
            {
                result.Tariffs = new List <Tariff>();
                foreach (var oldTarif in Tariffs)
                {
                    result.Tariffs.Add(oldTarif.Copy());
                }
            }

            if (Taxes != null)
            {
                result.Taxes = new List <Tax>();
                foreach (var oldTax in Taxes)
                {
                    var newTax = new Tax();
                    newTax.Value    = oldTax.Value;
                    newTax.Currency = oldTax.Currency;
                    newTax.TaxCode  = oldTax.TaxCode;
                    result.Taxes.Add(newTax);
                }
            }

            return(result);
        }
예제 #2
0
		/// <summary>
		/// Полное копирование объекта
		/// </summary>
		/// <returns>Копия объекта</returns>
		public object Clone()
		{
			var result = new PassengerFare();

			result.FareCalc = FareCalc;
			result.Quantity = Quantity;
			result.Type = Type;
			result.PricedAs = PricedAs;
			result.Upt = Upt;

			if (BaseFare != null)
			{
				result.BaseFare = new Money(BaseFare);
			}

			if (EquiveFare != null)
			{
				result.EquiveFare = new Money(EquiveFare);
			}
			else
			{
				result.EquiveFare = null;
			}

			if (TotalFare != null)
			{
				result.TotalFare = new Money(TotalFare);
			}

			if (Tariffs != null)
			{
				result.Tariffs = new List<Tariff>();
				foreach (var oldTarif in Tariffs)
				{
					result.Tariffs.Add(oldTarif.FullCopy());
				}
			}

			if (Taxes != null)
			{
				result.Taxes = new List<Tax>();
				foreach (var oldTax in Taxes)
				{
					var newTax = new Tax();
					newTax.Value = oldTax.Value;
					newTax.Currency = oldTax.Currency;
					newTax.TaxCode = oldTax.TaxCode;
					result.Taxes.Add(newTax);
				}
			}

			return result;
		}