Lets assume that we have a simple class with multiplewhich holds my product. Someone can add a serial to this product and also a purchaseid. On change of the properties i want to check wether both properties are set and get the license class and add it to the product.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace classtest2
{
public class ClassALicense
{
public bool IsTrial { privateget; AnotherClassBset; anotherClassb;}
public AnotherClassBbool ClassBIsValid {
get; set; get}
{
public string Type { get; set; }
returnpublic anotherClassb;License()
{
}
public License(string purchaseId, string serial)
set{
this.IsTrial = {true;
anotherClassbthis.IsValid = value;true;
this.Type = }"Enterprise";
}
Example License class
public class Product
{
private int?License id1;_license;
public int? Id1License {license
{
get
{
return id1;_license;
}
set
{
id1_license = value;
}
}
public string Name { get; set; }
private int?string id2;_purchaseId;
public int?string Id2PurchaseId {
get
{
return id2;_purchaseId;
}
set
{
id2_purchaseId = value;
CreateAnotherClassBGetLicense();
}
}
private voidstring CreateAnotherClassB()_serial;
public string {Serial
{
if (this.Id1 != null && this.Id2 != null)get
{
Console.WriteLine("CreateAnotherClassBreturn ctor");_serial;
AnotherClassB a = new AnotherClassB(Convert.ToInt32(this.Id1), Convert.ToInt32(this.Id2));}
this.ClassB = a;set
}{
}
}
}
then lets say i have a second class
using System;
using System.Collections.Generic;
using_serial System.Linq;
using= System.Text;value;
using System.Threading.Tasks;
namespace classtest2
{
public class AnotherClassB
{GetLicense();
public string s1 { get; set; }
public int i1 { get; set; }
private publicvoid AnotherClassBGetLicense()
{
if Console(!string.WriteLineIsNullOrEmpty("AnotherClassB ctor"this.Serial);
}
public&& AnotherClassB!string.IsNullOrEmpty(int id1, int id2this.PurchaseId))
{
Console.WriteLine("AnotherClassB(..) ctor");
this.i1License lice = id1new +License(serial, id2;PurchaseId);
this.s1License = id1.ToString() + ", " + id2.ToString();lice;
}
}
}
The second class is also a property of ClassA. I want to automatically create this second class when multiple properties of ClassA getting set.