-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented a part of the PhysicalFSManager
- Loading branch information
1 parent
9c9a3bc
commit 9cf0b9f
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { PhysicalResource } from '../resource/PhysicalResource'; | ||
import { IResource, ResourceType } from '../resource/Resource'; | ||
import { FSManager } from './FSManager'; | ||
export declare class PhysicalFSManager implements FSManager { | ||
private static _instance; | ||
static instance(): PhysicalFSManager; | ||
serialize(resource: any): object; | ||
unserialize(serializedResource: { | ||
realPath: string; | ||
isFile: boolean; | ||
}): PhysicalResource; | ||
newResource(fullPath: string, name: string, type: ResourceType, parent: IResource): IResource; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var PhysicalResource_1 = require("../resource/PhysicalResource"); | ||
var PhysicalFSManager = (function () { | ||
function PhysicalFSManager() { | ||
} | ||
PhysicalFSManager.instance = function () { | ||
if (!this._instance) | ||
this._instance = new PhysicalFSManager(); | ||
return this._instance; | ||
}; | ||
PhysicalFSManager.prototype.serialize = function (resource) { | ||
if (!resource.realPath) | ||
throw new Error('Unrocognized resource'); | ||
return { realPath: resource.realPath, isFile: resource.constructor === PhysicalResource_1.PhysicalFile }; | ||
}; | ||
PhysicalFSManager.prototype.unserialize = function (serializedResource) { | ||
if (serializedResource.realPath) { | ||
if (serializedResource.isFile) | ||
return new PhysicalResource_1.PhysicalFile(serializedResource.realPath, null, this); | ||
else | ||
return new PhysicalResource_1.PhysicalFolder(serializedResource.realPath, null, this); | ||
} | ||
throw new Error('Unrocognized resource'); | ||
}; | ||
PhysicalFSManager.prototype.newResource = function (fullPath, name, type, parent) { | ||
throw new Error('Not implemented yet'); | ||
}; | ||
return PhysicalFSManager; | ||
}()); | ||
exports.PhysicalFSManager = PhysicalFSManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { PhysicalFile, PhysicalFolder, PhysicalResource } from '../resource/PhysicalResource' | ||
import { IResource, ResourceType } from '../resource/Resource' | ||
import { FSManager } from './FSManager' | ||
|
||
export class PhysicalFSManager implements FSManager | ||
{ | ||
private static _instance : PhysicalFSManager; | ||
static instance() | ||
{ | ||
if(!this._instance) | ||
this._instance = new PhysicalFSManager(); | ||
return this._instance; | ||
} | ||
|
||
serialize(resource : any) : object | ||
{ | ||
if(!resource.realPath) | ||
throw new Error('Unrocognized resource'); | ||
|
||
return { realPath: resource.realPath, isFile: resource.constructor === PhysicalFile }; | ||
} | ||
unserialize(serializedResource : { realPath : string, isFile : boolean }) : PhysicalResource | ||
{ | ||
if(serializedResource.realPath) | ||
{ | ||
if(serializedResource.isFile) | ||
return new PhysicalFile(serializedResource.realPath, null, this); | ||
else | ||
return new PhysicalFolder(serializedResource.realPath, null, this); | ||
} | ||
|
||
throw new Error('Unrocognized resource'); | ||
} | ||
|
||
newResource(fullPath : string, name : string, type : ResourceType, parent : IResource) : IResource | ||
{ | ||
throw new Error('Not implemented yet'); | ||
} | ||
} |