在Visual Studio 2017中,我正在开发一个包含3个dotnet核心项目的项目.它使用docker-compose作为启动项目来构建和启动容器.现在它给了我一个错误,它无法找到以给定名称开头的容器.在Show output from:docker选中的Output窗口中,它显示了组合的docker-compose.yml文件.
它似乎没有构建容器,因此它无法找到它正在寻找的容器名称.看到这个后,我在PowerShell中运行了所有的docker命令,它构建了图像并启动了容器.随着容器到位Visual Studio启动,但给了我一个不同的错误.
我想知道为什么Visual Studio不再构建容器了.
注意:过去使用docker cli旋转容器时我遇到麻烦,Visual Studio会抛出异常,但我已经清理了运行容器,网络,卷和图像的docker ......
感谢您的帮助.我喜欢docker,但到目前为止使用VS工具时有一些挫折......
我有一堆不同的枚举,比如......
public enum MyEnum
{
[Description("Army of One")]
one,
[Description("Dynamic Duo")]
two,
[Description("Three Amigo's")]
three,
[Description("Fantastic Four")]
four,
[Description("The Jackson Five")]
five
}
Run Code Online (Sandbox Code Playgroud)
我为任何Enum编写了一个扩展方法,以获取Description属性(如果有).很简单吧......
public static string GetDescription(this Enum currentEnum)
{
var fi = currentEnum.GetType().GetField(currentEnum.ToString());
var da = (DescriptionAttribute)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
return da != null ? da.Description : currentEnum.ToString();
}
Run Code Online (Sandbox Code Playgroud)
我可以非常简单地使用它,它就像一个魅力,返回描述或ToString()按预期.
这是问题所在.我希望能够在IEnumerable的MyEnum,YourEnum或SomeoneElsesEnum上调用它.所以我简单地编写了以下扩展名.
public static IEnumerable<string> GetDescriptions(this IEnumerable<Enum> enumCollection)
{
return enumCollection.ToList().ConvertAll(a => a.GetDescription());
}
Run Code Online (Sandbox Code Playgroud)
这不起作用.它作为一种方法编译很好,但使用它会产生以下错误:
Instance argument: cannot convert from 'System.Collections.Generic.IEnumerable<MyEnum>' to System.Collections.Generic.IEnumerable<System.Enum>'
Run Code Online (Sandbox Code Playgroud)
那么为什么呢?我可以做这个吗?
我在这一点上找到的唯一答案是为泛型T编写扩展方法,如下所示:
public static IEnumerable<string> GetDescriptions<T>(this List<T> myEnumList) …Run Code Online (Sandbox Code Playgroud)