入力に基づいて、データを別の C# オブジェクトに保存する必要があります。
「productChoice」の値に基づいて、私のプログラムは対応するクラスにデータを保存する必要があります。
例えば :
productChoice = "auto" の場合、データは AutoDataprefill オブジェクトに設定する必要があります。
productChoice = "vehicle" の場合、データは VehicleMileage オブジェクトに設定する必要があります。
私の注文クラス:
public class Order
{
public Products products {get;set;}
}
私の製品クラス:
public class Products
{
public productChoiceType products { get; set; }
}
私のproductChoiceTypeクラス:
public class productChoiceType
{
public string productChoice { get; set; }
public AutoDataprefill auto_dataprefill { get; set; }
public VehicleMileage vehicle_mileage { get; set; }
public ClaimsDiscovery claims_discovery { get; set; }
public PropertyDataprefill property_dataprefill { get; set; }
public List productList { get; set; }
}
public class AutoDataprefill
{
public Parameter parameter { get; set; }
public Pnc pnc { get; set; }
public ProductReturnFormat format { get; set; }
public string primary_subject { get; set; } // Attribute // IDREF
}
public class VehicleMileage
{
public string usage { get; set; }
public VmrReportType report_type { get; set; }
public Vehicles vehicles { get; set; }
public string subject { get; set; } //Attribute // IDREF
}
「注文」のインスタンスを作成し、データを対応するオブジェクトに保存するコードは次のとおりです。
CLUEAuto.Personal.BusinessEntities.Order nwOrder = new CLUEAuto.Personal.BusinessEntities.Order
{
products = new CLUEAuto.Personal.BusinessEntities.Products
{
products = new CLUEAuto.Personal.BusinessEntities.productChoiceType
{
/* if (productChoice == "auto")
{Parameter = , Pnc = ,.... }
elseif (productChoice == "vehicle")
{usage = , reportType = , ....} */
???
}
}
}