public static IToyota CreateInstance(ToyotaType toyotaType) { IToyota toyota; switch (toyotaType) { case ToyotaType.Alphard: toyota = new Alphard(); break; case ToyotaType.Camry: toyota = new Camry(); break; case ToyotaType.Corolla: toyota = new Corolla(); break; default: throw new Exception("IToyota CreateInstance error..."); } return(toyota); }
public static IToyota CreateInstanceConfig() { ToyotaType toyotaType = (ToyotaType)Enum.Parse(typeof(ToyotaType), ToyotaTypeConfig);//字符串转枚举 IToyota toyota; switch (toyotaType) { case ToyotaType.Alphard: toyota = new Alphard(); break; case ToyotaType.Camry: toyota = new Camry(); break; case ToyotaType.Corolla: toyota = new Corolla(); break; default: throw new Exception("IToyota CreateInstance error..."); } return(toyota); }