Question:

You create a class library that is used by applications in three departments of your company. The library contains a Department class with the following definition.

public ref class Department {

public :

String= name;

String= manager;

};

Each application uses a custom configuration section to store department-specific values in the application configuration file as shown in the following code.

<Department>

<name>Hardware</name>

<manager>Amy</manager>

</Department>

You need to write a code segment that creates a Department object instance by using the field values retrieved from the application configuration file.

Which code segment should you use?

 

A public ref class deptHandler : public IConfigurationSectionHandler { public :
Object= Create(Object= parent,
Object= configContext, System.Xml.XmlNode= section) {

Department= dept = gcnew Department();
dept->name = section->Attributes["name"].Value;
dept->manager = section->Attributes["manager"].Value; return dept;
}
}; 

B public ref class deptElement : public ConfigurationElement { "A Composite Solution With Just One Click" - Certification Guaranteed 278 Microsoft 70-536 Exam
protected :
override void DeserializeElement(XmlReader= reader,
bool= serializeCollectionKey) {
Department= dept = gcnew Department();
dept->name = ConfigurationManager::AppSettings["name"]; dept->manager = ConfigurationManager::
AppSettings["manager"]; return dept;
}
}; 

C public ref class deptHandler :
public IConfigurationSectionHandler {
public :

Object= Create(Object= parent,
Object= configContext, System.Xml.XmlNode section) {

Department= dept = gcnew Department();
dept->name = section->SelectSingleNode("name")->InnerText; dept->manager = section-
>SelectSingleNode("manager")->InnerText; return dept;
}
}; 

D public ref class deptElement : public ConfigurationElement { protected :
override void DeserializeElement(XmlReader= reader,
bool= serializeCollectionKey) {

Department= dept = gcnew Department();

dept->name = reader->GetAttribute("name");

dept->manager = reader->GetAttribute("manager");
}
}; 

+ Answer
+ Report
Total Preview: 596

Copyright © 2024. Powered by Intellect Software Ltd