Which class should you use?
You are building a client for a Windows Communication Foundation (WCF) service. You need to create a proxy to consume this service. Which class should you use?
Which code segment should you inser at line 03?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application contains following XML document.
<feed>
<title>Products</title>
<entry>
<title>Entry title 1</title>
<author>Author 1</author>
<content>
<properties>
<description>some description</description>
<notes>some notes</notes>
<comments>some comments</comments>
</properties>
</content>
</entry>
…
</feed>
You plan to add localization features to the application. You add the following code segment.
(Line numbers are included for reference only.)
01 public IEnumerable <XNode> GetTextNodesForLocalization(XDocument doc)
02 {
03 …
04 return from n in nodes
05 where n.NodeType = XmlNodeType.Text
06 select n;
07 }
You need to ensure that the GetTextNodeForLocalization method returns all the XML text nodes of the XML document.
Which code segment should you inser at line 03?
Which code segment should you use?
You are implementing an ASP.NET Web site.
The site allows users to explicitly choose the display language for the site’s Web pages.
You create a Web page that contains a DropDownList named ddlLanguage, as shown in the following code segment.
<asp:DropDownList ID=”ddlLanguage” runat=”server” AutoPostBack=”True” ClientIDMode=”Static” OnSelectedIndexChanged=”SelectedLanguageChanged”>
<asp:ListItem Value=”en”>English</asp:ListItem>
<asp:ListItem Value=”es”>Spanish</asp:ListItem>
<asp:ListItem Value=”fr”>French</asp:ListItem>
<asp:ListItem Value=”de”>German</asp:ListItem>
</asp:DropDownList>
The site contains localized resources for all page content that must be translated into the language that is selected by the user.
You need to add code to ensure that the page displays content in the selected language if the user selects a language in the drop-down list.
Which code segment should you use?
Which header and request type should you use in the application?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Communication Foundation (WCF) Data Services service. You discover that when an application submits a PUT or DELETE request to the Data Services service, it receives an error. You need to ensure that the application can access the service. Which header and request type should you use in the application?
What should you do?
You are creating a Windows Communication Foundation (WCF) service that implements operations in a RESTful manner. You need to add a delete operation. You implement the delete method as follows.
Sub DeleteItems(ByVal id As String)
You need to configure WCF to call this method when the client calls the service with the HTTP DELETE operation. What should you do?
Which line of code should you insert at line 09?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application
that connects to a Microsoft SQL Server 2008 database. You add the following table to the database.
CREATE TABLE ObjectCache (
Id INT IDENTITY PRIMARY KEY,
SerializedObjectData XML)
You write the following code segment to retreive records from the ObjectCache table.
(Line numbers are included for reference only.)
01 string s = GetConnectionStringFromConfigFile(“xmldb”);
02 using (SqlConnection conn = new SqlConnection(s))
03 using (SqlCommand cmd = new SqlCommand(“select * from ObjectCache”, conn))
04 {
05 conn.Open();
06 SqlDataReader rdr = cmd.ExecuteReader();
07 while(rdr.Read())
08 {
09 …
10 DeserializeObject(obj);
11 }
12 }
You need to retreive the data from the SerializedObjectData column and pass it to a method named DeserializeObject.
Which line of code should you insert at line 09?
What should you do?
You are creating an ASP.NET Web site.
The site has a master page named Custom.master.
The code-behind file for Custom.master contains the following code segment.
public partial class CustomMaster : MasterPage
{
public string Region
{
get; set;
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
You create a new ASP.NET page and specify Custom.master as its master page.
You add a Label control named lblRegion to the new page.
You need to display the value of the master page’s Region property in lblRegion.
What should you do?
Which code segment should you insert at line 07?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a table named dbo.Documents that contains a column with large binary dat a. You are creating the Data Access Layer (DAL). You add the following code segment to query the dbo.Documents table. (Line numbers are included for reference only.)
01public void LoadDocuments(DbConnection cnx)
02{
03var cmd = cnx.CreateCommand();
04cmd.CommandText = “SELECT * FROM dbo.Documents”;
05…
06cnx.Open();
07
08ReadDocument(reader); }
You need to ensure that data can be read as a stream. Which code segment should you insert at line 07?
What should you do?
A Windows Communication Foundation (WCF) application uses a data contract that has several data members. You need the application to throw a SerializationException if any of the data members are not present when a serialized instance of the data contract is deserialized.
What should you do?
Which code segment should you insert at line 04?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server 2008 database. You add the following store procedure to the database.
CREATE PROCEDURE GetSalesPeople
AS
BEGIN
SELECT FirstName, LastName, Suffix, Email, Phone
FROM SalesPeople
END
You write the following code segment. (Line numbers are included for reference only.)
01 SqlConnection connection = new SqlConnection(“…”);
02 SqlCommand command = new SqlCommand(“GetSalesPeople”, connection);
03 command.CommandType = CommandType.StoredProcedure;
04 …
You need to retreive all of the results from the stored procedure. Which code segment should you insert at line 04?