开发者

Attributes on interface

开发者 https://www.devze.com 2023-03-08 03:40 出处:网络
I\'m working on an interface named IService. This interface replaces exist one and the application need to refer it as \"Service\" and not \"IService\" (I cannot change th开发者_StackOverflow社区e ap

I'm working on an interface named IService.

This interface replaces exist one and the application need to refer it as "Service" and not "IService" (I cannot change th开发者_StackOverflow社区e application code) I do not want to break the .Net naming conventions.

Is there a way to add attributes to interface do one defines it reference name?


If you really need keep the name Service for this interface, then you should just call it Service, and make sure its XML comment explains why you omitted the I.

Naming conventions are just that: conventions. As long as you make the reason for deviation clear, you don't need to follow them all the time.


Do the references in the application to Service require it to be an interface (ie, class inheritance where a base class is already used)? Or could you just create a blank Service class and inherit your interface?

public interface IService {
    //your code
}

public abstract class Service : IService {
}

If you need it to be an interface, then I'd go with dlev's answer. Conventions are just conventions.

0

精彩评论

暂无评论...
验证码 换一张
取 消