Skip to content

Commit

Permalink
Structured type (#322)
Browse files Browse the repository at this point in the history
* Added Pre and PostConstruct in StructuredType

* Repaired test

---------

Co-authored-by: Peter Kurhajec <[email protected]>
  • Loading branch information
Brano5 and PTKu authored Jun 28, 2024
1 parent e9e1e9e commit b910690
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ public static CsOnlinerConstructorBuilder Create(IxNodeVisitor visitor, IStructu
HumanReadable = {typeof(Connector.Connector).n()}.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = {typeof(Connector.Connector).n()}.CreateSymbol(parent.Symbol, symbolTail);");

builder.AddToSource(@$"PreConstruct(parent, readableTail, symbolTail);");

semantics.Fields.ToList().ForEach(p => p.Accept(visitor, builder));
builder.AddToSource("parent.AddChild(this);");
builder.AddToSource("parent.AddKid(this);");

builder.AddToSource(@$"PostConstruct(parent, readableTail, symbolTail);");

builder.AddToSource("}");

return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ public static CsOnlinerMemberBuilder Create(IxNodeVisitor visitor, IStructuredTy
var builder = new CsOnlinerMemberBuilder(sourceBuilder);
builder.AddToSource(semantics.DeclareProperties());
semantics.Fields.ToList().ForEach(p => p.Accept(visitor, builder));

builder.AddToSource(@$"partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);");

return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1157,16 +1157,20 @@ public partial class Motor : AXSharp.Connector.ITwinObject
{
public OnlinerBool isRunning { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down Expand Up @@ -1363,17 +1367,21 @@ public partial class Vehicle : AXSharp.Connector.ITwinObject

public OnlinerInt displacement { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
m = new misc.Motor(this, "m", "m");
displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,16 +867,20 @@ public partial class Motor : AXSharp.Connector.ITwinObject
{
public OnlinerBool isRunning { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down Expand Up @@ -1073,17 +1077,21 @@ public partial class Vehicle : AXSharp.Connector.ITwinObject

public OnlinerInt displacement { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
m = new Motor(this, "m", "m");
displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,16 +705,20 @@ public partial class Motor : AXSharp.Connector.ITwinObject
{
public OnlinerBool isRunning { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down Expand Up @@ -911,17 +915,21 @@ public partial class Vehicle : AXSharp.Connector.ITwinObject

public OnlinerInt displacement { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
m = new misc.Motor(this, "m", "m");
displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,20 @@ public partial class struct1 : AXSharp.Connector.ITwinObject
{
public struct2 s2 { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public struct1(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
s2 = new struct2(this, "s2", "s2");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down Expand Up @@ -471,16 +475,20 @@ public partial class struct2 : AXSharp.Connector.ITwinObject
{
public struct3 s3 { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public struct2(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
s3 = new struct3(this, "s3", "s3");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down Expand Up @@ -681,16 +689,20 @@ public partial class struct3 : AXSharp.Connector.ITwinObject
{
public struct4 s4 { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public struct3(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
s4 = new struct4(this, "s4", "s4");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down Expand Up @@ -891,16 +903,20 @@ public partial class struct4 : AXSharp.Connector.ITwinObject
{
public OnlinerInt s5 { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public struct4(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
s5 = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "s5", "s5");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ public partial class Motor : AXSharp.Connector.ITwinObject
{
public OnlinerBool isRunning { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down Expand Up @@ -214,17 +218,21 @@ public partial class Vehicle : AXSharp.Connector.ITwinObject

public OnlinerInt displacement { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
m = new Motor(this, "m", "m");
displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ public partial class Motor : AXSharp.Connector.ITwinObject
{
public OnlinerBool isRunning { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Motor(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
isRunning = @Connector.ConnectorAdapter.AdapterFactory.CreateBOOL(this, "isRunning", "isRunning");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down Expand Up @@ -217,17 +221,21 @@ public partial class Vehicle : AXSharp.Connector.ITwinObject

public OnlinerInt displacement { get; }

partial void PreConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
partial void PostConstruct(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail);
public Vehicle(AXSharp.Connector.ITwinObject parent, string readableTail, string symbolTail)
{
this.@SymbolTail = symbolTail;
this.@Connector = parent.GetConnector();
this.@Parent = parent;
HumanReadable = AXSharp.Connector.Connector.CreateHumanReadable(parent.HumanReadable, readableTail);
Symbol = AXSharp.Connector.Connector.CreateSymbol(parent.Symbol, symbolTail);
PreConstruct(parent, readableTail, symbolTail);
m = new TypeWithNameAttributes.Motor(this, "m", "m");
displacement = @Connector.ConnectorAdapter.AdapterFactory.CreateINT(this, "displacement", "displacement");
parent.AddChild(this);
parent.AddKid(this);
PostConstruct(parent, readableTail, symbolTail);
}

public async virtual Task<T> OnlineToPlain<T>()
Expand Down

0 comments on commit b910690

Please sign in to comment.