ServiceBehavior属性是否由其他类inheritance?

我有几个WCF服务,这些服务共享一些常用方法。 所以,我用这些方法创建了一个基类(不是WCF服务),并使所有WCF服务都从这个类inheritance。 像这样的东西:

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall)] public abstract class BaseService 

并且其中一个WCF服务:

 public class ExampleService : BaseService, IExampleService { 

我正在使用ServiceBehavior属性来设置ConcurrencyMode和InstanceContextMode值,我的问题是:使用ServiceBehavior属性标记基类是正确的,并期望所有服务inheritanceServiceBehavior属性的值,或者我应该标记所有WCF服务一个接一个?

是的,ServiceBehavior属性inheritance到子类,因为“ServiceBehaviorAttribute”类具有AttributeUsage属性,该属性不将“Inherited”值设置为False。

“Inherited”的默认值在“AttributeUsageAttribute”类中为True。

一个简单的例子是在Abstract类中设置Namespace属性,并查看wsdl中反映的内容。