You create a class library that is used by applications in three departments of your Braindumps.

You create a class library that is used by applications in three departments of your Braindumps.
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>Braindumps</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 deptElement : public ConfigurationElement {
    protected :
    override void DeserializeElement(XmlReader^ reader,
    bool^ serializeCollectionKey) {
    Department^ dept = gcnew Department();
    dept->name = ConfigurationManager::AppSettings[“name”];
    dept->manager = ConfigurationManager::AppSettings[“manager”];
    return dept;
    }};
B. 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”);
    }};
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 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;
     }};

Answer: C

No comments:

Post a Comment