什么是IService接口命名空间? [英] What is the namespace for IService interface?

查看:767
本文介绍了什么是IService接口命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习ServiceStack和开发HelloWorld的简单的演示,但无法找到 ISservice 接口命名空间,我的code按如下:

I am learning ServiceStack and developing simple demo for helloworld, but could not find namespace for ISservice interface, my code as per below:

 public class Hello
{
    public string name { get; set; }
}
public class HelloResponse
{
    public string Result { get; set; }
}

public class HelloService :  **IService**<Hello>
{
    public object Execute(Hello request)
    {
        return new HelloResponse { Result = "Hello" + request.name };
    }
}

public class HelloAppHost : AppHostBase
{
    public HelloAppHost() : base("Hello Web Services", typeof(HelloService).Assembly) { }
    public override void Configure(Funq.Container container)
    {
        Routes.Add<Hello>("/hello")
            .Add<Hello>("/hello/{Name}");

    }
}

谁能告诉我我需要添加 IService 接口什么的命名空间或DLL?

Can anyone please tell me what namespace or DLL I need to add for IService interface?

推荐答案

ServiceStack的 IService&LT; T&GT; 是在 ServiceStack.ServiceHost 命名空间而住在 ServiceStack.Interfaces.dll ,为什么这里的类:

ServiceStack's IService<T> is in the ServiceStack.ServiceHost namespace which lives in the ServiceStack.Interfaces.dll, why here's the class:

<一个href=\"https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Interfaces/ServiceHost/IService.cs\" rel=\"nofollow\">https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Interfaces/ServiceHost/IService.cs

请注意:如果你是刚刚起步的,它可能更好地继承 <一个href=\"https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.ServiceInterface/ServiceBase.cs\"相对=nofollow> ServiceStack.ServiceInterface.ServiceBase&LT; T&GT; 并覆盖在运行()方法,它是一个有用的基类,提供如自动异常处理的事情你。

Note: If you're just starting out, it's probably better to inherit from ServiceStack.ServiceInterface.ServiceBase<T> and override the Run() method which is a useful base class that provides things like auto exception handling for you.

如果您希望能够运行不同code代表不同的HTTP动词如GET / POST / PUT / DELETE(即创建REST Web服务)比你要继承的 RestServiceBase 而不是和重写其使用onGET / onPOST等/ OnPut / OnDelete方法。

If you want to be able run different code for different HTTP Verbs e.g GET/POST/PUT/DELETE (i.e. creating REST web services) than you want to inherit from RestServiceBase instead and override its OnGet/OnPost/OnPut/OnDelete methods.

这篇关于什么是IService接口命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆