Exemplo n.º 1
0
        internal void GetInfo(FieldInfo i_Info, ref object io_ChoiseToReturn)
        {
            string fixName;

            fixName = GarageData.FixNameToPrint(i_Info.Name);

            string toAskUser = string.Format(@"Please Enter {0} :", fixName);

            if (i_Info.FieldType.IsEnum)
            {
                io_ChoiseToReturn = getEnumInfo(toAskUser, i_Info.FieldType.GetEnumNames());
            }
            else if (i_Info.FieldType == typeof(float?) || i_Info.FieldType == typeof(int?))
            {
                io_ChoiseToReturn = getNumericInfo(toAskUser);
            }
            else if (i_Info.FieldType == typeof(bool?))
            {
                io_ChoiseToReturn = getBoolInfo(toAskUser);
            }
            else ////Gets Any Info From User-the object class wil handle validation. To support futer members typs.
            {
                io_ChoiseToReturn = Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        private object getEnumInfo(string i_toAskUser, string[] i_EnumString)
        {
            int    numOfOption = 1, choise = 0;
            bool   goodInput = false;
            string userChoise;

            i_toAskUser += string.Format("\n The Options Are: ");

            foreach (string enumName in i_EnumString)
            {
                string fixedName = GarageData.FixNameToPrint(enumName);
                i_toAskUser += string.Format("\n {0}. {1} ", numOfOption, fixedName);
                numOfOption++;
            }

            Console.WriteLine(i_toAskUser);

            while (!goodInput)
            {
                try
                {
                    userChoise = getOnlyDigitsString();
                    choise     = int.Parse(userChoise);
                    Validation.IsInRange(choise, 0, numOfOption - 1);
                    goodInput = true;
                }
                catch (Exception ex)
                {
                    AnnounceError(ex);
                    Console.WriteLine(@"Please Enter Again:
");
                }
            }

            return(choise);
        }
Exemplo n.º 3
0
 public GarageManage(UI i_Ui)
 {
     m_UI   = i_Ui;
     m_Data = new GarageData();
 }