private void Add_StaticConstructor() { var cw = Ext.Create(GetType()); var array = new CsArguments(_relatedUnit.Units.Select(q => q.FieldName).ToArray()); array.CreateArray(cw, "All = "); var c = Target.AddConstructor().WithStatic().WithBody(cw); Target.AddField("All", AllPropertyTypeName).WithStatic().WithIsReadOnly() .Description = $"All known {Cfg.TargetUnitTypename.FirstLower()} units"; }
private void Add_AllProperty() { var cw = new CsCodeWriter(); var array = new CsArguments(Cfg.Units.Select(q => q.FieldName).ToArray()); array.CreateArray(cw, "return "); Target.AddProperty("All", "IReadOnlyList<UnitDefinition<" + Cfg.Name + "Unit>>") .WithIsPropertyReadOnly() .WithNoEmitField() .WithStatic() .WithOwnGetter(cw.Code) .Description = $"All known {Cfg.Name.FirstLower()} units"; }