小编Jef*_*eff的帖子

VB.NET与C#交叉兼容

我有一个带有通用接口的C#项目

public interface IMyFoo<T> { void DoSomething(T instance); }
Run Code Online (Sandbox Code Playgroud)

我还有一个C#项目,其接口继承了几个IMyFoos

public interface IMyBar : IMyFoo<Type1>, IMyFoo<Type2> { ... }
Run Code Online (Sandbox Code Playgroud)

在C#land中一切正常(包括下面的方案在VB中不起作用).

我有一个引用这个C#库的VB .NET项目.

我有一个IMyBar的实例,并尝试使用如下:

Dim instance as MyType1 = ...
Dim bar as IMyBar = ...
bar.DoSomething(instance) ' This generates a compile error: 
' 'DoSomething' is ambiguous across the inherited interfaces 'IMyFoo(Of MyType1)' and 'IMyFoo(Of MyType2)'. 
Run Code Online (Sandbox Code Playgroud)

这是怎么回事?我可以像这样DirectCast并且它工作正常......但我真的不愿意

DirectCast(bar, IMyFoo(Of MyType1)).DoSomething(instance)
Run Code Online (Sandbox Code Playgroud)

.net c# vb.net interop

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

TSQL UDF每8个字符拆分字符串

有人决定将多次拼凑成一个列,因此列值可能如下所示:

08:00 AM01:00 PM
Run Code Online (Sandbox Code Playgroud)

另一列包含以下格式的日期;

20070906
Run Code Online (Sandbox Code Playgroud)

我想编写一个UDF来在单个SQL查询中规范化这个数据,所以我可以为上面的例子找回2行的datetime类型

2007-09-06 08:00:00.000
2007-09-06 13:00:00.000
Run Code Online (Sandbox Code Playgroud)

转换为datetime类型很简单...但我需要每8个字符拆分时间部分以获得个人超时.

有人知道现有的UDF要做到这一点吗?

谢谢.

t-sql sql-server user-defined-functions

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

TFS状态更改日期不起作用

我们正在使用Scrum 1.0模板进行TFS.我们正在尝试进行工作项查询,并且我注意到State Changed Date所有项目都是空的.如果我搜索Changed Date,这工作正常,但不会产生预期的结果......

为什么会这样呢?

tfs scrum visual-studio-2010 tfs2010

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

Azure Pipelines 托管代理无法访问 DevOps 项目源

我有一个 Azure DevOps 项目(只有一个)。

我有一个构建管道设置为在“托管 VS2017”代理池中运行。此代理池似乎位于 [MyProject]\Build Administrators、Contributors、Project Administrators 和 Release Administrators 角色中。

我在 DevOps 项目中还有一个 Artifacts nuget 提要。它有 [MyProject]\Project Valid Users 设置为“读者”角色。似乎项目有效用户具有上述代理池的所有角色作为成员。

我有一个 azure-pipelines.yml 脚本,它在开头添加了工件提要作为 nuget 源:

# Add nuget source
- powershell: Invoke-RestMethod "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "$env:UserProfile/nuget.exe"
- script: '%UserProfile%\nuget.exe sources Add -Name "devops" -Source "https://pkgs.dev.azure.com/MyProject/_packaging/feed/nuget/v3/index.json"'
Run Code Online (Sandbox Code Playgroud)

构建 yml 然后点 adotnet build但在内部失败NuGet.targets

Unable to load the service index for source https://pkgs.dev.azure.com/MyProject/_packaging/feed/nuget/v3/index.json.
Response status code does not indicate success: 401 (Unauthorized).
Run Code Online (Sandbox Code Playgroud)

我怎样才能使这项工作?我的构建需要来自该工件提要上的其他构建的包...

azure-devops azure-pipelines-build-task azure-pipelines azure-artifacts

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

无法实例化Windsor自定义组件激活器

我正在调用Resolve的异常:

KernelException: Could not instantiate custom activator
Inner Exception:
{"Constructor on type 'MyProj.MyAdapter`1[[MyProj.MyBusinessObject, MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' not found."}
Run Code Online (Sandbox Code Playgroud)

肯定有一个公共无参数构造函数(我在运行时使用反射验证了这一点)...所以我认为这个问题可能与它是通用的事实有关吗?我已经尝试获取组件模型对象并将RequiresGenericArguments设置为true,但这并没有让我在任何地方.

任何帮助将非常感激!谢谢.

castle-windsor ioc-container activator microkernel

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

样式化ContentControl

我有一个自定义WPF控件.它有一个嵌套的ContentControl,它绑定到模板的Content属性,因此它可以将任何对象设置为其内容.

如果内容是原始字符串,我想将以下样式应用于TextBlock(我知道当实际呈现Visual Tree时,如果将ContentControl的Content属性设置为字符串,则会生成带有TextBlock的ContentPresenter).

<Style x:Key="Label" TargetType="TextBlock">
    <Setter Property="TextWrapping" Value="Wrap" />
    <Setter Property="FontSize" Value="14" />
    <Setter Property="Foreground">
        <Setter.Value>
            <SolidColorBrush>
                <SolidColorBrush.Color>
                    <Color A="255" R="82" G="105" B="146" />
                </SolidColorBrush.Color>
            </SolidColorBrush>
        </Setter.Value>
    </Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

我本以为这样做的方法是通过嵌套资源(这是我的自定义控件的一部分):

<ContentControl x:Name="SomeText" Margin="10,10,10,0"
                Content="{TemplateBinding Content}"
                IsTabStop="False" Grid.Column="1">
    <ContentControl.Resources>
        <Style TargetType="TextBlock" BasedOn="{StaticResource Label}" />
    </ContentControl.Resources>
</ContentControl>
Run Code Online (Sandbox Code Playgroud)

所以...上面说的(对我来说)如果ContentControl以嵌套的TextBlock结束,我们应该应用Label样式,对吗?...但不是,在上面的例子中没有应用Label样式.

我怎么能做到这一点?

谢谢.

.net wpf xaml

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

TFS团队建立日志单元测试结果

我们正在使用TFS 2010 Team Build,它会在构建过程中自动运行我们的单元测试。如果单击查看日志,则可以看到运行的测试列表和每个测试结果(成功/失败)。如果发生故障,我想查看测试结果输出(以便开发人员可以找出故障原因)。仅在本地运行单元测试是不够的,因为问题可能是环境问题(如果由于某些数据,服务器或物理路径而导致测试失败)。

如何更改构建过程模板以在日志中包含单元测试的全部结果?

“查看日志”页面上的MSTest命令行:

e:\Program Files\Common7\IDE\MSTest.exe /nologo /usestderr /testSettings:"E:\Builds\1\1\Sources\Source\TestSettings.testsettings" /searchpathroot:"E:\Builds\1\1\Binaries" /resultsfileroot:"E:\Builds\1\1\TestResults" /testcontainer:"E:\Builds\1\1\Sources\Source\Testing\bin\Release\Testing.dll" /publish:"http://tfs:8080/tfs/Projects" /publishbuild:"vstfs:///Build/Build/196" /teamproject:"Project" /platform:"Any CPU" /flavor:"Release" 
Run Code Online (Sandbox Code Playgroud)

摘要的屏幕截图

http://imageshack.us/photo/my-images/28/tfsbuild.gif/

以及“构建定义”配置

http://imageshack.us/photo/my-images/835/builddefinition.gif/

谢谢。

team-build tfsbuild tfs2010

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

CQRS匹配事件和命令

我开始使用CQRS,我发现我的Event类定义几乎与我的Command定义匹配1到1.除了显而易见的代码重复之外,我正在试图弄清楚我做错了什么.当然有些情况下事件与命令不匹配......但并不多.

采取简单的CUD方案:

命令类:

  • CreatePost
  • UpdatePost
  • DeletePost

活动类:

  • CreatedPost
  • UpdatedPost
  • DeletedPost

有什么建议吗?

我正在使用事件存储,如果这有任何区别.

谢谢.

.net cqrs event-sourcing

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

CQRS命令构造

我有这样的CQRS命令

public sealed class RequestRoute
{
    public RequestRoute(string fromAddressName, double fromLatitude, double fromLongitude, string toAddressName, double toLatitude, double toLongitude, string userId)
    {
        UserId = userId;
        ToLongitude = toLongitude;
        ToLatitude = toLatitude;
        ToAddressName = toAddressName;
        FromLongitude = fromLongitude;
        FromLatitude = fromLatitude;
        FromAddressName = fromAddressName;
    }

    public string FromAddressName { get; private set; }
    public double FromLatitude { get; private set; }
    public double FromLongitude { get; private set; }

    public string ToAddressName { get; private set; }
    public double ToLatitude { …
Run Code Online (Sandbox Code Playgroud)

.net domain-driven-design cqrs

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

WebAPI未找到

可悲的是,我无法获得使用WebAPI的最基本的东西

$.ajax({
    url: "https://192.168.1.100/Api/Authentication/LogIn",
    type: "POST",
    contentType: "application/json",
    data: "{ 'username': 'admin', 'password': 'MyPass' }",
    error: function (r, s, e) { alert(e); },
    success: function (d, s, r) { alert(s); }
});
Run Code Online (Sandbox Code Playgroud)

我得到"未找到"

API控制器定义

public class AuthenticationController : ApiController
{
    [HttpPost]
    public bool LogIn(string username, string password)
    {
        return true;
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我删除HttpPost并将其替换为HttpGet然后执行

$.ajax({
    url: "https://192.168.1.100/Api/Authentication/LogIn?username=admin&password=MyPass",
    type: "GET",
    error: function (r, s, e) { alert(e); },
    success: function (d, s, r) { alert(s); }
});
Run Code Online (Sandbox Code Playgroud)

这很好.

WebAPI出了什么问题?

asp.net-mvc asp.net-mvc-4 asp.net-web-api

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