Which code segment should you use?

You create a class library that is used by applications in three departments of Domain.com.
The library contains a Department class with the following definition.
public class Department {
public string name;
public 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.

Hardware
Certkiller

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?

You create a class library that is used by applications in three departments of Domain.com.
The library contains a Department class with the following definition.
public class Department {
public string name;
public 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.

Hardware
Certkiller

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 class deptElement : ConfigurationElement {
protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey) {
Department dept = new Department();
dept.name = ConfigurationManager.AppSettings[“name”];
dept.manager = ConfigurationManager.AppSettings[“manager”]; return dept;
}
}

B.
public class deptElement: ConfigurationElement {
protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey) {
Department dept = new Department();
dept.name = reader.GetAttribute(“name”);
dept.manager = reader.GetAttribute(“manager”);
}
}

C.
public class deptHandler : IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) {
Department dept = new Department();
dept.name = section.SelectSingleNode(“name”).InnerText;
dept.manager = section.SelectSingleNode(“manager”).InnerText; return dept;
}
}

D.
public class deptHandler : IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) {
Department dept = new Department();
dept.name = section.Attributes[“name”].Value;
dept.manager = section.Attributes[“manager”].Value;
return dept;
}
}



Leave a Reply 2

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


networkmanagers

networkmanagers

I choose C

paulojmbarbosa

paulojmbarbosa

I don’t no what is the right question. But these questions don’t make sense..in 70-410, 70-411 or 70-412 questions about Windows Server 2012..