小编ant*_*riz的帖子

ASP.Net Core + Swagger - 操作需要 Swagger 2.0 的显式 HttpMethod 绑定

我有一个项目MyProject.Api具有以下结构:

Controllers/
- Api/
  - UsersController.cs
- HomeController.cs
Startup.cs
Run Code Online (Sandbox Code Playgroud)

其中HomeController.cs看起来像这样:

Controllers/
- Api/
  - UsersController.cs
- HomeController.cs
Startup.cs
Run Code Online (Sandbox Code Playgroud)

UsersController.cs看起来像这样:

namespace MyProject.Api.Controllers
{
    public class HomeController : Controller
    {
        private readonly IHostingEnvironment _hostingEnvironment;

        public HomeController(IHostingEnvironment hostingEnv) {...}

        [HttpGet]
        public async Task<IActionResult> Index() {...}

        [HttpGet("sitemap.xml")]
        public IActionResult SiteMap() {...}

        [HttpGet("error")]
        public IActionResult Error() {...}
    }
}
Run Code Online (Sandbox Code Playgroud)

Startup.cs

namespace MyProject.Api.Controllers.Api
{
    [Route("api/[controller]")]
    public class UsersController : Controller
    {
        private readonly ApiHelper<UsersController> _apiHelper;
        private readonly IUserService …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-web-api swagger asp.net-core

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

如何在 Node 的 TypeScript 中使用非类型化 JS NPM 模块?

我刚刚开始尝试 TypeScript,我有以下项目结构:

-src
| index.ts
| MyClass.ts
-node_modules
 -npm_js_module
 | index.js
 | utils.js
 - src
  | someModuleFile.js
  | someModuleFile2.js
Run Code Online (Sandbox Code Playgroud)

我需要在 MyClass.ts 中使用 npm_js_module/index.js 中的函数(以及 pm_js_module/src 中的函数,但这些是 index.js 所必需的)。该模块是无类型的,并且其他人无法在线输入。是否可以在 TypeScript 项目中使用非类型化 JavaScript NPM 模块?

当我尝试编译这个项目时,我收到此错误:

error TS6059: File '/node_modules/npm_js_module/index.js' is not under 'rootDir' '/src'. 'rootDir' is expected to contain all source files.
error TS6059: File '/node_modules/npm_js_module/utils.js'' is not under 'rootDir' '/src'. 'rootDir' is expected to contain all source files.
Run Code Online (Sandbox Code Playgroud)

我的 tsconfig.json 看起来像这样:

{
  "compilerOptions": {
    "moduleResolution": "node",
    "module": "commonjs",
    "target": "es2017", …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm typescript

5
推荐指数
1
解决办法
4050
查看次数

Bash - 比较两个命令的输出

我有这个代码:

#!/bin/bash

CMDA=$(curl -sI website.com/example.txt | grep Content-Length)

CMDB=$(curl -sI website.com/example.txt | grep Content-Length)

if [ "CMDA" == "CMDB" ];then
  echo "equal";
else
  echo "not equal";
fi
Run Code Online (Sandbox Code Playgroud)

有了这个输出

root@abcd:/var/www/html# bash ayy.sh
not equal
Run Code Online (Sandbox Code Playgroud)

这应该是“相等”而不是“不相等”。我做错了什么?

纳克斯

linux bash terminal curl string-comparison

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

简单的Android应用程序在启动时崩溃

我正在创建一个新的Android应用程序,但它在启动时崩溃(手机和模拟器).

这是代码:

Arcig Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.tona.arcig"
    android:versionCode="1"
    android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="17" /><application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
    <activity android:name="MainActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
Run Code Online (Sandbox Code Playgroud)

strings.xml中

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="suplovani">Suplování</string>
    <string name="rozvrh">Rozvrh hodin</string>
    <string name="prihlasovani">P?ihlašování do systému</string>
    <string name="email">Email</string>
    <string name="moodle">Moodle</string>
    <string name="kdm">KDM</string>
    <string name="o_aplikaci">O Aplikaci</string>
    <string name="app_name">Arcig.CZ</string>

</resources>
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:contentDescription="@string/suplovani"
            android:src="@drawable/suplovani" /> …
Run Code Online (Sandbox Code Playgroud)

java xml crash android startup

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