本文整理汇总了TypeScript中tns-core-modules/file-system.path类的典型用法代码示例。如果您正苦于以下问题:TypeScript path类的具体用法?TypeScript path怎么用?TypeScript path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了path类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
export var test_XmlParser_IntegrationTest = function () {
var actualResult = "";
var xmlParser = new xmlModule.XmlParser(function (event: xmlModule.ParserEvent) {
if (event.eventType === xmlModule.ParserEventType.Text && event.data.trim() === "") {
// Ignore ignorable whitespace.
return;
}
actualResult += event.toString();
});
var file = fs.File.fromPath(fs.path.join(__dirname, "xml.xml"));
var xmlString = file.readTextSync();
xmlString = xmlString.replace(/(\r\n|\n|\r)/gm, "\n");
xmlParser.parse(xmlString);
var expectedResult: string;
file = fs.File.fromPath(fs.path.join(__dirname, "xml.expected"));
expectedResult = file.readTextSync();
var i;
var maxLength = Math.max(actualResult.length, expectedResult.length);
for (i = 0; i < maxLength; i++) {
var actualChar;
var actualCharCode;
if (i <= actualResult.length) {
actualChar = actualResult.charAt(i);
actualCharCode = actualResult.charCodeAt(i);
}
else {
actualChar = "undefined";
actualCharCode = "undefined";
}
var expectedChar;
var expectedCharCode;
if (i <= expectedResult.length) {
expectedChar = expectedResult.charAt(i);
expectedCharCode = expectedResult.charCodeAt(i);
}
else {
expectedChar = "undefined";
expectedCharCode = "undefined";
}
TKUnit.assert(actualCharCode === expectedCharCode, "At index " + i + ": Actual character is " + actualChar + "[" + actualCharCode + "]; Expected character is: " + expectedChar + "[" + expectedCharCode + "]");
}
};
开发者ID:triniwiz,项目名称:NativeScript,代码行数:49,代码来源:xml-parser-tests.ts
示例2: test_DummyTestForSnippetOnly
export function test_DummyTestForSnippetOnly() {
// >> image-cache-request-images
var cache = new imageCacheModule.Cache();
cache.placeholder = imageSource.fromFile(fs.path.join(__dirname, "res/no-image.png"));
cache.maxRequests = 5;
// Enable download while not scrolling
cache.enableDownload();
var imgSouce: imageSource.ImageSource;
var url = "https://github.com/NativeScript.png";
// Try to read the image from the cache
var image = cache.get(url);
if (image) {
// If present -- use it.
imgSouce = imageSource.fromNativeSource(image);
}
else {
// If not present -- request its download.
cache.push({
key: url,
url: url,
completed: (image: any, key: string) => {
if (url === key) {
imgSouce = imageSource.fromNativeSource(image);
}
}
});
}
// Disable download while scrolling
cache.disableDownload();
// << image-cache-request-images
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:34,代码来源:image-cache-tests.ts
示例3: function
export var test_getContentAsFile = function (done) {
var result;
// >> http-get-urlfile-content
var filePath = fs.path.join(fs.knownFolders.documents().path, "test.png");
http.getFile("https://httpbin.org/image/png?testQuery=query&anotherParam=param", filePath).then(function (r) {
//// Argument (r) is File!
// >> (hide)
result = r;
try {
TKUnit.assert(result instanceof fs.File, "Result from getFile() should be valid File object!");
done(null);
}
catch (err) {
done(err);
}
// << (hide)
}, function (e) {
//// Argument (e) is Error!
// >> (hide)
done(e);
// << (hide)
});
// << http-get-urlfile-content
};
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:25,代码来源:http-tests.ts
示例4: getPlaceholderImageDrawable
public static getPlaceholderImageDrawable(value) {
let fileName = "",
drawable = null;
if (types.isString(value)) {
value = value.trim();
if (utils.isFileOrResourcePath(value)) {
if (0 === value.indexOf("~/")) {
fileName = fs.path.join(fs.knownFolders.currentApp().path, value.replace("~/", ""));
drawable = android.graphics.drawable.Drawable.createFromPath(fileName);
} else if (0 === value.indexOf("res")) {
fileName = value;
let res = utils.ad.getApplicationContext().getResources();
let resName = fileName.substr(utils.RESOURCE_PREFIX.length);
let identifier = res.getIdentifier(resName, 'drawable', utils.ad.getApplication().getPackageName());
drawable = res.getDrawable(identifier);
}
}
}
return drawable;
}
开发者ID:VideoSpike,项目名称:nativescript-web-image-cache,代码行数:31,代码来源:helpers.ts
示例5: function
export var test_leading_slash_is_not_returned = function () {
var parts = ["app", "tns_modules", "fileName"];
var expected = parts.join("/");
var path = fs.path.join(...parts);
TKUnit.assertEqual(path, expected, "Leading slash should not be part of the path");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:7,代码来源:file-system-access-tests.ts
示例6: test_MultiParserTemplate
export function test_MultiParserTemplate() {
const file = fs.File.fromPath(fs.path.join(__dirname, "itemTemplates.xml"));
const xml = file.readTextSync();
const view: any = builder.parse(xml);
TKUnit.assertNotNull(view.items)
TKUnit.assertEqual(view.items.length, 1);
}
开发者ID:triniwiz,项目名称:NativeScript,代码行数:8,代码来源:xml-parser-tests.ts
示例7: testSaveToFile_WithQuality
export function testSaveToFile_WithQuality() {
const img = imageSource.fromFile(imagePath);
const folder = fs.knownFolders.documents();
const path = fs.path.join(folder.path, "test.png");
const saved = img.saveToFile(path, "png", 70);
TKUnit.assert(saved, "Image not saved to file");
TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:8,代码来源:image-source-tests.ts
示例8: resolveRelativeUrls
private resolveRelativeUrls(url: string): string {
// Angular assembles absolute URLs and prefixes them with //
if (url.indexOf("/") !== 0) {
// Resolve relative URLs based on the app root.
return path.join(this.fs.currentApp().path, url);
} else {
return url;
}
}
开发者ID:NathanWalker,项目名称:nativescript-angular,代码行数:9,代码来源:resource-loader.ts
示例9:
source.fromAsset(imageAsset).then((source) => {
let folder = fs.knownFolders.documents().path;
let fileName = "test.png"
let path = fs.path.join(folder, fileName);
let saved = source.saveToFile(path, "png");
if(saved){
console.log("saved image")
}
})
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:9,代码来源:image-source-snippet.ts
示例10:
source.fromAsset(imageAsset).then((imageSource) => {
let folder = fs.knownFolders.documents().path;
let fileName = "test.png";
let path = fs.path.join(folder, fileName);
let saved = imageSource.saveToFile(path, "png");
if (saved) {
console.log("Image saved successfully!");
}
})
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:9,代码来源:image-source-snippet.ts
注:本文中的tns-core-modules/file-system.path类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论