Which code segment should you use?
You are consuming a Windows Communication Foundation (WCF) service.
The service interface is defined as follows:
[DataContract(Namespace = ”]
public class Item
{
}
[ServiceContract(Namespace = ”)]
public interface Catalog
{
[OperationContract]
[WebInvoke(Method=”POST”, UriTemplate=”{Item}”)]
Item UpdateItem(Item item);
}
The client application receives a WebResponse named response with the response from the service.
You need to deserialize this response into a strongly typed object representing the return value of the method.
Which code segment should you use?
Which code segment should you insert at line 05?
You use Microsoft .NET Framework 4 to create a Windows Forms application.
You plan to use a Windows Presentation Foundation (WPF) control of the UserControl1 type hosted in an
ElementHost control named elementHost1.
You write the following code segment. (Line numbers are included for reference only.)
01public class WPFInWinForms {
02public WPFInWinForms
03{
04InitializeComponent();
05
06}
07private void OnBackColorChange(object sender, String propertyName, object value)
08{
09ElementHost host = sender as ElementHost;
10System.Drawing.Color col = (System.Drawing.Color)value;
11SolidColorBrush brush =
new SolidColorBrush(System.Windows.Medi
a.Color.FromRgb(col.R, col.G, col.B));
12UserControl1 uc1 = host.Child as UserControl1;
13uc1.Background = brush;
14}
15}
You need to ensure that the application changes the background color of the hosted control when the background color of the form changes.
Which code segment should you insert at line 05?
What should you do?
You are designing a Windows Presentation Foundation (WPF) application by using Microsoft .NET Framework 4, Microsoft Visual Studio 2010, and Microsoft SQL Server 2008.
You have designed the application to use the ADO.NET Entity Framework for the Data Access Layer (DAL).
You have designed the user interface (UI) of the application by using the Model-View-ViewModel (M-V-VM) pattern.
The middle tier of the application is designed by using Windows Communication Foundation (WCF).
The database schema changes often. The DAL entity objects are required to be referenced from the middle tier and the ViewModel layer of the UI.
You need to ensure that the DAL entity objects are updated when the database schema changes.
What should you do?
Which two actions should you perform?
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code segment. (Line numbers are included for reference only.)
01public class Contact
02{
03private string _contactName;
04
05public string ContactName {
06get { return _contactName; }
07set { _contactName = value; }
08}
09
10}
You add the following code fragment within a WPF window control.
<TextBox>
<TextBox.Text>
<Binding Path=”ContactName” UpdateSourceTrigger=”PropertyChanged”>
<Binding.ValidationRules>
<DataErrorValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
The TextBox control is data-bound to an instance of the Contact class.
You need to ensure that the Contact class contains a business rule to ensure that the ContactName property is not empty or NULL.
You also need to ensure that the TextBox control validates the input data.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two).
Which code segment should you use?
You are consuming a Windows Communication Foundation (WCF) service in an ASP. NET Web application.
The service interface is defined as follows:
[ServiceContract]
public interface ICatalog
{
[OperationContract]
[WebGet(UriTemplate=”/Catalog/Items/{id}”, ResponseFormat=WebMessageFormat.Json)]
string RetrieveItemDescription(int id);
}
The service is hosted at Catalogsvc.
You need to call the service using jQuery to retrieve the description of an item as indicated by a variable named itemId.
Which code segment should you use?
Which binding expression should you use?
You use Microsoft Visual Studio 2010 and Microsoft .
NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You create a WPF window in the application.
You add the following code segment to the application.
public class ViewModel
{
public CollectionView Data { get; set; }
}
public class BusinessObject
{
public string Name { get; set; }
}
The DataContext property of the window is set to an instance of the ViewModel class.
The Data property of the ViewModel instance is initialized with a collection of BusinessObject objects.
You add a TextBox control to the Window.
You need to bind the Text property of the TextBox control to the Name property of the current item of the CollectionView of the DataContext object.
You also need to ensure that when a binding error occurs, the Text property of the TextBox control is set to N/A .
Which binding expression should you use?
Which code segment should you write for the click event handler for btnDetails?
You create a Windows client application by using Windows Presentation Foundation (WPF).
The application contains the following code fragment.
<Window.Resources>
<DataTemplate x:Key=”detail”>
<!–…–>
</DataTemplate>
</Window.Resources>
<StackPanel>
<ListBox Name=”lbDetails”>
</ListBox>
<Button Name=”btnDetails”>Details</Button>
</StackPanel>
You need to assign lbDetails to use the detail data template when btnDetails is clicked.
Which code segment should you write for the click event handler for btnDetails?
What should you do?
A Windows Communication Foundation (WCF) service implements the following contract.
(Line numbers are included for reference only.)
01 [ServiceContract]
02 public interface IDataAccessService
03 {
04 [OperationContract]
05 void PutMessage(string message);
06 …
07 [OperationContract]
08 [FaultContract(typeof(TimeoutFaultException))]
09 [FaultContract(typeof(FaultException))]
10 string SearchMessages(string search);
11 }
The implementation of the SearchMessages method throws TimeoutFaultException exceptions for database timeouts.
The implementation of the SearchMessages method also throws an Exception for any other issue it encounters while processing the request.
These exceptions are received on the client side as generic FaultException exceptions.
You need to implement the error handling code for SearchMessages and create a new channel on the client only if the channel faults.
What should you do?
How can you achieve this?
You have definded a style in app.xaml
<Style x:Key=”A” x:Name=”B”
…
</Style>
You want to use this style in your application in code behind.
How can you achieve this?
Which two actions should you recommend?
You are designing a .NET Framework 4 solution. The solution contains a Windows Presentation Foundation (WPF) application and a Windows Communication Foundation (WCF) Web service. The WPF application uses the WCF Web service to store data in a Microsoft SQL Server 2008 database.
You have the following requirements:
Ensure that the WPF application functions while users’computers are offline. Minimize the time spent sending data to the WCF Web service.
Minimize disk space requirements for data storage.
You need to recommend an approach for synchronizing data between the WPF application and the database.
Which two actions should you recommend? (Each correct answer presents part of the solution. Choose two.)