小编ran*_*uwe的帖子

使用XDT转换的Web.config进行部分替换

我处于这样一种情况,我只想更新WCF端点的URL的一部分.现在,我们通过在每个"种类"中包含所有端点的不同配置来实现此目的.这很难管理.我想在web.config中设置一个转换来实现.

这些是文件的两个示例

开发

  <endpoint address="http://servicesdev.host.com/RPUtilityServices/LogException.svc/restService"
        behaviorConfiguration="restfulBehavior"
        binding="webHttpBinding"
        contract="Host.RP.Shared.Common.Services.Utility.Interfaces.IExceptionUtilityService"
        name="LogService" />
Run Code Online (Sandbox Code Playgroud)

还有一些这些

分期

  <endpoint address="http://servicessta.host.com/RPUtilityServices/LogException.svc/restService"
            behaviorConfiguration="restfulBehavior"
            binding="webHttpBinding"
            contract="Host.RP.Shared.Common.Services.Utility.Interfaces.IExceptionUtilityService"
            name="LogService" />
Run Code Online (Sandbox Code Playgroud)

不同之处在于servicessta与servicesdev.现在我也有serviceuat和servicesqa etcera.我想设置一个转换,只是将' dev ' 替换为' sta '等而不是整个块(使用xdt:Transform="Replace")

但是我该怎么做?

c# web-config .net-4.5 visual-studio-2012 web.config-transform

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

如何在C#中使用WCF REST服务?

我的合同细节如下.我正在使用Json响应和请求格式,也使用POST方法.如何编写客户端以在c#中使用此服务.

[OperationContract()]
[WebInvoke(UriTemplate = "/RESTJson_Sample1_Sample1Add", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
int RESTJson_Sample1_Sample1Add(Int32 a, Int32 b, Int32 c);
Run Code Online (Sandbox Code Playgroud)

c# rest wcf wcf-rest

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

替换为异步void

我正在开发一个监视某些任务的应用程序(例如,如果某些服务/网站当前正在运行,数据库中存在某些记录等).而且,因为大多数这些任务长时间运行,我用TPLasync/await.

我有一个基类用于所有这些任务:

public abstract class LongRunningOperation
{
    // .. some props...

    internal async void Start()
    {
        try
        {
            this.Status = OperationStatus.Started;
            await this.DoStart();
            this.Status = OperationStatus.Finished;
        }
        catch (Exception e)
        {
            this.Status = OperationStatus.Error;
            this.Message = e.ToString();
        }
    }

    protected abstract Task DoStart();
}
Run Code Online (Sandbox Code Playgroud)

启动这些任务的方法如下所示:

public static LongRunningOperation[] LaunchOperations()
{
    LongRunningOperation[] operations = GetAllLongRunningOperations();
    foreach (var o in operations)
        Task.Factory.StartNew(() => { o.Start(); });
    return operations;
}
Run Code Online (Sandbox Code Playgroud)

此方法返回的数组用于监视所有LongRunningOperations并记录统计信息.目前我有一个控制台应用程序,它有一个while (true)循环,可以打印屏幕上每个操作的统计信息(名称,状态,当前运行时)(每秒刷新一次),直到所有操作都完成.

困扰我的是async void …

.net c# task-parallel-library async-await

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