Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // tạo 1 đối tượng delegate
            IntegerToInteger ii = new IntegerToInteger(Calculator.Add); // tham chieu den ô nhớ của hàm

            ii += Calculator.Subtract;                                  // nạp thêm hàm vào chuỗi thực hiện của delegate - multicast
            ii += new Calculator().division;
            int a = ii(5, 2);                                           // thực thi các hàm được nạp vào delegate

            Console.WriteLine("a = " + a);
            // Calculator.Add(2 , 5);
            // Calculator.Subtract(2 , 5);
            // // luon can chay 2 dong voi moi cap so
            // Calculator.Add(7 , 3);
            // Calculator.Subtract(7 , 3);
            TaxMoney tm  = TaxCalc.GetTax("VN");// tm la 1 delegate;
            float    tax = tm(100000000);

            Console.WriteLine("Thue phai nop: " + tax);

            // tạo 1 hàm ẩn danh bằng delegate
            TaxMoney tm2   = delegate(float salary) { return(salary * 40 / 100); };
            float    frTax = tm2(10000);

            Console.WriteLine("Thue tai Phap: " + frTax);
        }
Exemplo n.º 2
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Id = {(Id == null ? "null" : Id == string.Empty ? "" : Id)}");
     toStringOutput.Add($"MerchantId = {(MerchantId == null ? "null" : MerchantId == string.Empty ? "" : MerchantId)}");
     toStringOutput.Add($"CreatedAt = {(CreatedAt == null ? "null" : CreatedAt == string.Empty ? "" : CreatedAt)}");
     toStringOutput.Add($"CreatorId = {(CreatorId == null ? "null" : CreatorId == string.Empty ? "" : CreatorId)}");
     toStringOutput.Add($"Device = {(Device == null ? "null" : Device.ToString())}");
     toStringOutput.Add($"PaymentUrl = {(PaymentUrl == null ? "null" : PaymentUrl == string.Empty ? "" : PaymentUrl)}");
     toStringOutput.Add($"ReceiptUrl = {(ReceiptUrl == null ? "null" : ReceiptUrl == string.Empty ? "" : ReceiptUrl)}");
     toStringOutput.Add($"InclusiveTaxMoney = {(InclusiveTaxMoney == null ? "null" : InclusiveTaxMoney.ToString())}");
     toStringOutput.Add($"AdditiveTaxMoney = {(AdditiveTaxMoney == null ? "null" : AdditiveTaxMoney.ToString())}");
     toStringOutput.Add($"TaxMoney = {(TaxMoney == null ? "null" : TaxMoney.ToString())}");
     toStringOutput.Add($"TipMoney = {(TipMoney == null ? "null" : TipMoney.ToString())}");
     toStringOutput.Add($"DiscountMoney = {(DiscountMoney == null ? "null" : DiscountMoney.ToString())}");
     toStringOutput.Add($"TotalCollectedMoney = {(TotalCollectedMoney == null ? "null" : TotalCollectedMoney.ToString())}");
     toStringOutput.Add($"ProcessingFeeMoney = {(ProcessingFeeMoney == null ? "null" : ProcessingFeeMoney.ToString())}");
     toStringOutput.Add($"NetTotalMoney = {(NetTotalMoney == null ? "null" : NetTotalMoney.ToString())}");
     toStringOutput.Add($"RefundedMoney = {(RefundedMoney == null ? "null" : RefundedMoney.ToString())}");
     toStringOutput.Add($"SwedishRoundingMoney = {(SwedishRoundingMoney == null ? "null" : SwedishRoundingMoney.ToString())}");
     toStringOutput.Add($"GrossSalesMoney = {(GrossSalesMoney == null ? "null" : GrossSalesMoney.ToString())}");
     toStringOutput.Add($"NetSalesMoney = {(NetSalesMoney == null ? "null" : NetSalesMoney.ToString())}");
     toStringOutput.Add($"InclusiveTax = {(InclusiveTax == null ? "null" : $"[{ string.Join(", ", InclusiveTax)} ]")}");
     toStringOutput.Add($"AdditiveTax = {(AdditiveTax == null ? "null" : $"[{ string.Join(", ", AdditiveTax)} ]")}");
     toStringOutput.Add($"Tender = {(Tender == null ? "null" : $"[{ string.Join(", ", Tender)} ]")}");
     toStringOutput.Add($"Refunds = {(Refunds == null ? "null" : $"[{ string.Join(", ", Refunds)} ]")}");
     toStringOutput.Add($"Itemizations = {(Itemizations == null ? "null" : $"[{ string.Join(", ", Itemizations)} ]")}");
     toStringOutput.Add($"SurchargeMoney = {(SurchargeMoney == null ? "null" : SurchargeMoney.ToString())}");
     toStringOutput.Add($"Surcharges = {(Surcharges == null ? "null" : $"[{ string.Join(", ", Surcharges)} ]")}");
     toStringOutput.Add($"IsPartial = {(IsPartial == null ? "null" : IsPartial.ToString())}");
 }
        public override int GetHashCode()
        {
            int hashCode = -685311361;

            if (TotalMoney != null)
            {
                hashCode += TotalMoney.GetHashCode();
            }

            if (TaxMoney != null)
            {
                hashCode += TaxMoney.GetHashCode();
            }

            if (DiscountMoney != null)
            {
                hashCode += DiscountMoney.GetHashCode();
            }

            if (TipMoney != null)
            {
                hashCode += TipMoney.GetHashCode();
            }

            if (ServiceChargeMoney != null)
            {
                hashCode += ServiceChargeMoney.GetHashCode();
            }

            return(hashCode);
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            IntegerToInteger ii = new IntegerToInteger(Caculator.Add);

            ii += Caculator.Subtract;
            ii += new Caculator().Division;
            ii(2, 5);


            TaxMoney tm  = TaxCaic.GetTax("US");// tm la 1  delegate
            float    tax = tm(100000000);

            Console.WriteLine("thue phai nop " + tax);


            //tao 1 ham an danh bang delegate
            TaxMoney tm2 = delegate(float salary)
            {
                return(salary * 40 / 100);
            };
            float frTax = tm2(10000);

            Console.WriteLine("thue tai phap " + frTax);



            PhepTinh pt = Pheptinh.GetPt("-");
            int      c  = pt(2, 3);

            Console.WriteLine("ket qua " + c);
        }
Exemplo n.º 5
0
        public static void Main1(string[] args)
        {
            // tao doi tuong delegate
            IntegerToInteger ii = new IntegerToInteger(Calculator.Add);

            ii += Calculator.Subtract; // nap them ham vao chuoi thuc hien cura delegate - multi catch
            ii += new Calculator().division;
            ii(15, 5);                 // thuc thi cac ham duoc nap vao delegate

            //Console.WriteLine("a =" + a);

            //Calculator.Add(2, 5);
            //Calculator.Subtract(2, 5);
            //luon can chay 2 dong voi moi cap so
            TaxMoney tm  = TaxCalc.GetTax("VN"); //tm la delegate
            float    tax = tm(1000000000);

            Console.WriteLine("Thue phai nop: " + tax);

            //Tao 1 ham an danh bang delegate
            TaxMoney tm2   = delegate(float salary) { return(salary * 40 / 100); };
            float    frTax = tm2(10000);

            Console.WriteLine("Thue tai Phap: " + frTax);
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            // tao 1 doi tuong delegate
            IntegerToInteger ii = new IntegerToInteger(Calculator.Add); // tham chiu den o nho cua ham

            ii += Calculator.Subtract;                                  //nap them chuoi thuc hien cua delegate mo
            ii += Calculator.division;
            int a = ii(5, 2);                                           // Thực thi các ham nạp bào delegate

            Console.WriteLine("a =" + a);
            // Calculator.Add(2, 5);
            //Calculator.Subtract(2, 5);
            //luon chay 2 dong voimoi cap
            //Calculator.Add(7, 3);
            //Calculator.Subtract(7, 3);
            TaxMoney tm  = TaxCalc.GetTax("VN");// tm là 1 delegate;
            float    tax = tm(1000000);

            Console.WriteLine("Thue phai nop:" + tax);

            TaxMoney tm2   = delegate(float salary) { return(salary * 40 / 100); };
            float    frTax = tm2(10000);

            Console.WriteLine("Thue tai Phap:" + frTax);
        }
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"TotalMoney = {(TotalMoney == null ? "null" : TotalMoney.ToString())}");
     toStringOutput.Add($"TaxMoney = {(TaxMoney == null ? "null" : TaxMoney.ToString())}");
     toStringOutput.Add($"DiscountMoney = {(DiscountMoney == null ? "null" : DiscountMoney.ToString())}");
     toStringOutput.Add($"TipMoney = {(TipMoney == null ? "null" : TipMoney.ToString())}");
     toStringOutput.Add($"ServiceChargeMoney = {(ServiceChargeMoney == null ? "null" : ServiceChargeMoney.ToString())}");
 }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            TaxMoney tm  = TaxCalc.GetTax("VN");
            float    tax = tm(100000000);

            Console.WriteLine("Thue Phai Nop : " + tax);

            // Tao 1 Ham an danh bang delegate
            TaxMoney tm2   = delegate(float salary) { return(salary * 40 / 100); };
            float    frTax = tm2(10000);

            Console.WriteLine("Thue Tai Phap : " + frTax);
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is OrderMoneyAmounts other &&
                   ((TotalMoney == null && other.TotalMoney == null) || (TotalMoney?.Equals(other.TotalMoney) == true)) &&
                   ((TaxMoney == null && other.TaxMoney == null) || (TaxMoney?.Equals(other.TaxMoney) == true)) &&
                   ((DiscountMoney == null && other.DiscountMoney == null) || (DiscountMoney?.Equals(other.DiscountMoney) == true)) &&
                   ((TipMoney == null && other.TipMoney == null) || (TipMoney?.Equals(other.TipMoney) == true)) &&
                   ((ServiceChargeMoney == null && other.ServiceChargeMoney == null) || (ServiceChargeMoney?.Equals(other.ServiceChargeMoney) == true)));
        }
Exemplo n.º 10
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is V1Payment other &&
                   ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((MerchantId == null && other.MerchantId == null) || (MerchantId?.Equals(other.MerchantId) == true)) &&
                   ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) &&
                   ((CreatorId == null && other.CreatorId == null) || (CreatorId?.Equals(other.CreatorId) == true)) &&
                   ((Device == null && other.Device == null) || (Device?.Equals(other.Device) == true)) &&
                   ((PaymentUrl == null && other.PaymentUrl == null) || (PaymentUrl?.Equals(other.PaymentUrl) == true)) &&
                   ((ReceiptUrl == null && other.ReceiptUrl == null) || (ReceiptUrl?.Equals(other.ReceiptUrl) == true)) &&
                   ((InclusiveTaxMoney == null && other.InclusiveTaxMoney == null) || (InclusiveTaxMoney?.Equals(other.InclusiveTaxMoney) == true)) &&
                   ((AdditiveTaxMoney == null && other.AdditiveTaxMoney == null) || (AdditiveTaxMoney?.Equals(other.AdditiveTaxMoney) == true)) &&
                   ((TaxMoney == null && other.TaxMoney == null) || (TaxMoney?.Equals(other.TaxMoney) == true)) &&
                   ((TipMoney == null && other.TipMoney == null) || (TipMoney?.Equals(other.TipMoney) == true)) &&
                   ((DiscountMoney == null && other.DiscountMoney == null) || (DiscountMoney?.Equals(other.DiscountMoney) == true)) &&
                   ((TotalCollectedMoney == null && other.TotalCollectedMoney == null) || (TotalCollectedMoney?.Equals(other.TotalCollectedMoney) == true)) &&
                   ((ProcessingFeeMoney == null && other.ProcessingFeeMoney == null) || (ProcessingFeeMoney?.Equals(other.ProcessingFeeMoney) == true)) &&
                   ((NetTotalMoney == null && other.NetTotalMoney == null) || (NetTotalMoney?.Equals(other.NetTotalMoney) == true)) &&
                   ((RefundedMoney == null && other.RefundedMoney == null) || (RefundedMoney?.Equals(other.RefundedMoney) == true)) &&
                   ((SwedishRoundingMoney == null && other.SwedishRoundingMoney == null) || (SwedishRoundingMoney?.Equals(other.SwedishRoundingMoney) == true)) &&
                   ((GrossSalesMoney == null && other.GrossSalesMoney == null) || (GrossSalesMoney?.Equals(other.GrossSalesMoney) == true)) &&
                   ((NetSalesMoney == null && other.NetSalesMoney == null) || (NetSalesMoney?.Equals(other.NetSalesMoney) == true)) &&
                   ((InclusiveTax == null && other.InclusiveTax == null) || (InclusiveTax?.Equals(other.InclusiveTax) == true)) &&
                   ((AdditiveTax == null && other.AdditiveTax == null) || (AdditiveTax?.Equals(other.AdditiveTax) == true)) &&
                   ((Tender == null && other.Tender == null) || (Tender?.Equals(other.Tender) == true)) &&
                   ((Refunds == null && other.Refunds == null) || (Refunds?.Equals(other.Refunds) == true)) &&
                   ((Itemizations == null && other.Itemizations == null) || (Itemizations?.Equals(other.Itemizations) == true)) &&
                   ((SurchargeMoney == null && other.SurchargeMoney == null) || (SurchargeMoney?.Equals(other.SurchargeMoney) == true)) &&
                   ((Surcharges == null && other.Surcharges == null) || (Surcharges?.Equals(other.Surcharges) == true)) &&
                   ((IsPartial == null && other.IsPartial == null) || (IsPartial?.Equals(other.IsPartial) == true)));
        }
        public static void Main(string[] args)
        {
            //tạo 1 đối tượng delegate
            IntegerToInteger ii = new IntegerToInteger(Calculator.Add);//tham chiếu đến ô nhớ của hàm

            //program.Add(2, 4);
            ii += Calculator.Subtract; //nạp thêm hàm vào chuỗi thực hiện của delegate
            ii += new Calculator().division;
            ii(5, 2);                  //thực thi các hàm nạp vào delegate
            //Calculator.Add(2, 6);
            //Calculator.Subtract(4, 6);
            //Calculator.Add(7, 3);
            //Calculator.Subtract(4, 3);
            TaxMoney tm  = TaxCalc.GetTax("VN");//tm la 1 delegate
            float    tax = tm(100000000);

            Console.WriteLine("thue phai nop :" + tax);

            TaxMoney tm2 = delegate(float salary) { return(salary * 40 / 100); };

            float frTax = tm2(10000);

            Console.WriteLine("Thue tai phap :" + frTax);
        }
Exemplo n.º 12
0
        public static void Main(string[] args)
        {
            DetegateAdd ii = new DetegateAdd(Calculator.Add);

            ii += Calculator.Stru;
            ii += new Calculator().division;
            ii(2, 4);//nap vao delegate

            AddSalary ss = new AddSalary(TaxCalc.vietNam);

            ss(10023);


            TaxMoney tm  = TaxCalc.GetTax("VN");// la 1 delegate
            float    tax = tm(10000);

            Console.WriteLine("Thue phai nop" + tax);

            TaxMoney tm2  = TaxCalc.GetTax("Us");// la 1 delegate
            float    tax2 = tm2(10000);

            Console.WriteLine("Thue phai nop" + tax2);

            TaxMoney tm3  = TaxCalc.GetTax("sadas");// la 1 delegate
            float    tax3 = tm3(10000);

            Console.WriteLine("Thue phai nop" + tax3);

            //an danh
            TaxMoney tm4  = delegate(float salary) { return(salary * 40 / 100); };
            float    tax4 = tm4(341);

            Console.WriteLine("Thue phai nop tai phap" + tax4);

            //tu lam
            // int chose = 0;
            // NumberAdd p ;
            // Console.WriteLine("Thue phai nop"+tax3);
            // do
            // {
            //     Console.WriteLine("1. Cong");
            //     Console.WriteLine("2. Tru");
            //     Console.WriteLine("3. Nhan ");
            //     Console.WriteLine("4. Chia");
            //     Console.WriteLine("Chose: ");
            //     chose = Convert.ToInt32(Console.ReadLine());
            //     switch (chose)
            //     {
            //         case 1:
            //              p = PhepToan.NumberFunction("Tong");
            //             break;
            //         case 2:
            //             p = PhepToan.NumberFunction("hieu");
            //             break;
            //         case 3:
            //             p = PhepToan.NumberFunction("tich");
            //             break;
            //         case 4:
            //             p = PhepToan.NumberFunction("Thuong");
            //             break;
            //         case 5:
            //             Environment.Exit(0);
            //             break;
            //     }
            // } while (chose != 5);
            // NumberAdd tm5 = PhepToan.NumberFunction("Tong");// la 1 delegate
            // float tax5 = tm5(123,3123);
            // Console.WriteLine("Tong = "+tax5);
            //
            // NumberAdd tm6 = PhepToan.NumberFunction("hieu");// la 1 delegate
            // float tax6 = tm6(123,3123);
            // Console.WriteLine("hieu = "+tax6);
            //
            // NumberAdd tm7 = PhepToan.NumberFunction("tich");// la 1 delegate
            // float tax7 = tm7(123,3123);
            // Console.WriteLine("Tich = "+tax7);
            //
            // NumberAdd tm8 = PhepToan.NumberFunction("Thuong");// la 1 delegate
            // float tax8 = tm8(1123123,3123);
            // Console.WriteLine("thuong = "+tax8);

            //thay chua
            int choose;

            do
            {
                showMenu();
                choose = readNumber();
                if (choose > 0 && choose < 5)
                {
                    Console.WriteLine("nhap so thu nhat:");
                    int no1 = readNumber();
                    Console.WriteLine("nhap so thu hai:");
                    int       no2 = readNumber();
                    NumberAdd mn  = PhepToan.NumberFunction(choose);
                    switch (choose)
                    {
                    case 1:
                        Console.WriteLine("Tong 2 so:" + mn(no1, no2));
                        break;

                    case 2:
                        Console.WriteLine("Hieu 2 so:" + mn(no1, no2));
                        break;

                    case 3:
                        Console.WriteLine("Tich 2 so:" + mn(no1, no2));
                        break;

                    case 4:
                        Console.WriteLine("Thuong 2 so:" + mn(no1, no2));
                        break;
                    }
                }
            } while (choose != 0);
        }
Exemplo n.º 13
0
        public override int GetHashCode()
        {
            int hashCode = -215174345;

            if (Context != null)
            {
                hashCode += Context.GetHashCode();
            }

            if (Id != null)
            {
                hashCode += Id.GetHashCode();
            }

            if (MerchantId != null)
            {
                hashCode += MerchantId.GetHashCode();
            }

            if (CreatedAt != null)
            {
                hashCode += CreatedAt.GetHashCode();
            }

            if (CreatorId != null)
            {
                hashCode += CreatorId.GetHashCode();
            }

            if (Device != null)
            {
                hashCode += Device.GetHashCode();
            }

            if (PaymentUrl != null)
            {
                hashCode += PaymentUrl.GetHashCode();
            }

            if (ReceiptUrl != null)
            {
                hashCode += ReceiptUrl.GetHashCode();
            }

            if (InclusiveTaxMoney != null)
            {
                hashCode += InclusiveTaxMoney.GetHashCode();
            }

            if (AdditiveTaxMoney != null)
            {
                hashCode += AdditiveTaxMoney.GetHashCode();
            }

            if (TaxMoney != null)
            {
                hashCode += TaxMoney.GetHashCode();
            }

            if (TipMoney != null)
            {
                hashCode += TipMoney.GetHashCode();
            }

            if (DiscountMoney != null)
            {
                hashCode += DiscountMoney.GetHashCode();
            }

            if (TotalCollectedMoney != null)
            {
                hashCode += TotalCollectedMoney.GetHashCode();
            }

            if (ProcessingFeeMoney != null)
            {
                hashCode += ProcessingFeeMoney.GetHashCode();
            }

            if (NetTotalMoney != null)
            {
                hashCode += NetTotalMoney.GetHashCode();
            }

            if (RefundedMoney != null)
            {
                hashCode += RefundedMoney.GetHashCode();
            }

            if (SwedishRoundingMoney != null)
            {
                hashCode += SwedishRoundingMoney.GetHashCode();
            }

            if (GrossSalesMoney != null)
            {
                hashCode += GrossSalesMoney.GetHashCode();
            }

            if (NetSalesMoney != null)
            {
                hashCode += NetSalesMoney.GetHashCode();
            }

            if (InclusiveTax != null)
            {
                hashCode += InclusiveTax.GetHashCode();
            }

            if (AdditiveTax != null)
            {
                hashCode += AdditiveTax.GetHashCode();
            }

            if (Tender != null)
            {
                hashCode += Tender.GetHashCode();
            }

            if (Refunds != null)
            {
                hashCode += Refunds.GetHashCode();
            }

            if (Itemizations != null)
            {
                hashCode += Itemizations.GetHashCode();
            }

            if (SurchargeMoney != null)
            {
                hashCode += SurchargeMoney.GetHashCode();
            }

            if (Surcharges != null)
            {
                hashCode += Surcharges.GetHashCode();
            }

            if (IsPartial != null)
            {
                hashCode += IsPartial.GetHashCode();
            }

            return(hashCode);
        }