|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ControlToViewModelMapping.cs" company="Catel development team">
// Copyright (c) 2008 - 2011 Catel development team. All rights reserved.
// </copyright>
// <summary>
// Holds the information for a control to viewmodel mapping. The information is based on the <see cref="ControlToViewModelAttribute"/>.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Reflection;
using Catel.Windows.Properties;
using log4net;
namespace Catel.MVVM.UI
{
/// <summary>
/// Holds the information for a control to viewmodel mapping. The information is based on the <see cref="ControlToViewModelAttribute"/>.
/// </summary>
internal class ControlToViewModelMapping
{
#region Variables
/// <summary>
/// The <see cref="ILog">log</see> object.
/// </summary>
protected static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Constructor & destructor
/// <summary>
/// Initializes a new instance of the <see cref="ControlToViewModelMapping"/> class.
/// </summary>
/// <param name="controlPropertyName">Name of the control property.</param>
/// <param name="viewModelPropertyName">Name of the view model property.</param>
/// <param name="mapping">The mapping type.</param>
/// <exception cref="ArgumentException">when <paramref name="controlPropertyName"/> is <c>null</c> or empty.</exception>
/// <exception cref="ArgumentException">when <paramref name="viewModelPropertyName"/> is <c>null</c> or empty.</exception>
public ControlToViewModelMapping(string controlPropertyName, string viewModelPropertyName, ControlViewModelModelMappingType mapping)
{
if (string.IsNullOrEmpty(controlPropertyName))
{
throw new ArgumentException(Exceptions.ArgumentCannotBeNullOrEmpty, "controlPropertyName");
}
if (string.IsNullOrEmpty(viewModelPropertyName))
{
throw new ArgumentException(Exceptions.ArgumentCannotBeNullOrEmpty, "viewModelPropertyName");
}
ControlPropertyName = controlPropertyName;
ViewModelPropertyName = viewModelPropertyName;
MappingType = mapping;
Log.Debug(TraceMessages.CreatedControlToViewModelMapping, mapping, controlPropertyName, viewModelPropertyName);
}
#endregion
#region Properties
/// <summary>
/// Gets the name of the control property.
/// </summary>
/// <value>The name of the control property.</value>
public string ControlPropertyName { get; private set; }
/// <summary>
/// Gets the name of the view model property.
/// </summary>
/// <value>The name of the view model property.</value>
public string ViewModelPropertyName { get; private set; }
/// <summary>
/// Gets or sets the mapping type.
/// </summary>
/// <value>The mapping type.</value>
public ControlViewModelModelMappingType MappingType { get; private set; }
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.