小编Jac*_*ult的帖子

无法使用文件替换目录 /var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping

在我的 Windows 计算机上,我尝试使用以下 Dockerfile 构建容器化的 Node.js 应用程序:

  # use latest version of nodejs
  FROM node:lts-alpine
  
  # install aurelia-cli to build the app & http-server to serve static contents
  RUN npm i -g http-server
  RUN npm i -g aurelia-cli
  
  # set working directory to app
  # henceforth all commands will run inside this folder
  WORKDIR /app
  
  # copy package.json related files first and install all required dependencies
  COPY package*.json ./
  RUN npm install
  
  # copy the rest of the files and …
Run Code Online (Sandbox Code Playgroud)

node.js npm docker aurelia windows-subsystem-for-linux

6
推荐指数
2
解决办法
7936
查看次数

如何避免 C# while 和 do-while 循环中的代码重复?

我在具有以下结构的 C# 方法中有一个循环。

do
{
     getUserInput();
     if (inputIsBad)
     {
          doSomethingElse();
     } 
} while (inputIsBad);
Run Code Online (Sandbox Code Playgroud)

或者,使用 while 循环:

getUserInput();
while (inputIsBad)
{
     doSomethingElse();
     getUserInput();
}
Run Code Online (Sandbox Code Playgroud)

但是这两种方法都使用了冗余代码:do-while 有一个 if 语句和 while 循环检查相同的条件;while 循环在循环之前和内部都调用 getUserInput()。

是否有一种简单的、非冗余的、非临时的方式来完成这些方法模式所做的事情,无论是一般情况下还是在 C# 中,只涉及编写每个基本组件一次?

c# language-agnostic loops while-loop do-while

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