2013-01-24 58 views
2

我创建的自定义RegistrationFeature:ServiceStack登记

public class CustomRegistrationFeature: IPlugin 
{ 
    private string AtRestPath {get; set;} 
    public CustomRegistrationFeature() 
    { 
     AtRestPath = "/register"; 
    } 
    public void Register (IAppHost apphost) 
    { 
     appHost.RegisterService <CustomRegistrationService>(AtRestPath); 
     appHost.RegisterAs <CustomRegistrationValidator, IValidator <CustomRegistration>>(); 
    } 
} 

我在APPHOST配置:

Plugins.Add (new CustomRegistrationFeature()); 

但在元数据页有CustomRegistration和注册。 为什么? 谢谢。

更新

的CustomRegistrationService:

[DefaultRequest(typeof(CustomRegistration))] 
public class CustomRegistrationService : RegistrationService 
{ 
    public object Post(CustomRegistration request) 
    { 
     //base.Post(request); 
     return new CustomRegistrationResponse(); 
    } 
} 

的CustomRegistration(请求DTO):

[DataContract] 
public class CustomRegistration : IReturn<CustomRegistrationResponse> 
{ 
    [DataMember] 
    public string Name{ get; set; } 
} 

的CustomRegistrationResponse(响应DTO):

[DataContract] 
public class CustomRegistrationResponse 
{ 
    [DataMember] 
    public string Test { get; set; } 
} 

回答

1

CustomRegistration服务应该出现,虽然我们无法看到它的实现,但我不知道服务是否已被正确写入。

但是没有理由为什么注册将出现在/metadata页面中,因为您尚未注册RegistrationFeature

+0

谢谢你的回答。我添加了我的CustomRegistration服务 – user2007820