سؤال

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}");

    }
}

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

هل كانت مفيدة؟

المحلول

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

https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Interfaces/ServiceHost/IService.cs

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.

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top