小编use*_*994的帖子

在使用MVVM时,我应该在哪个类中加载数据

我目前正在学习C#,最近我了解了WPF的MVVM设计模式.我正在编写一个简单的程序作为练习它的方法,但我不确定在哪里编写加载数据的方法.

我有一个SalesSheet类,如下所示.这保存了我从.xls文件加载的数据.

class SalesSheet
{
    public List<Row> Rows { get; set; }

    public SalesSheet()
    {
        Rows = new List<Row>();
    }

    public class Row
    {
        public string CallType { get; set; }
        public string HistoryText { get; set; }
    }

}
Run Code Online (Sandbox Code Playgroud)

我的问题是,我应该在哪里编写加载数据的方法?写一个方法是不好的做法:

private void LoadData(string filePath)
Run Code Online (Sandbox Code Playgroud)

在模型中,并将其称为构造函数?

我应该从ViewModel加载它吗?

c# wpf xls model mvvm

5
推荐指数
2
解决办法
4258
查看次数

“ IServiceCollection”不包含“ AddSpaStaticFiles”的定义

我不知道为什么Startup.cs引发此错误。我尝试了这里建议的解决方案(包括重新启动计算机和运行dotnet restore),但没有运气。有任何想法吗?

CS1061'IServiceCollection'不包含'AddSpaStaticFiles'的定义,并且找不到可以接受的扩展方法'AddSpaStaticFiles'接受类型为'IServiceCollection'的第一个参数(是否缺少using指令或程序集引用?)

在此处输入图片说明

在startup.cs顶部使用语句:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Myproject.Models;

using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;
//Install-Package Microsoft.AspNetCore.Session
//Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection
Run Code Online (Sandbox Code Playgroud)

我的.csproj文件包含:

  <ItemGroup>
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="5.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.1" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
    <PackageReference Include="Flurl.Http" Version="2.2.1" />
    <PackageReference Include="jQuery" Version="3.3.1" />
    <PackageReference Include="jQuery.Validation" Version="1.17.0" />
    <PackageReference Include="LeanKit.API.Client" Version="1.2.6" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />

    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.2" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

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

在第一个循环中继续,在第二个循环内

这有助于您更好地理解它:

for(Object o : objects){//first loop
    for(int j = 0; i < y; j++){//second loop

        if(something_is_true)
            stop second loop , continue first loop 

    }
}
Run Code Online (Sandbox Code Playgroud)

我应该使用continue关键字吗?

java loops keyword

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

Angular 6 资产文件夹未在浏览器上呈现

我正在学习 angular,我正在尝试将资产文件夹内的本地图像加载到 main.component.html 中,并且我已经正确设置了路径,同时我在打开图像的路径上执行 alt+单击。但是图像没有加载到浏览器上。

我得到 的错误在此处输入图片说明

在 Chrome 开发者工具的源选项卡中,没有 包含资产文件夹

在此处输入图片说明

这是我的角度 cli 版本 在此处输入图片说明

我试过这个https://github.com/angular/angular-cli/issues/5268但没有用,有人请帮忙这是我的 angular.json 文件

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "game-of-thrones": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/game-of-thrones",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css",
              "./node_modules/bootstrap/dist/css/bootstrap.min.css",
              "./node_modules/font-awesome/css/font-awesome.css"
            ],
            "scripts": [
              "./node_modules/jquery/dist/jquery.min.js",
              "./node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          },
          "configurations": …
Run Code Online (Sandbox Code Playgroud)

assets file-not-found http-status-code-404 angular

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

标签 统计

c# ×2

angular ×1

asp.net ×1

assets ×1

file-not-found ×1

http-status-code-404 ×1

java ×1

keyword ×1

loops ×1

model ×1

mvvm ×1

wpf ×1

xls ×1