Instantiating a property when the required attributes have been set
Getters &amp; Setters + Validation

I think it's better to validate the serial and the purchase-id in their setters instead in the GetLicense method that actually could be a readonly-property.


private void GetLicense()
{
    if (!string.IsNullOrEmpty(this.Serial) &amp;&amp; !string.IsNullOrEmpty(this.PurchaseId))
    { 
        License lice = new License(serial, PurchaseId);
        this.License = lice;
    }
}



After this tiny refactorings the result is:

public class Product
{
    // it's prettier if you group private fields togehter at the top
    private string _purchaseId;
    private string _serial;   

    public string Name { get; set; }

    public string PurchaseId
    {
        get { return _purchaseId; }
        set
        {
            if (string.IsNullOrEmpty(value)) 
                throw new ArgumentNullException(nameof(PurchaseId));
            _purchaseId = value;
        }
    }


    public string Serial
    {
        get { return _serial; }
        set
        {
            if (string.IsNullOrEmpty(value)) 
                throw new ArgumentNullException(nameof(Serial));
            _serial = value;
        }
    }   

    public License License
    {
        get { new License(Serial, PurchaseId); }
    }
}




Magic Strings


  this.Type = "Enterprise";


You should create a const/readonly string for the "Enterprise" and name it for example DefaultLicenseType



Bug

There is a bug. The license constructor expects purchaseId + serial and you create a license with a serial + purchase id

Constructor signature:

public License(string purchaseId, string serial)


License creation:

new License(serial, PurchaseId);