import { GenericFile } from '../common/generic-file' ; import { IFileDescription } from '../common/i-file-description' ; import { SerializationService } from '../../model/serialization.service' ; import { IFile } from '../common/i-file' ; interface SerializedFormV1 { version : '1' ; type : 'github' ; description : string ; name : string ; size : number ; content : string ; sha : string ; } export class GithubFile extends GenericFile { sha ? : string ; static deserialize ( serializationService , serializedForm ) { const v1Object = JSON . parse ( serializedForm ) ; return new GithubFile ( serializationService . deserializeIFileDescription ( v1Object . description ) , v1Object . name , v1Object . size , v1Object . content , v1Object . sha ) ; } constructor ( _description , _name , _size , _content , _sha ) { super ( _description , _name , _size , _content ) ; this . sha = _sha ; } public serialize ( serializationService ) { return JSON . stringify ( { version : '1' , type : 'github' , description : this . description . serialize ( serializationService ) , name : this . name , size : this . size , content : this . content , sha : this . sha } as SerializedFormV1 ) ; } param newContent public copyWithNewContent ( newContent ) { return new GithubFile ( this . description , this . name , newContent . length , newContent , this . sha ) ; } param saveAs copyForNewDescription ( saveAs ) { return new GithubFile ( saveAs , this . name , this . content . length , this . content , this . sha ) ; } }