3
我正在使用ServiceStack请求过滤器,我想要检查requestDTO参数的其中一个属性。该参数在运行时强类型化,但在编译时是一个通用对象。按类型访问ServiceStack requestDto对象
该过滤器将用于多个服务调用,因此requestDTO类型将根据调用的内容而改变。因此我无法对它进行特定的演员表演。但是,不管类型如何,requestDTO对象将始终有一个名为“AppID”的字符串属性。这是我希望访问的这个属性。
这里是我的代码(目前不编译):
public override void Execute(ServiceStack.ServiceHost.IHttpRequest req, ServiceStack.ServiceHost.IHttpResponse res, object requestDto)
{
//Check only for non-local requests
if (!req.IsLocal)
{
var app = this._appIDs.Apps.Where(x => x.ID == requestDto.AppID).FirstOrDefault();
var errResponse = DtoUtils.CreateErrorResponse("401", "Unauthorised", null);
var contentType = req.ResponseContentType;
res.WriteToResponse(req, errResponse);
res.EndRequest(); //stops further execution of this request
return;
}
}
此行不会编译:
var app = this._appIDs.Apps.Where(x => x.ID == requestDto.AppID).FirstOrDefault();
我需要与反思这里要处理访问我的对象或有没有内置到ServiceStack本身?
Gargh,当然。他们已经实施了适当的界面,我很愚蠢。再次感谢。 – Simon