Skip to content

Commit 205f570

Browse files
committed
FormGroup for unlimited number of inheritance
1 parent 664a3d1 commit 205f570

File tree

10 files changed

+157
-77
lines changed

10 files changed

+157
-77
lines changed

DemoCoreWeb.ClientApi/WebApiClientAuto.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9631,18 +9631,9 @@ public class BigNumbers : object
96319631

96329632
[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
96339633
[System.SerializableAttribute()]
9634-
public class Company : DemoWebApi.DemoData.Base.Client.Entity
9634+
public class BizEntity : DemoWebApi.DemoData.Base.Client.Entity
96359635
{
96369636

9637-
/// <summary>
9638-
/// BusinessNumber to be serialized as BusinessNum
9639-
/// </summary>
9640-
[System.Runtime.Serialization.DataMember(Name="business_no")]
9641-
public string BusinessNumber { get; set; }
9642-
9643-
[System.Runtime.Serialization.DataMember()]
9644-
public string BusinessNumberType { get; set; }
9645-
96469637
/// <summary>
96479638
/// Data type: Date
96489639
/// </summary>
@@ -9652,6 +9643,21 @@ public class Company : DemoWebApi.DemoData.Base.Client.Entity
96529643

96539644
[System.Runtime.Serialization.DataMember()]
96549645
public System.DateOnly RegisterDate { get; set; }
9646+
}
9647+
9648+
[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
9649+
[System.SerializableAttribute()]
9650+
public class Company : DemoWebApi.DemoData.Client.BizEntity
9651+
{
9652+
9653+
/// <summary>
9654+
/// BusinessNumber to be serialized as BusinessNum
9655+
/// </summary>
9656+
[System.Runtime.Serialization.DataMember(Name="business_no")]
9657+
public string BusinessNumber { get; set; }
9658+
9659+
[System.Runtime.Serialization.DataMember()]
9660+
public string BusinessNumberType { get; set; }
96559661

96569662
[System.Runtime.Serialization.DataMember()]
96579663
public string[][] TextMatrix { get; set; }

DemoCoreWeb/Scripts/ClientApi/WebApiCoreJQClientAuto.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,19 +1652,22 @@ namespace DemoWebApi_DemoData_Client {
16521652
unsigned64?: string | null;
16531653
}
16541654

1655-
export interface Company extends DemoWebApi_DemoData_Base_Client.Entity {
1656-
1657-
/**
1658-
* BusinessNumber to be serialized as BusinessNum
1659-
*/
1660-
business_no?: string | null;
1661-
businessNumberType?: string | null;
1655+
export interface BizEntity extends DemoWebApi_DemoData_Base_Client.Entity {
16621656

16631657
/** Data type: Date */
16641658
foundDate?: Date | null;
16651659

16661660
/** Type: DateOnly */
16671661
registerDate?: Date | null;
1662+
}
1663+
1664+
export interface Company extends DemoWebApi_DemoData_Client.BizEntity {
1665+
1666+
/**
1667+
* BusinessNumber to be serialized as BusinessNum
1668+
*/
1669+
business_no?: string | null;
1670+
businessNumberType?: string | null;
16681671
textMatrix?: Array<Array<string>>;
16691672
int2D?: number[][];
16701673
int2DJagged?: Array<Array<number>>;

DemoWebApi.DemoDataCore/Entities.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,18 @@ public override string ToString()
254254
}
255255

256256
[DataContract(Namespace = Constants.DataNamespace)]
257-
public class Company : Entity
257+
public class BizEntity : Entity {
258+
259+
[DataMember]
260+
public DateOnly RegisterDate { get; set; }
261+
262+
[DataMember]
263+
[DataType(DataType.Date)]
264+
public DateTimeOffset FoundDate { get; set; }
265+
};
266+
267+
[DataContract(Namespace = Constants.DataNamespace)]
268+
public class Company : BizEntity
258269
{
259270
/// <summary>
260271
/// BusinessNumber to be serialized as BusinessNum
@@ -279,12 +290,6 @@ public string[][] TextMatrix
279290
[DataMember]
280291
public IEnumerable<string> Lines;
281292

282-
[DataMember]
283-
public DateOnly RegisterDate { get; set; }
284-
285-
[DataMember]
286-
[DataType(DataType.Date)]
287-
public DateTimeOffset FoundDate { get; set; }
288293
}
289294

290295
[DataContract(Namespace = Constants.DataNamespace)]

Fonlow.Poco2TsCore/Poco2TsGen.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,32 @@ public CodeTypeDeclaration LookupExistingClassOfCs(string namespaceText, string
741741
return null;
742742
}
743743

744+
///// <summary>
745+
///// Including namespace
746+
///// </summary>
747+
///// <param name="className"></param>
748+
///// <returns></returns>
749+
//public CodeTypeDeclaration LookupExistingClassOfCs(string className)
750+
//{
751+
// for (int i = 0; i < codeCompileUnit.Namespaces.Count; i++)
752+
// {
753+
// CodeNamespace ns = codeCompileUnit.Namespaces[i];
754+
// if (ns.Name == namespaceText + ClientNamespaceSuffix)
755+
// {
756+
// for (int k = 0; k < ns.Types.Count; k++)
757+
// {
758+
// CodeTypeDeclaration c = ns.Types[k];
759+
// if (c.Name == typeName)
760+
// {
761+
// return c;
762+
// }
763+
// }
764+
// }
765+
// }
766+
767+
// return null;
768+
//}
769+
744770
CodeTypeDeclaration AddCodeTypeDeclaration(Type type, bool dcOnly)
745771
{
746772
if (type.IsGenericTypeParameter && type.IsGenericParameter)

HeroesDemo/src/clientapi/WebApiCoreNG2FormGroupClientAuto.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,48 +1864,64 @@ export namespace DemoWebApi_DemoData_Client {
18641864

18651865
}
18661866

1867-
export interface Company extends DemoWebApi_DemoData_Base_Client.Entity {
1868-
1869-
/**
1870-
* BusinessNumber to be serialized as BusinessNum
1871-
*/
1872-
business_no?: string | null;
1873-
businessNumberType?: string | null;
1867+
export interface BizEntity extends DemoWebApi_DemoData_Base_Client.Entity {
18741868

18751869
/** Data type: Date */
18761870
foundDate?: Date | null;
18771871

18781872
/** Type: DateOnly */
18791873
registerDate?: Date | null;
1874+
}
1875+
export interface BizEntityFormProperties extends DemoWebApi_DemoData_Base_Client.EntityFormProperties {
1876+
1877+
/** Data type: Date */
1878+
foundDate: FormControl<Date | null | undefined>,
1879+
1880+
/** Type: DateOnly */
1881+
registerDate: FormControl<Date | null | undefined>,
1882+
}
1883+
export function CreateBizEntityFormGroup() {
1884+
return new FormGroup<BizEntityFormProperties>({
1885+
emailAddress: new FormControl<string | null | undefined>(undefined, [Validators.email, Validators.maxLength(255)]),
1886+
id: new FormControl<string | null | undefined>(undefined),
1887+
name: new FormControl<string | null | undefined>(undefined, [Validators.required, Validators.minLength(2), Validators.maxLength(255)]),
1888+
web: new FormControl<string | null | undefined>(undefined, [Validators.pattern('https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)')]),
1889+
foundDate: new FormControl<Date | null | undefined>(undefined),
1890+
registerDate: CreateDateOnlyFormControl(),
1891+
});
1892+
1893+
}
1894+
1895+
export interface Company extends DemoWebApi_DemoData_Client.BizEntity {
1896+
1897+
/**
1898+
* BusinessNumber to be serialized as BusinessNum
1899+
*/
1900+
business_no?: string | null;
1901+
businessNumberType?: string | null;
18801902
textMatrix?: Array<Array<string>>;
18811903
int2D?: number[][];
18821904
int2DJagged?: Array<Array<number>>;
18831905
lines?: Array<string>;
18841906
}
1885-
export interface CompanyFormProperties extends DemoWebApi_DemoData_Base_Client.EntityFormProperties {
1907+
export interface CompanyFormProperties extends DemoWebApi_DemoData_Client.BizEntityFormProperties {
18861908

18871909
/**
18881910
* BusinessNumber to be serialized as BusinessNum
18891911
*/
18901912
business_no: FormControl<string | null | undefined>,
18911913
businessNumberType: FormControl<string | null | undefined>,
1892-
1893-
/** Data type: Date */
1894-
foundDate: FormControl<Date | null | undefined>,
1895-
1896-
/** Type: DateOnly */
1897-
registerDate: FormControl<Date | null | undefined>,
18981914
}
18991915
export function CreateCompanyFormGroup() {
19001916
return new FormGroup<CompanyFormProperties>({
19011917
emailAddress: new FormControl<string | null | undefined>(undefined, [Validators.email, Validators.maxLength(255)]),
19021918
id: new FormControl<string | null | undefined>(undefined),
19031919
name: new FormControl<string | null | undefined>(undefined, [Validators.required, Validators.minLength(2), Validators.maxLength(255)]),
19041920
web: new FormControl<string | null | undefined>(undefined, [Validators.pattern('https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)')]),
1905-
business_no: new FormControl<string | null | undefined>(undefined),
1906-
businessNumberType: new FormControl<string | null | undefined>(undefined),
19071921
foundDate: new FormControl<Date | null | undefined>(undefined),
19081922
registerDate: CreateDateOnlyFormControl(),
1923+
business_no: new FormControl<string | null | undefined>(undefined),
1924+
businessNumberType: new FormControl<string | null | undefined>(undefined),
19091925
});
19101926

19111927
}

HeroesDemo/src/clientapi/WebApiCoreNg2ClientAuto.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,19 +1662,22 @@ export namespace DemoWebApi_DemoData_Client {
16621662
unsigned64?: string | null;
16631663
}
16641664

1665-
export interface Company extends DemoWebApi_DemoData_Base_Client.Entity {
1666-
1667-
/**
1668-
* BusinessNumber to be serialized as BusinessNum
1669-
*/
1670-
business_no?: string | null;
1671-
businessNumberType?: string | null;
1665+
export interface BizEntity extends DemoWebApi_DemoData_Base_Client.Entity {
16721666

16731667
/** Data type: Date */
16741668
foundDate?: Date | null;
16751669

16761670
/** Type: DateOnly */
16771671
registerDate?: Date | null;
1672+
}
1673+
1674+
export interface Company extends DemoWebApi_DemoData_Client.BizEntity {
1675+
1676+
/**
1677+
* BusinessNumber to be serialized as BusinessNum
1678+
*/
1679+
business_no?: string | null;
1680+
businessNumberType?: string | null;
16781681
textMatrix?: Array<Array<string>>;
16791682
int2D?: number[][];
16801683
int2DJagged?: Array<Array<number>>;

WebApiClientGenCore.NG2FormGroup/CodeObjectHelperForNg2FormGroup.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CodeObjectHelperForNg2FormGroup : CodeObjectHelper
1717
readonly CodeNamespaceCollection codeNamespaceCollection;
1818
readonly bool careForDateOnly;
1919

20-
public CodeObjectHelperForNg2FormGroup(CodeNamespaceCollection codeNamespaceCollection, bool careForDateOnly=false) : base(true)
20+
public CodeObjectHelperForNg2FormGroup(CodeNamespaceCollection codeNamespaceCollection, bool careForDateOnly = false) : base(true)
2121
{
2222
this.codeNamespaceCollection = codeNamespaceCollection;
2323
this.careForDateOnly = careForDateOnly;
@@ -414,14 +414,8 @@ void WriteAngularFormGroupMembersAndCloseBracing(CodeTypeDeclaration typeDeclara
414414
CodeTypeReference parentTypeReference = typeDeclaration.BaseTypes[0];
415415
string parentTypeName = TypeMapper.MapCodeTypeReferenceToTsText(parentTypeReference); //namspace prefix included
416416
//Console.WriteLine("parentTypeName: " + parentTypeName);
417-
CodeTypeDeclaration parentCodeTypeDeclaration = FindCodeTypeDeclaration(parentTypeName);
418-
if (parentCodeTypeDeclaration != null)
419-
{
420-
for (int i = 0; i < parentCodeTypeDeclaration.Members.Count; i++)
421-
{
422-
WriteCodeTypeMemberOfAngularFormGroup(parentCodeTypeDeclaration.Members[i], w, o);
423-
};
424-
}
417+
418+
WriteAngularFormGroupMembersOfParent(parentTypeName, w, o);
425419
}
426420

427421
for (int i = 0; i < typeDeclaration.Members.Count; i++)
@@ -434,6 +428,24 @@ void WriteAngularFormGroupMembersAndCloseBracing(CodeTypeDeclaration typeDeclara
434428
}
435429
}
436430

431+
void WriteAngularFormGroupMembersOfParent(string parentTypeName, TextWriter w, CodeGeneratorOptions o)
432+
{
433+
CodeTypeDeclaration parentCodeTypeDeclaration = FindCodeTypeDeclaration(parentTypeName);
434+
if (parentCodeTypeDeclaration != null)
435+
{
436+
if (parentCodeTypeDeclaration.BaseTypes.Count >0){
437+
CodeTypeReference grantParentTypeReference = parentCodeTypeDeclaration.BaseTypes[0];
438+
string grantParentTypeName = TypeMapper.MapCodeTypeReferenceToTsText(grantParentTypeReference);
439+
WriteAngularFormGroupMembersOfParent(grantParentTypeName, w, o);
440+
};
441+
442+
for (int i = 0; i < parentCodeTypeDeclaration.Members.Count; i++)
443+
{
444+
WriteCodeTypeMemberOfAngularFormGroup(parentCodeTypeDeclaration.Members[i], w, o);
445+
};
446+
}
447+
}
448+
437449
/// <summary>
438450
///
439451
/// </summary>

aurelia/src/clientapi/WebApiCoreAureliaClientAuto.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,19 +1661,22 @@ export namespace DemoWebApi_DemoData_Client {
16611661
unsigned64?: string | null;
16621662
}
16631663

1664-
export interface Company extends DemoWebApi_DemoData_Base_Client.Entity {
1665-
1666-
/**
1667-
* BusinessNumber to be serialized as BusinessNum
1668-
*/
1669-
business_no?: string | null;
1670-
businessNumberType?: string | null;
1664+
export interface BizEntity extends DemoWebApi_DemoData_Base_Client.Entity {
16711665

16721666
/** Data type: Date */
16731667
foundDate?: Date | null;
16741668

16751669
/** Type: DateOnly */
16761670
registerDate?: Date | null;
1671+
}
1672+
1673+
export interface Company extends DemoWebApi_DemoData_Client.BizEntity {
1674+
1675+
/**
1676+
* BusinessNumber to be serialized as BusinessNum
1677+
*/
1678+
business_no?: string | null;
1679+
businessNumberType?: string | null;
16771680
textMatrix?: Array<Array<string>>;
16781681
int2D?: number[][];
16791682
int2DJagged?: Array<Array<number>>;

axios/src/clientapi/WebApiCoreAxiosClientAuto.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,19 +1652,22 @@ export namespace DemoWebApi_DemoData_Client {
16521652
unsigned64?: string | null;
16531653
}
16541654

1655-
export interface Company extends DemoWebApi_DemoData_Base_Client.Entity {
1656-
1657-
/**
1658-
* BusinessNumber to be serialized as BusinessNum
1659-
*/
1660-
business_no?: string | null;
1661-
businessNumberType?: string | null;
1655+
export interface BizEntity extends DemoWebApi_DemoData_Base_Client.Entity {
16621656

16631657
/** Data type: Date */
16641658
foundDate?: Date | null;
16651659

16661660
/** Type: DateOnly */
16671661
registerDate?: Date | null;
1662+
}
1663+
1664+
export interface Company extends DemoWebApi_DemoData_Client.BizEntity {
1665+
1666+
/**
1667+
* BusinessNumber to be serialized as BusinessNum
1668+
*/
1669+
business_no?: string | null;
1670+
businessNumberType?: string | null;
16681671
textMatrix?: Array<Array<string>>;
16691672
int2D?: number[][];
16701673
int2DJagged?: Array<Array<number>>;

fetchapi/src/clientapi/WebApiCoreFetchClientAuto.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,19 +1650,22 @@ export namespace DemoWebApi_DemoData_Client {
16501650
unsigned64?: string | null;
16511651
}
16521652

1653-
export interface Company extends DemoWebApi_DemoData_Base_Client.Entity {
1654-
1655-
/**
1656-
* BusinessNumber to be serialized as BusinessNum
1657-
*/
1658-
business_no?: string | null;
1659-
businessNumberType?: string | null;
1653+
export interface BizEntity extends DemoWebApi_DemoData_Base_Client.Entity {
16601654

16611655
/** Data type: Date */
16621656
foundDate?: Date | null;
16631657

16641658
/** Type: DateOnly */
16651659
registerDate?: Date | null;
1660+
}
1661+
1662+
export interface Company extends DemoWebApi_DemoData_Client.BizEntity {
1663+
1664+
/**
1665+
* BusinessNumber to be serialized as BusinessNum
1666+
*/
1667+
business_no?: string | null;
1668+
businessNumberType?: string | null;
16661669
textMatrix?: Array<Array<string>>;
16671670
int2D?: number[][];
16681671
int2DJagged?: Array<Array<number>>;

0 commit comments

Comments
 (0)