/// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (PayeeUType != null)
         {
             hashCode = hashCode * 59 + PayeeUType.GetHashCode();
         }
         if (Domestic != null)
         {
             hashCode = hashCode * 59 + Domestic.GetHashCode();
         }
         if (Biller != null)
         {
             hashCode = hashCode * 59 + Biller.GetHashCode();
         }
         if (International != null)
         {
             hashCode = hashCode * 59 + International.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if BankingPayeeDetail instances are equal
        /// </summary>
        /// <param name="other">Instance of BankingPayeeDetail to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BankingPayeeDetail other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     PayeeUType == other.PayeeUType ||
                     PayeeUType != null &&
                     PayeeUType.Equals(other.PayeeUType)
                     ) &&
                 (
                     Domestic == other.Domestic ||
                     Domestic != null &&
                     Domestic.Equals(other.Domestic)
                 ) &&
                 (
                     Biller == other.Biller ||
                     Biller != null &&
                     Biller.Equals(other.Biller)
                 ) &&
                 (
                     International == other.International ||
                     International != null &&
                     International.Equals(other.International)
                 ));
        }
예제 #3
0
파일: FxPair.cs 프로젝트: mpvyard/qwack
 public override int GetHashCode()
 {
     unchecked
     {
         var result = Foreign.GetHashCode();
         result = (result * 397) ^ Domestic.GetHashCode();
         result = (result * 397) ^ SettlementCalendar.GetHashCode();
         result = (result * 397) ^ SpotLag.GetHashCode();
         return(result);
     }
 }
예제 #4
0
 public void ComputeDomesticWateruse(object basin)
 {
     //https://github.com/aspnet/EntityFrameworkCore/issues/7810#issuecomment-384909854
     try
     {
         using (var command = this.context.Database.GetDbConnection().CreateCommand())
         {
             command.CommandText = String.Format(getSQLStatement(sqlTypes.e_domesticsummarystats), basin, 4326);
             context.Database.OpenConnection();
             using (System.Data.Common.DbDataReader reader = command.ExecuteReader())
             {
                 this.DomesticUse = new Domestic();
                 while (reader.Read())
                 {
                     if (reader["name"].ToString() == "gw")
                     {
                         this.DomesticUse.GroundWater = Convert.ToDouble(reader["value"]);
                     }
                     if (reader["name"].ToString() == "sw")
                     {
                         this.DomesticUse.SurfaceWater = Convert.ToDouble(reader["value"]);
                     }
                 }
             } //end using
         }     //end using
     }
     catch (Exception ex)
     {
         this.DomesticUse = null;
         return;
     }
     finally
     {
         if (context.Database.GetDbConnection().State == System.Data.ConnectionState.Open)
         {
             context.Database.CloseConnection();
         }
     }
 }
예제 #5
0
        /// <summary>
        /// Test Out Every class in this repo
        /// </summary>
        static void ProveAnimalBehavior()
        {
            // Use polymorphism to create base class arrays with concrete class objects
            Animal[] zooPopulation = new Animal[]
            {
                new Snake(),
                new Crocodile(),
                new Bear(),
                new Cat("Carl"),
                new Horse("Harold"),
                new Dragon(),
                new Phoenix()
            };

            Reptile[]  slithers = new Reptile[2];
            Domestic[] pets     = new Domestic[2];

            // Demonstrate Animal Methods
            Console.WriteLine("All Animals Make Noise, and Like to eat!");
            foreach (Animal creature in zooPopulation)
            {
                Console.WriteLine("Press a key to hear the next one...");
                Console.ReadLine();
                creature.MakeNoise();
                creature.Eat();
                Console.WriteLine();
            }

            // Explicitly cast Animals to Wild type array
            Wild[] wilds = new Wild[]
            {
                (Wild)zooPopulation[0],
                (Wild)zooPopulation[1],
                (Wild)zooPopulation[2]
            };

            // Demonstrate Wild Method
            foreach (Wild creature in wilds)
            {
                creature.Hunt((Wild)zooPopulation[1]);
            }

            // Demonstrate Mammal and Reptile Methods
            Console.WriteLine($"Crocodiles lay { new Crocodile().LayEggs()} eggs.");
            Console.WriteLine($"Snakes lay { new Snake().LayEggs()} eggs.");
            Console.WriteLine();
            Console.WriteLine("...and bears hibernate:");
            new Bear().Hibernate(24);
            Console.WriteLine();

            // Demonstrate Domestic Behavior
            Console.WriteLine("Domestic animals can be trained by their owners:");
            Console.WriteLine(new Cat("Jerry Cat").TrainWith("You"));
            Console.WriteLine(new Horse("Apple Jack").TrainWith("You"));
            Console.WriteLine();

            // Demonstrate Fantasy Behavior
            Console.WriteLine("Fantasy creatures have magical powers!");
            Console.WriteLine(new Dragon().DoMagic());
            Console.WriteLine(new Phoenix().DoMagic());
            Console.WriteLine("Age is kind of a joke to immortal phoenixes");
        }
예제 #6
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            bool flag = true;

            if (txtAppointmentCount.Text.Length == 0 || cmbAppointmentTime.SelectedIndex == -1)
            {
                MessageBox.Show("Enter appointment count and click the 'Show Timings'", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                if (cmbAppointmentTime.SelectedIndex == -1)
                {
                    MessageBox.Show("Select an appointment time");
                    flag = false;
                }
                else if (cmbTestLocation.SelectedIndex == -1)
                {
                    MessageBox.Show("Select a test location");
                    flag = false;
                }
                else
                {
                    int slot = cmbAppointmentTime.SelectedIndex + 1;
                    if (appArray[slot - 1].CandidateData == null)
                    {
                        Candidate candidate = new Domestic();
                        appArray[slot - 1].AppointmentTime = appArray[slot - 1].AppointmentTime;
                        appArray[slot - 1].TestLocation    = cmbTestLocation.Text;
                        appArray[slot - 1].SlotNumber      = slot;
                        int candidateType = cmbCandidateType.SelectedIndex + 1;


                        switch (candidateType)
                        {
                        case (int)CandidateType.Domestic:
                            candidate = new Domestic();
                            candidate.CandidateType = "Domestic";
                            string IsFeeDeduction = cmbIndividualTask.Text;
                            ((Domestic)candidate).IsFeeDeduction = (IsFeeDeduction.ToUpper() == "YES") ? true : false;
                            break;

                        case (int)CandidateType.International:
                            candidate = new International();
                            candidate.CandidateType = "International";
                            string isWorkPermit = cmbIndividualTask.Text;
                            ((International)candidate).IsWorkPermit = (isWorkPermit.ToUpper() == "YES") ? true : false;
                            break;

                        case (int)CandidateType.LicenseRenew:
                            candidate = new LicenseRenew();
                            candidate.CandidateType = "LicenseRenew";
                            string isLicenseExpired = cmbIndividualTask.Text;
                            ((LicenseRenew)candidate).IsLicenseExpired = (isLicenseExpired.ToUpper() == "YES") ? true : false;
                            break;
                        }

                        string  candidateName    = txtName.Text;
                        string  candidateAddress = txtAddress.Text;
                        string  candidateEmail   = txtEmail.Text;
                        string  passport         = txtPassport.Text;
                        decimal amount;
                        string  amountString = txtAmount.Text;
                        string  creditCard   = txtCreditcard.Text;
                        candidate.CreditCard = creditCard;
                        candidate.Passport   = passport;
                        candidate.Email      = candidateEmail;
                        if (candidateName.Length == 0)
                        {
                            if (Validation.GetHasError(txtName) == true)
                            {
                                return;
                            }
                            txtName.Foreground = Brushes.Red;
                            txtName.Select(0, txtName.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtName.Foreground = Brushes.Black;
                        }
                        if (candidateAddress.Length == 0)
                        {
                            txtAddress.Foreground = Brushes.Red;
                            txtAddress.Select(0, txtAddress.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtAddress.Foreground = Brushes.Black;
                        }
                        if (!candidate.CheckEmail())
                        {
                            txtEmail.Foreground = Brushes.Red;
                            txtEmail.Select(0, txtEmail.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtEmail.Foreground = Brushes.Black;
                        }
                        if (!(decimal.TryParse(amountString, out amount)))
                        {
                            txtAmount.Foreground = Brushes.Red;
                            txtAmount.Select(0, txtAmount.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtAmount.Foreground = Brushes.Black;
                        }
                        if (!candidate.CheckCreditCard())
                        {
                            txtCreditcard.Foreground = Brushes.Red;
                            txtCreditcard.Select(0, txtCreditcard.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtCreditcard.Foreground = Brushes.Black;
                        }
                        if (!candidate.CheckPassport())
                        {
                            txtPassport.Foreground = Brushes.Red;
                            txtPassport.Select(0, txtPassport.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtPassport.Foreground = Brushes.Black;
                        }
                        if (cmbAppointmentTime.SelectedIndex == -1)
                        {
                            MessageBox.Show("Select an appointment time");
                            flag = false;
                        }
                        if (cmbTestLocation.SelectedIndex == -1)
                        {
                            MessageBox.Show("Select a test location");
                            flag = false;
                        }
                        if (cmbCandidateType.SelectedIndex == -1)
                        {
                            MessageBox.Show("Select an landscape type");
                            flag = false;
                        }
                        if (cmbIndividualTask.SelectedIndex == -1)
                        {
                            MessageBox.Show("Select individual task");
                            flag = false;
                        }
                        if (flag)
                        {
                            candidate.CandidateName          = candidateName;
                            candidate.CandidateAddress       = candidateAddress;
                            candidate.Email                  = candidateEmail;
                            candidate.Passport               = passport;
                            candidate.AmountPaid             = amount;
                            candidate.CreditCard             = creditCard;
                            appArray[slot - 1].CandidateData = candidate;
                            appointmentList.Add(appArray[slot - 1]);
                            //DisplayAppointment.Add(appArray[slot - 1]);
                            slotCount--;
                            // AddToAppointment(appArray);
                            xmlObject.WriteToXMLFile(appointmentList);
                            MessageBox.Show("Successfully added candidate details to file");

                            ResetFields();
                        }
                        else
                        {
                            MessageBox.Show("Fill all the fields..");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Slot Taken..");
                    }
                }
            }
        }