コード例 #1
0
ファイル: Motorcycle.cs プロジェクト: NadavPorat/B21-Ex03
 public override void SetInfo(FieldInfo i_FieldInfo, Object i_ValueToPut)
 {
     if (i_FieldInfo.FieldType == m_LicenseType.GetType())
     {
         m_LicenseType = (eLisenceType)i_ValueToPut;
     }
     else if (i_FieldInfo.FieldType == typeof(int?))
     {
         m_EngineCapacity = (int)(i_ValueToPut as float?);
     }
 }
コード例 #2
0
        public Motorcycle(Dictionary <string, string> i_MotorcycleInfo)
            : base(i_MotorcycleInfo)
        {
            //bool isValidLicenseType = Enum.TryParse(i_MotorcycleInfo["License Type"], out m_LicenseType);
            try
            {
                this.m_LicenseType = (eLisenceType)Enum.Parse(typeof(eLisenceType), i_MotorcycleInfo["License Type"]);
            }
            catch (ArgumentException ae)
            {
                throw new ArgumentException("the license type is only: A, A1, A2, A3");
            }

            this.m_EngineVolume = Validation.StringToInt(i_MotorcycleInfo["Engine Volume"]);
        }