小编Cha*_*aos的帖子

接口继承和新关键字

我想要:

public interface IBase
{
    MyObject Property1 { get; set; }
}

public interface IBaseSub<T> : IBase
{
    new T Property1 { get; set; }
}

public class MyClass : IBaseSub<YourObject>
{
    public YourObject Property1 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

但这不编译.它给出了错误:

//This class must implement the interface member IBase.Property1
Run Code Online (Sandbox Code Playgroud)

任何人都可以对此有所了解吗?我认为它应该工作..

谢谢

c# interface

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

OpenAPI / Swagger 3.0:默认鉴别器值

您如何为每个子类设置默认鉴别器?

例如,采用以下模式:

components:
  schemas:
    Pet:
      type: object
      required:
      - petType
      properties:
        petType:
          type: string
      discriminator:
        propertyName: petType
    Cat:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - type: object
        # all other properties specific to a `Cat`
        properties:
          name:
            type: string
    Dog:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - type: object
        # all other properties specific to a `Dog`
        properties:
          bark:
            type: string
Run Code Online (Sandbox Code Playgroud)

上述模式的代码生成器将创建一个客户端,其中的petType值必须由程序员显式设置。为什么不能默认设置Cat对象?petTypeCat

我尝试使用defaultvalue 让它工作。但是,生成的代码包含隐藏的属性(子级和父级上的相同属性)。

components:
  schemas:
    Pet:
      type: object
      required:
      - petType
      properties:
        petType:
          type: string …
Run Code Online (Sandbox Code Playgroud)

polymorphism swagger openapi swagger-codegen openapi-generator

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

web.config转换和location元素

我似乎无法弄清楚你将如何改变以下内容

<configuration>
<location path="hello123">
<.../>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)

<configuration>
<location path="world321">
<.../>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)

不删除第一个并添加第二个.对此的任何帮助都会很棒.

谢谢

asp.net web-config web-config-transform

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