小编NBM*_*NBM的帖子

.NET Core中的T4替代品?

T4文本模板是文本块和控制逻辑的混合,可以生成文本文件.

任何人都可以建议我在.NET Core中使用T4替代品吗?微软是否有计划在.NET Core世界中引入T4?

c# t4 .net-core

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

.NET Core中[Serializable]的等价物是什么?(转换项目)

在许多情况下,当我想将当前的.NET Framework项目转换为.NET Core等效项时,某些类具有Serializable属性.

我应该怎么做才能在.NET Core中转换它们?(在这个时候我删除它们!!!)

编辑

考虑以下代码:

using System;

namespace DotLiquid.Exceptions
{
    [Serializable] // I delete it now !!!!!!!
    public class FilterNotFoundException : Exception
    {
        public FilterNotFoundException(string message, FilterNotFoundException innerException)
            : base(message, innerException)
        {
        }

        public FilterNotFoundException(string message, params string[] args)
            : base(string.Format(message, args))
        {
        }

        public FilterNotFoundException(string message)
            : base(message)
        {
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的代码没有[Serializable]在.NET Core中工作,没有语法问题.

但我想知道什么时候删除[Serializable]

什么是副作用?

哪些地方应该改变?

我什么时候应该使用JSON.NET(或...)而不是[Serializable]?

c# .net-core

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

如何在C#中生成带有Bogus库的字符串列表?

我使用Bogus库生成测试数据.

例如我有一个类:

public class Person
{
   public int Id {get; set;}
   public List<string> Phones {get; set;} // PROBLEM !!!
}

var Ids = 0;
var test = new Faker<Person>()
    .RuleFor(p => p.Id, f => Ids ++)
    .RuleFor(p => p.Phones , f => /*HOW ?????*/) // How can I return random list of PhoneNumbers ???
Run Code Online (Sandbox Code Playgroud)

任何人都可以指导我如何在虚假中生成预定义的faker列表?

c#

8
推荐指数
2
解决办法
2819
查看次数

无法在.NET Core中加载文件或程序集"System.Runtime,Version = 4.1.0.0"

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& …
Run Code Online (Sandbox Code Playgroud)

c# .net-core

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

.NET Core 中控制台应用程序中的交互式、可选择和可滚动项目,如 Yeoman 控制台

有人知道如何在控制台中创建有吸引力且可选择的项目吗?

当您将 yeoman 安装为 node.js 包并使用“yo”从命令行调用它时,

他们向我们展示了可滚动项目的列表,可以使用向上向下箭头键进行选择。

无论如何,是否有用于此目的的任何代码或库?(在 .NET Core 中)

在此输入图像描述 在此输入图像描述

c# interactive console-application yeoman .net-core

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

Angular2 中的@Input() 不适用于字符串

请参阅以下代码:

import { AppComponent } from './app.component';
import { HelloWorldComponent } from './hello-world/hello-world.component';

@NgModule({
  declarations: [
    AppComponent,
    HelloWorldComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

我将“HelloWorldComponent”添加到主组件(“AppComponent”)

在“app.component.html”中

<h1>
  {{title}}
  <app-hello-world [name]="test"></app-hello-world> // When [name]="Test" does not works but when I use number works !!! [name] = "4"
</h1>
Run Code Online (Sandbox Code Playgroud)

在“hello-world.component.ts”中使用@Input() 装饰器

import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-hello-world',
  templateUrl: './hello-world.component.html',
  styleUrls: ['./hello-world.component.css']
})
export class HelloWorldComponent implements …
Run Code Online (Sandbox Code Playgroud)

angular

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

标签 统计

c# ×5

.net-core ×4

angular ×1

console-application ×1

interactive ×1

t4 ×1

yeoman ×1