小编Jeo*_*uan的帖子

如何在observableArray中交换两个项目?

我有一个按钮,可以将项目移动到observableArray中的一个位置.我是按照以下方式做的.但是,缺点是categories()[index]从数组中删除,从而丢弃了该节点上的任何DOM操作(通过我的情况下通过jQuery验证).

有没有办法在不使用临时变量的情况下交换两个项目以保留DOM节点?

    moveUp: function (category) {
        var categories = viewModel.categories;
        var length = categories().length;
        var index = categories.indexOf(category);
        var insertIndex = (index + length - 1) % length;

        categories.splice(index, 1);
        categories.splice(insertIndex, 0, category);
        $categories.trigger("create");
    }
Run Code Online (Sandbox Code Playgroud)

knockout.js

21
推荐指数
2
解决办法
8064
查看次数

如何为ValidateAntiForgeryToken选择一个salt值

防伪令牌接受盐值.是否有任何关于选择盐的安全问题,例如

  • 最小长度要求
  • 密码学强
  • 字母数字和其他字符的混合(如密码的字符)

另外,客户可以查看盐值吗?查看源代码,似乎是将salt值添加到cookie之前.

asp.net asp.net-mvc

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

在ASP.NET Core模块进程内托管SetBasePath中使用的目录

SetBasePath用于进程内托管的正确参数是什么?

我们以这种方式设置配置:

private static IConfiguration Configuration { get; } = new ConfigurationBuilder()
    .SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("appsettings.json", optional: false)
    .Build();
Run Code Online (Sandbox Code Playgroud)

但是,使用ASP.NET Core 2.2进程内托管时,Directory.GetCurrentDirectory()将返回C:\Program Files\IIS Express而不是我的应用程序根目录。

编辑:

我正在初始化我的配置,Program.Main以便按照示例阅读设置以传递给Serilog 。

回答:

可悲的是,这个问题被标记为重复,因此在问题中回答。

这个问题在这里讨论。在下一次ASP.NET Core更新中,GetCurrentDirectory将提供与进程外托管相同的值。同时,提供以下代码作为解决方法。

using System;

namespace SampleApp
{
    internal class CurrentDirectoryHelpers
    {
        internal const string AspNetCoreModuleDll = "aspnetcorev2_inprocess.dll";

        [System.Runtime.InteropServices.DllImport("kernel32.dll")]
        private static extern IntPtr GetModuleHandle(string lpModuleName);

        [System.Runtime.InteropServices.DllImport(AspNetCoreModuleDll)]
        private static extern int http_get_application_properties(ref IISConfigurationData iiConfigData);

        [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
        private struct IISConfigurationData
        {
            public IntPtr pNativeApplication;
            [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.BStr)]
            public …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core

6
推荐指数
0
解决办法
3201
查看次数

与interactivePopGestureRecognizer一起调整位置

我有一个自定义控件,包含一行按钮,模仿标签栏.当UINavigationController导航离开根视图控制器时,此控件滑出视图,并在导航到根时滑回.

使用iOS 7,UIScreenEdgePanGestureRecognizer可以实现向后滑动的手势.我正在修改我的自定义控件,以便幻灯片数量对应于UIScreenEdgePanGestureRecognizer翻译.

问题是,当用户释放触摸时,我该如何判断它是否UINavigationController会导航或弹回原始视图?

[self.interactivePopGestureRecognizer addTarget:self action:@selector(panningBack:)];


- (void) panningBack:(UIPanGestureRecognizer *)recognizer
{
    // Snipped - Code that reads the recognizer translation and adjust custom control y position

    if (recognizer.state == UIGestureRecognizerStateEnded)
    {
        // Question: Does it go back, or does it not?

        // If it goes back, slide custom control into view
        // Else slide custom control out of view
    }
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uinavigationcontroller ios ios7

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

在方法调用中使用逗号表达式是什么意思,比如`var proc = (0, _postcss2.default)();`

查看 cssnano 源代码,我遇到了这一行

var proc = (0, _postcss2.default)();

根据我的测试,它似乎与

var proc = _postcss2.default();

为什么 cssnanoproc使用第一种语法进行赋值?

javascript javascript-objects

2
推荐指数
1
解决办法
295
查看次数