From 1d55f70e34b851d9bd2c9a855fb923e64db70ffb Mon Sep 17 00:00:00 2001 From: Anand Prakash Date: Sun, 27 Apr 2014 17:29:43 -0700 Subject: [PATCH] Fixed local, roaming and temp definitions on WinJS.Application object. These should be instances on IOHelper as defined in WinJS. --- winjs/winjs.d.ts | 161 +++++++++++++++-------------------------------- 1 file changed, 49 insertions(+), 112 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 20263a3bb9..d14238eeeb 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -25,7 +25,49 @@ and limitations under the License. **/ interface Element { winControl: any; // TODO: This should be control? -}/** +} + +/** + * Utility class for easy access to operations on application folders +**/ +interface IOHelper { + /** + * Instance of the currently wrapped application folder + **/ + folder: Windows.Storage.StorageFolder; + + /** + * Determines whether the specified file exists in the folder. + * @param filename The name of the file. + * @returns A promise that completes with a value of either true (if the file exists) or false. + **/ + exists(filename: string): WinJS.Promise; + + /** + * Reads the specified file. If the file doesn't exist, the specified default value is returned. + * @param fileName The file to read from. + * @param def The default value to be returned if the file failed to open. + * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. + **/ + readText(fileName: string, def?: string): WinJS.Promise; + + /** + * Deletes a file from the folder. + * @param fileName The file to be deleted. + * @returns A promise that is fulfilled when the file has been deleted. + **/ + remove(fileName: string): WinJS.Promise; + + /** + * Writes the specified text to the specified file. + * @param fileName The name of the file. + * @param text The content to be written to the file. + * @returns A promise that completes with a value that is the number of characters written. + **/ + writeText(fileName: string, text: string): WinJS.Promise; +} + +/** * Provides application-level functionality, for example activation, storage, and application events. **/ declare module WinJS.Application { @@ -34,128 +76,23 @@ declare module WinJS.Application { /** * The local storage of the application. **/ - var local: { - //#region Methods - - /** - * Determines whether the specified file exists in the folder. - * @param filename The name of the file. - * @returns A promise that completes with a value of either true (if the file exists) or false. - **/ - exists(filename: string): Promise; - - /** - * Reads the specified file. If the file doesn't exist, the specified default value is returned. - * @param fileName The file to read from. - * @param def The default value to be returned if the file failed to open. - * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. - **/ - readText(fileName: string, def?: string): Promise; - - /** - * Deletes a file from the folder. - * @param fileName The file to be deleted. - * @returns A promise that is fulfilled when the file has been deleted. - **/ - remove(fileName: string): Promise; - - /** - * Writes the specified text to the specified file. - * @param fileName The name of the file. - * @param text The content to be written to the file. - * @returns A promise that completes with a value that is the number of characters written. - **/ - writeText(fileName: string, text: string): Promise; - - //#endregion Methods - - }; + var local: IOHelper; /** * The roaming storage of the application. **/ - var roaming: { - //#region Methods + var roaming: IOHelper; - /** - * Determines whether the specified file exists in the folder. - * @param filename The name of the file. - * @returns A promise that completes with a value of either true (if the file exists) or false. - **/ - exists(filename: string): Promise; - - /** - * Reads the specified file. If the file doesn't exist, the specified default value is returned. - * @param fileName The file to read from. - * @param def The default value to be returned if the file failed to open. - * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. - **/ - readText(fileName: string, def?: string): Promise; - - /** - * Deletes a file from the folder. - * @param fileName The file to be deleted. - * @returns A promise that is fulfilled when the file has been deleted. - **/ - remove(fileName: string): Promise; - - /** - * Writes the specified text to the specified file. - * @param fileName The name of the file. - * @param text The content to be written to the file. - * @returns A promise that completes with a value that is the number of characters written. - **/ - writeText(fileName: string, text: string): Promise; - - //#endregion Methods - - }; + /** + * The temp storage of the application. + **/ + var temp: IOHelper; /** * An object used for storing app information that can be used to restore the app's state after it has been suspended and then resumed. Data that can usefully be contained in this object includes the current navigation page or any information the user has added to the input controls on the page. You should not add information about customization (for example colors) or user-defined lists of content. **/ var sessionState: any; - /** - * The temp storage of the application. - **/ - var temp: { - //#region Methods - - /** - * Determines whether the specified file exists in the folder. - * @param filename The name of the file. - * @returns A promise that completes with a value of either true (if the file exists) or false. - **/ - exists(filename: string): Promise; - - /** - * Reads the specified file. If the file doesn't exist, the specified default value is returned. - * @param fileName The file to read from. - * @param def The default value to be returned if the file failed to open. - * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. - **/ - readText(fileName: string, def?: string): Promise; - - /** - * Deletes a file from the folder. - * @param fileName The file to be deleted. - * @returns A promise that is fulfilled when the file has been deleted. - **/ - remove(fileName: string): Promise; - - /** - * Writes the specified text to the specified file. - * @param fileName The name of the file. - * @param text The text to write. - * @returns A Promise that completes with the number of bytes successfully written to the file. - **/ - writeText(fileName: string, text: string): Promise; - - //#endregion Methods - - }; - //#endregion Objects //#region Methods