由另一个类继承的ServiceBehavior属性? [英] Is the ServiceBehavior attribute inherited by another classes?

查看:171
本文介绍了由另一个类继承的ServiceBehavior属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个WCF服务,并且这些服务共享一些通用的方法。所以,我创建了一个基类(不WCF服务)使用这些方法,并提出所有的WCF服务,从这个类继承。事情是这样的:

I have several WCF services, and those services share some common methods. So, I have created a base class (not a WCF service) with those methods and made all the WCF services to inherit from this class. Something like this:

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

和的WCF服务中的一个:

And one of the WCF services:

public class ExampleService : BaseService, IExampleService
    {

我使用ServiceBehavior属性设置ConcurrencyMode和InstanceContextMode价值观,我的问题是:是正确标记与ServiceBehavior属性的基类,并期望所有服务继承ServiceBehavior属性的值,或我应该标志着一个个都在WCF服务?

I'm using the ServiceBehavior attribute to set the ConcurrencyMode and InstanceContextMode values, and my question is: Is correct to mark the base class with the ServiceBehavior attribute, and expect all the services to inherit the values of the ServiceBehavior attribute, or should I mark one by one all the WCF services?

推荐答案

是的,ServiceBehavior属性被继承到子类的ServiceBehaviorAttribute类具有不将继承值设置为False AttributeUsage特性。

Yes, ServiceBehavior Attribute is inherited to the child classes as the "ServiceBehaviorAttribute" class has the AttributeUsage attribute which doesn't set the "Inherited" value to False.

有继承的默认值是AttributeUsageAttribute级真。

The default value for "Inherited" is True in "AttributeUsageAttribute" class.

一个简单的例子是设置Namespace属性在抽象类,看到反映在您的WSDL。

A simple example would be to set the Namespace property in your Abstract class and see that reflected in your wsdl.

这篇关于由另一个类继承的ServiceBehavior属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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