TestClasses.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. module BABYLON {
  2. @className("Address")
  3. export class Address extends PropertyChangedBase {
  4. public get street(): string {
  5. return this._street;
  6. }
  7. public set street(value: string) {
  8. if (value === this._street) {
  9. return;
  10. }
  11. let old = this._street;
  12. this._street = value;
  13. this.onPropertyChanged("street", old, value);
  14. }
  15. public get city(): string {
  16. return this._city;
  17. }
  18. public set city(value: string) {
  19. if (value === this._city) {
  20. return;
  21. }
  22. let old = this._city;
  23. this._city = value;
  24. this.onPropertyChanged("city", old, value);
  25. }
  26. public get postalCode(): string {
  27. return this._postalCode;
  28. }
  29. public set postalCode(value: string) {
  30. if (value === this._postalCode) {
  31. return;
  32. }
  33. let old = this._postalCode;
  34. this._postalCode = value;
  35. this.onPropertyChanged("postalCode", old, value);
  36. }
  37. private _street: string;
  38. private _city: string;
  39. private _postalCode: string;
  40. }
  41. @className("Customer")
  42. export class Customer extends PropertyChangedBase {
  43. /**
  44. * Customer First Name
  45. **/
  46. public get firstName(): string {
  47. return this._firstName;
  48. }
  49. public set firstName(value: string) {
  50. if (value === this._firstName) {
  51. return;
  52. }
  53. let old = this._firstName;
  54. this._firstName = value;
  55. this.onPropertyChanged("firstName", old, value);
  56. }
  57. /**
  58. * Customer Last Name
  59. **/
  60. public get lastName(): string {
  61. return this._lastName;
  62. }
  63. public set lastName(value: string) {
  64. if (value === this._lastName) {
  65. return;
  66. }
  67. let old = this._lastName;
  68. this._lastName = value;
  69. this.onPropertyChanged("lastName", old, value);
  70. }
  71. /**
  72. * Customer Main Address
  73. **/
  74. public get mainAddress(): Address {
  75. if (!this._mainAddress) {
  76. this._mainAddress = new Address();
  77. }
  78. return this._mainAddress;
  79. }
  80. public set mainAddress(value: Address) {
  81. if (value === this._mainAddress) {
  82. return;
  83. }
  84. let old = this._mainAddress;
  85. this._mainAddress = value;
  86. this.onPropertyChanged("mainAddress", old, value);
  87. }
  88. public get age(): number {
  89. return this._age;
  90. }
  91. public set age(value: number) {
  92. if (value === this._age) {
  93. return;
  94. }
  95. let old = this._age;
  96. this._age = value;
  97. this.onPropertyChanged("age", old, value);
  98. }
  99. private _firstName: string;
  100. private _lastName: string;
  101. private _mainAddress: Address;
  102. private _age: number;
  103. }
  104. @className("CustomerViewModel")
  105. export class CustomerViewModel extends SmartPropertyBase {
  106. public static firstNameProperty: Prim2DPropInfo;
  107. public static ageProperty: Prim2DPropInfo;
  108. public static cityProperty: Prim2DPropInfo;
  109. constructor() {
  110. super();
  111. }
  112. @BABYLON.dependencyProperty(0, pi => CustomerViewModel.ageProperty = pi)
  113. public get age(): number {
  114. return this._age;
  115. }
  116. public set age(value: number) {
  117. this._age = value;
  118. }
  119. @BABYLON.dependencyProperty(1, pi => CustomerViewModel.cityProperty = pi)
  120. public get city(): string {
  121. return this._city;
  122. }
  123. public set city(value: string) {
  124. this._city = value;
  125. }
  126. @BABYLON.dependencyProperty(2, pi => CustomerViewModel.firstNameProperty = pi, DataBinding.MODE_ONETIME)
  127. public get firstName(): string {
  128. return this._firstName;
  129. }
  130. public set firstName(value: string) {
  131. this._firstName = value;
  132. }
  133. private _age: number;
  134. private _city: string;
  135. private _firstName: string;
  136. }
  137. }