Which code segment should you use?

You are creating a Windows Communication Foundation service by using Microsoft .NET Framework 3.5. The service will be hosted on a Web server. You add the following code fragment to the .svc file.
<% @ServiceHost Factory=”ExamServiceFactory” Service=”ExamService” %>
You need to create the instances of the services by using the custom ExamServiceFactory class.
Which code segment should you use?

You are creating a Windows Communication Foundation service by using Microsoft .NET Framework 3.5. The service will be hosted on a Web server. You add the following code fragment to the .svc file.
<% @ServiceHost Factory=”ExamServiceFactory” Service=”ExamService” %>
You need to create the instances of the services by using the custom ExamServiceFactory class.
Which code segment should you use?

A.
public class ExamServiceFactory: ServiceHost
{
protected override void ApplyConfiguration()
{ //Implementation code comes here. }
}

B.
public class ExamServiceFactory: ServiceHostBase
{
protected override void ApplyConfiguration()
{ //Implementation code comes here. }
}

C.
public class ExamServiceFactory: ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{ //Implementation code comes here. }
}

D.
public class ExamServiceFactory: ServiceHost
{
public ExamServiceFactory(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses)
{ //Implementation code comes here. }
}

Explanation:
Factory: The CLR type name of the service host factory used to instantiate the service host. This attribute is optional. If unspecified, the default ServiceHostFactory is used, which returns an instance of ServiceHost.

http://msdn.microsoft.com/en-us/library/aa967286.aspx



Leave a Reply 1

Your email address will not be published. Required fields are marked *


kimberlyadler

kimberlyadler

It’s a good post.