Example #1
0
        public bool CheckIsValid()
        {
            //bool result = true;

            if ((BYR == null) || (BYR.Equals("")))
            {
                return(false);
            }

            if ((IYR == null) || (IYR.Equals("")))
            {
                return(false);
            }

            if ((EYR == null) || (EYR.Equals("")))
            {
                return(false);
            }

            if ((HGT == null) || (HGT.Equals("")))
            {
                return(false);
            }

            if ((HCL == null) || (HCL.Equals("")))
            {
                return(false);
            }

            if ((ECL == null) || (ECL.Equals("")))
            {
                return(false);
            }

            if ((PID == null) || (PID.Equals("")))
            {
                return(false);
            }

            //if ((CID == null) || (CID.Equals("")))
            //    return false;
            return(true);
        }
Example #2
0
 public bool HCLValid()
 {
     if (HCL == null)
     {
         return(false);
     }
     else
     {
         if (HCL.Length != 7)
         {
             return(false);
         }
         string hexValue = HCL.Substring(1);
         char[] hexArray = hexValue.ToCharArray();
         foreach (char hex in hexArray)
         {
             return((hex >= '0' && hex <= '9') || (hex >= 'a' && hex <= 'f'));
         }
     }
     return(true);
 }
Example #3
0
        public bool CheckIsStrictValid()
        {
            //bool result = true;

            if ((BYR == null) || (BYR.Equals("")))
            {
                return(false);
            }
            else
            {
                try
                {
                    if (BYR.Length != 4)
                    {
                        return(false);
                    }

                    if (Convert.ToInt32(BYR) < 1920)
                    {
                        return(false);
                    }

                    if (Convert.ToInt32(BYR) > 2002)
                    {
                        return(false);
                    }
                }
                catch { return(false); }
            }

            if ((IYR == null) || (IYR.Equals("")))
            {
                return(false);
            }
            else
            {
                try
                {
                    if (IYR.Length != 4)
                    {
                        return(false);
                    }

                    if (Convert.ToInt32(IYR) < 2010)
                    {
                        return(false);
                    }

                    if (Convert.ToInt32(IYR) > 2020)
                    {
                        return(false);
                    }
                }
                catch { return(false); }
            }

            if ((EYR == null) || (EYR.Equals("")))
            {
                return(false);
            }
            else
            {
                try
                {
                    if (EYR.Length != 4)
                    {
                        return(false);
                    }

                    if (Convert.ToInt32(EYR) < 2020)
                    {
                        return(false);
                    }

                    if (Convert.ToInt32(EYR) > 2030)
                    {
                        return(false);
                    }
                }
                catch { return(false); }
            }


            if ((HGT == null) || (HGT.Equals("")))
            {
                return(false);
            }
            else
            {
                try
                {
                    if (HGT.Contains("cm"))
                    {
                        int number = Convert.ToInt32(HGT.Replace("cm", "").Trim());

                        if (number < 150)
                        {
                            return(false);
                        }

                        if (number > 193)
                        {
                            return(false);
                        }
                    }
                    else if (HGT.Contains("in"))
                    {
                        int number = Convert.ToInt32(HGT.Replace("in", "").Trim());

                        if (number < 59)
                        {
                            return(false);
                        }

                        if (number > 76)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch { return(false); }
            }

            if ((HCL == null) || (HCL.Equals("")))
            {
                return(false);
            }
            else
            {
                try
                {
                    if (!HCL.Contains("#"))
                    {
                        return(false);
                    }

                    if (HCL.Length != 7)
                    {
                        return(false);
                    }

                    string working = HCL;
                    working = working.Replace("#", "");

                    foreach (char c in working)
                    {
                        if ((c != '0') &&
                            (c != '1') &&
                            (c != '2') &&
                            (c != '3') &&
                            (c != '4') &&
                            (c != '5') &&
                            (c != '6') &&
                            (c != '7') &&
                            (c != '8') &&
                            (c != '9') &&
                            (c != 'a') &&
                            (c != 'b') &&
                            (c != 'c') &&
                            (c != 'd') &&
                            (c != 'e') &&
                            (c != 'f'))
                        {
                            return(false);
                        }
                    }
                }
                catch { return(false); }
            }

            if ((ECL == null) || (ECL.Equals("")))
            {
                return(false);
            }
            else
            {
                try
                {
                    if (!(ECL.Equals("amb")) &&
                        !(ECL.Equals("blu")) &&
                        !(ECL.Equals("brn")) &&
                        !(ECL.Equals("gry")) &&
                        !(ECL.Equals("grn")) &&
                        !(ECL.Equals("hzl")) &&
                        !(ECL.Equals("oth")))
                    {
                        return(false);
                    }
                }
                catch { return(false); }
            }

            if ((PID == null) || (PID.Equals("")))
            {
                return(false);
            }
            else
            {
                try
                {
                    if (PID.Length != 9)
                    {
                        return(false);
                    }

                    Convert.ToInt32(PID.Trim());
                }
                catch { return(false); }
            }

            //if ((CID == null) || (CID.Equals("")))
            //    return false;
            return(true);
        }