I have a simple class which holds my product. Someone can add a serial to this product and also a purchase id. On change of the properties, I want to check whether both properties are set, and get the license class and add it to the product.
public class License
{
public bool IsTrial { get; set; }
public bool IsValid { get; set; }
public string Type { get; set; }
public License()
{
}
public License(string purchaseId, string serial)
{
this.IsTrial = true;
this.IsValid = true;
this.Type = "Enterprise";
}
Example License class
public class Product
{
private License _license;
public License license
{
get
{
return _license;
}
set
{
_license = value;
}
}
public string Name { get; set; }
private string _purchaseId;
public string PurchaseId {
get
{
return _purchaseId;
}
set
{
_purchaseId = value;
GetLicense();
}
}
private string _serial;
public string Serial
{
get
{
return _serial;
}
set
{
_serial = value;
GetLicense();
}
}
private void GetLicense()
{
if (!string.IsNullOrEmpty(this.Serial) && !string.IsNullOrEmpty(this.PurchaseId))
{
License lice = new License(serial, PurchaseId);
this.License = lice;
}
}
That's the approach I used. Is this a correct way to do it? How is this called and what is the best practice? I need to use .NET Framework 3.5.
this.ClassB = a
\$\endgroup\$