小编JQu*_*ile的帖子

在Windows Azure Blob存储中使用子目录

我正在尝试将文件上传到Windows Azure blob存储.根据我的理解,您可以将文件上传到类似于子目录的内容.我想将文件上传到blob,使文件基本上驻留在/TestContainer/subDirectory1/subDirectory2/file.png

// Setup the Windows Aure blob client
CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting("BlobStorage");
CloudBlobClient client = storageAccount.CreateCloudBlobClient();

// Retrieve the TestContainer container from blob storage
CloudBlobContainer container = client.GetContainerReference("TestContainer");
if (container.CreateIfNotExist())
  container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });

// Setup the blob
CloudBlob blob = container.GetBlobReference("");

// Create the meta data for the blob
NameValueCollection metadata = new NameValueCollection();
metadata["id"] = fileID.ToString();
blob.Metadata.Add(metadata);

// Store the blob 
byte[] bytes = GetFileBytes();
blob.UploadByteArray(bytes);
Run Code Online (Sandbox Code Playgroud)

如何上传具有目录结构的文件?这里的链接提到有一种方法可以做到这一点.但是,它没有告诉你如何做到这一点.

谢谢!

azure-storage azure-storage-blobs

4
推荐指数
1
解决办法
1万
查看次数

使用AngularJS超时

我是AngularJS的新手.我目前正在查看$ timeout服务.我知道它就像是setTimeout函数的包装器.文档说它提供了异常处理.此外,文档说我可以取消并刷新超时.

当超时发生异常时,有人可以向我解释一下吗?我也不明白为什么我需要刷新超时.我想要一个解释或者也许是一个小伙子.对于我的生活,我无法弄清楚为什么甚至如何使用这些附加功能.

更新:当我尝试运行stop函数时,抛出与myTimer相关联的catch处理程序.这是我的代码:

var myTimer = null; 
$scope.hasStarted = false; 
$scope.start = function () { 
  if ($scope.hasStarted === false) { 
    $scope.isTimerActive = true; 
    myTimer = $timeout(function () { $scope.isTimerActive = false; }, 5000); 
    myTimer.catch(function (err) { 
      alert("An error happened with the clock."); 
    }); 
  }
} 

$scope.stopClock = function () { 
  $timeout.cancel(myTimer); 
  $scope.isClockActive = false; 
}  
Run Code Online (Sandbox Code Playgroud)

谢谢!

timeout angularjs

4
推荐指数
1
解决办法
6043
查看次数

语义版本名称的示例

我一直在读关于semver的文章.我非常喜欢这个一般的想法.然而,当谈到实践时,我觉得我错过了一些关键的信息.我不确定库的名称存在于何处,或者文件变体如何处理.例如,文件名是[framework] - [semver] .min.js吗?有流行的JavaScript框架使用semver吗?我不知道.

谢谢!

semantics

4
推荐指数
1
解决办法
1465
查看次数

AngularJS - 如何关闭hashbang模式

我有一个网页上有两个AngularJS应用程序.因为有两个应用程序,我必须将应用程序引导到页面上.我正在引导这样的应用程序:

// Bootstrap the first app
var app1 = angular.module('app-1', []);
app1.controller('App1Controller', ['$scope', '$window', function ($scope, $window) {
}]);
angular.bootstrap($('#app1'), ['app-1']);

// Bootstrap the second app
angular.bootstrap($('#app-2'), ['my-app-name']);
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何完全关闭hashbang?我没有使用AngularJS进行视图管理.我正在将它用于其他事情.出于某种原因,当我使用带有Angular的IE8访问页面时,用户被重定向到其中包含hashbang的页面.hashbang导致服务器端错误.出于这个原因,我需要关闭它.我怎么做?

angularjs

4
推荐指数
1
解决办法
1347
查看次数

从Jasmine测试中引用JavaScript文件

我正在编写一些我打算在JavaScript中重用的实用程序.这也是我的学习练习.为了做到这一点,我有以下文件:

utilities.js

Object.prototype.AddPrefix = function(prefix) {
    return prefix + this;
};
Run Code Online (Sandbox Code Playgroud)

我打算在JavaScript中调用这个函数,如下所示:

var myString = 'agree';
myString = myString.AddPrefix('dis');
Run Code Online (Sandbox Code Playgroud)

请注意,这是一个人为的例子.我只是想证明调用函数.无论哪种方式,我想测试AddPrefix函数.为此,我正在使用Jasmine.我有以下Jasmine文件:

utilities.tests.js

'use strict';
describe('utilities', function() {
    describe('add prefix', function() {
        it('append dis to string', function() {
            var v = 'agree';
            var actual = v.AddPrefix('dis');
            var expected = 'disagree';
            expect(actual).toBe(expected);
        });
    });
});
Run Code Online (Sandbox Code Playgroud)

这两个文件,utilities.jsutilities.tests.js在同一个目录下.我使用以下脚本通过gulp执行Jasmine:

gulpfile.js

var gulp = require('gulp');
var jasmine = require('gulp-jasmine');

gulp.task('default', function() {});

gulp.task('test', function() {
    var testFiles = [
        'utilities/utilities.tests.js'
    ];

    return gulp …
Run Code Online (Sandbox Code Playgroud)

javascript jasmine gulp

4
推荐指数
1
解决办法
6553
查看次数

Node.js - 显示“MODULE_NOT_FOUND”的全局安装模块

我在一个项目中使用 Node.js。我使用全局安装了 WebdriverIO

npm install -g webdriverio

在我的一个文件中,我有:

文件.js

var webdriverio = require('webdriverio');
Run Code Online (Sandbox Code Playgroud)

当这个文件被加载时,我在控制台中收到一条错误消息:

Message:
    Cannot find module 'webdriverio'
Details:
    code: MODULE_NOT_FOUND
Run Code Online (Sandbox Code Playgroud)

如果我注释掉该行var webdriverio = ...,我的代码运行良好。

考虑到我已经在全球范围内安装了 webdriverio,我不明白为什么我会遇到这个问题。

javascript node.js

4
推荐指数
2
解决办法
3147
查看次数

Gulp - 将多个文件复制到单独的路径

我正在使用Node.js的Web应用程序.在这个应用程序中,我有一个Gulp文件.我正在使用Gulp 4.在构建过程中,我试图一次将多个文件复制到目录.我的目录结构如下所示:

./
  dest/
  source/
    child/
      index.js
      index.bak
    file.js
    README.md
Run Code Online (Sandbox Code Playgroud)

我的真实目录结构更复杂.不过,我试图复制./source/file.js./dest/file.js./source/child/index.js./dest/child/index.js.请注意,我不想复制README.md或复制index.bak./dest directory.为了做到这一点,我有以下功能:

function copy() {
  let files = [
    'source/file.js',
    'source/child/**/*.*'
  ];

  return gulp
    .src(files)
    .pipe(gulp.dest('dest'))
  ;
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,一切都被复制到dest目录.目录结构不会被保留.如果我能弄清楚如何在单个任务中将文件复制到不同的目录,那就没问题了.我尝试了以下方法:

function copy() {
    return gulp
        .src('source/child/index.js')
        .pipe(gulp.dest('dest/child'))
        .src('source/file.js')
        .pipe(gulp.dest('dest'))
    ;            
}
Run Code Online (Sandbox Code Playgroud)

但是,这种方法只会产生一个错误:

TypeError: gulp.src(...).pipe(...).src is not a function
Run Code Online (Sandbox Code Playgroud)

所以,我被困住了.我不确定如何从单个gulp任务将多个文件复制到多个目录.

node.js gulp

4
推荐指数
1
解决办法
1475
查看次数

LINQ中的嵌套匿名类型

我正在尝试使用LINQ构建自定义结果集.目前,我有以下内容:

List<Team> teams = Team.FindAll();
List<Player> players = Player.FindAll();

var results = (from player in players
               select new
               {
                 PlayerId = player.Id,
                 PlayerName = player.Name,
                 Teams = teams.Where(t => player.TeamsIds.Contains(t.TeamId)).ToList() 
               });
Run Code Online (Sandbox Code Playgroud)

我希望团队成为一种新的自定义类型.我希望该类型有一个名为IsChecked,TeamId和TeamName的字段.但是,每个团队目前只有TeamId和TeamName.如何在此LINQ语句中添加IsChecked属性?有没有办法嵌套"选择新"语句?如果是这样,怎么样?

谢谢?

c# linq

3
推荐指数
1
解决办法
1600
查看次数

使用ASP.NET MVC进行条件格式化

我有一个在视图中使用Razor的ASP.NET MVC应用程序.在我看来,我有以下几点:

<table style="width:100%;">
 ...
</table>
Run Code Online (Sandbox Code Playgroud)

我想说,if (items.Count == 0)然后表的背景颜色应该是橙色.但是,if (items.Count > 0)我希望表格的背景颜色为灰色.我如何使用Razor做到这一点?

谢谢!

asp.net-mvc razor

3
推荐指数
2
解决办法
2568
查看次数

在ASP.NET MVC函数中获取查询字符串值

我有一个ASP.NET MVC应用程序.我的观点使用Razor.在我的CSHTML文件的顶部,我有以下内容:

@functions
{
    public static HtmlString IsSelectedCss(string name)
    {
        string selected = ""; // Need to get value of "t" from query string

        HtmlString attribute = new HtmlString("");
        if (selectedTab.Equals(name, StringComparison.InvariantCultureIgnoreCase))
        {
          attribute = new HtmlString("class=\"active\"");
        }                
        return attribute;
    }
}
Run Code Online (Sandbox Code Playgroud)

我需要这个函数来检查查询字符串.具体来说,我需要获取"t"查询字符串参数的值.我的挑战是,我似乎无法弄清楚如何在此函数中访问QueryString.

如何在Razor函数中获取查询字符串参数的值?

谢谢!

razor asp.net-mvc-4

3
推荐指数
1
解决办法
3万
查看次数