到目前为止,这是我尝试过的:
gulp.task('watch-index-html', function () {
gulp.watch(files, function (file) {
return gulp.src('index/index.html')
.pipe(inject(gulp.src(['index/base3.html']), {
starttag: '<!-- inject:base3:html -->'
}))
.pipe(print(function (file) {
return "Processing " + file;
}))
.pipe(gulp.dest('./'));
});
});
Run Code Online (Sandbox Code Playgroud)
这是发生了什么:
之前:
<body>
abcd
<!-- inject:base3:html -->
<!-- endinject -->
efgh
Run Code Online (Sandbox Code Playgroud)
后:
<body>
abcd
<!-- inject:base3:html -->
<link rel="import" href="/index/base3.html">
<!-- endinject -->
efgh
Run Code Online (Sandbox Code Playgroud)
我期望看到的是文件的实际内容,而不是该行:
<link rel="import" href="/index/base3.html">
Run Code Online (Sandbox Code Playgroud)
谁能告诉我是否可以通过“插入文件内容”来执行此操作,gulp-inject或者是否还有其他应使用的内容。请注意,过去我尝试使用,gulp-mustache但是在插入字符(65279)时遇到了问题。我认为这与以下问题有关,但是我从来没有胡须为我工作:
如何避免在PHP中回显字符65279?(此问题也与Javascript xmlhttp.responseText(ajax)有关)
我希望有人可以给我一些建议,可以使用gulp-inject或或以gulp-mustache其他任何方式将文件内容插入另一个文件。
我在C#中有此代码
foreach (var entry in auditableTableEntries)
{
IAuditableTable table = (IAuditableTable)entry.Entity;
table.ModifiedBy = userId;
table.ModifiedDate = dateTime;
if (entry.State == EntityState.Added || entry.State == EntityState.Modified)
{
if (table.CreatedBy == null || table.CreatedBy == null)
{
table.CreatedBy = userId;
table.CreatedDate = dateTime;
}
}
}
Run Code Online (Sandbox Code Playgroud)
一些表对象具有属性modified,为此,我想将属性设置为秒数。自1970年以来。类似:
table.modified = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds
Run Code Online (Sandbox Code Playgroud)
但是,如何判断该表是否具有该属性?如果属性不存在,我不想设置该属性,因为我认为这会导致异常。
到目前为止,这是我尝试过的:
if (table.GetType().GetProperty("modified") != null)
{
// The following line will not work as it will report that
// an IAuditableTable does not have …Run Code Online (Sandbox Code Playgroud) 如果我有这样的数组:
var array1 =
[
{"phraseId":"abc",
"keyword":"bb",
"posId":1},
{"phraseId":"def",
"keyword":"bb",
"posId":1},
]
Run Code Online (Sandbox Code Playgroud)
如何才能发现具有"def"的phraseId的对象具有第二个位置?
我有这个代码,其中AddDefSpan是一个扩展方法,它将一个字符串作为参数.我在这里用这个:
FormattedString s = new FormattedString()
.AddDefSpan("On the ")
.AddTabSpan("settings")
.AddDefSpan(" screen you set ")
.AddDtlSpan("card appearance visibility")
.AddDefSpan(" to ")
.AddDtlSpan("favorites")
.AddDefSpan(" to ");
if (App.phraseInfo.Favorite == 0)
s.AddDefSpan(" aaa.");
else
s.AddDefSpan(" bbb.");
Run Code Online (Sandbox Code Playgroud)
我想知道的是,如果有一些方法可以将决定(App.phraseInfo.Favorite == 0)合并到.AddDefSpan的单个参数中
这样的事情:
s.AddDefSpan(
if (App.phraseInfo.Favorite == 0) " aaa." else " bbb."
);
Run Code Online (Sandbox Code Playgroud)
我意识到我刚写的东西不会起作用,但我想知道是否有办法可以使它工作?
我有以下内容:
$('#EID').empty();
$('#EID').html(data);
Run Code Online (Sandbox Code Playgroud)
是否有可能使用jQuery简化这一点,我真的需要第一行的空吗?
当我在课堂上做以下事情时:
public string ModifiedBy { get; set; }
Run Code Online (Sandbox Code Playgroud)
C#如何存储数据.编译器是否生成支持变量,它是如何命名的,如果不使用get,我是否可以访问它; 组?
我有以下方法但如果字符串为null则失败.如果字符串为null,我怎么能让它返回null?
public static string Truncate(this string value, int maxChars)
{
return value.Length <= maxChars ?
value :
value.Substring(0, maxChars) + " ..";
}
Run Code Online (Sandbox Code Playgroud)
有人也可以向我解释"这个"的用途.对不起,我不太擅长C#,这不是我的代码.
有人能告诉我这是否是有效的代码:
get
{
return string.IsNullOrEmpty(TopicID) ? null :
TopicID == "00" ? "All Topics" :
int.Parse(TopicID).ToString();
}
Run Code Online (Sandbox Code Playgroud)
我希望get返回null,如果它是"00"则返回单词"All Topics"或返回没有前导零的数字.
代码看起来很乱,但我不确定是否有更简洁的方法让我编写代码.
我使用以下类方法从数字创建Base36字符串:
private const string CharList = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static String Encode(long input) {
if (input < 0) throw new ArgumentOutOfRangeException("input", input, "input cannot be negative");
char[] clistarr = CharList.ToCharArray();
var result = new Stack<char>();
while (input != 0)
{
result.Push(clistarr[input % 36]);
input /= 36;
}
return new string(result.ToArray());
}
Run Code Online (Sandbox Code Playgroud)
其中一个要求是字符串应始终用零填充,并且最多应为四位数.任何人都可以提出一种方法,我可以编码领先的零,并限制功能,所以它永远不会返回超过"ZZZZ"?C#中是否有一些功能可以做到这一点.对于此代码的缩进感到抱歉.我不确定为什么它没有正确缩进.
我有以下代码:
if (Session["CurrentUrl"] != null & Session["CurrentHost"] != null)
Run Code Online (Sandbox Code Playgroud)
我在很多地方使用它.我想知道是否有人能想出一种优化C#代码的方法,只是为了让事情更加清晰.