1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
module SCA.DTO {
export class BaseDTO {
// id auto
IsSelected= ko.observable<Boolean>();
//#region Constructeur
/** Contructeur
* author : yoyo88 25/02/2016
*/
constructor(protected Controlleur?: string, pObjectJSON?: any) {
if (pObjectJSON != null) {
this.AffectationValeur(pObjectJSON);
}
}
//#endregion Constructeur
//#region Methode
/** Affectation des valeur de l'objet JSON
*
* author : yoyo88 13/05/2016
*/
protected AffectationValeur(pObjectJSON: any) {
if (typeof pObjectJSON != "undefined") {
//Recuperation des variable
var lListKey = Object.keys(pObjectJSON);
// pour chaque variable de l'object JSON
for (var key in Object.keys(pObjectJSON)) {
// affectation de la variable
if (typeof this[lListKey[key]]() == "object") {
}
else {
this[lListKey[key]](pObjectJSON[lListKey[key]]);
}
}
}
}
/** Recuperation du controlleur
*
* author : yoyo88 25/02/2016
*/
public GetControlleur(): string {
return this.Controlleur;
}
/** Convertion en JSON
* author : yoyo88 25/02/2016
*/
public ToJSON(): string {
// supression du controlleur et convertion en JSON
return ko.mapping.toJSON(this, { 'ignore': ["Controlleur"] });
}
/** Convertion en object pouvant etre envoyez au controlleur
* author : yoyo88 25/02/2016
*/
public ToObject(): any {
// convertion en object pouvant etre passer au controller
return JSON.parse(this.ToJSON());
}
/** Permet de recharger le DTO
* author : yoyo88 25/02/2016
*/
public Reload(){
// rechargement de lobjet
this = HelperAjax.ReloadDTO(this);
}
//#endregion Methode
}
} |
Partager