view Chronosv2/source/Presentation/ViewModel/ViewModelBase.cs @ 19:09d18d6e5f40

airport work
author stevenh7776 stevenhollidge@hotmail.com
date Thu, 15 Mar 2012 06:59:15 +0000
parents 443821e55f06
children
line wrap: on
line source

using nRoute.Services;
using nRoute.ViewServices;

namespace Chronos.Presentation.ViewModel
{
    /// <summary>
    /// Provides a base class for Applications to inherit from. 
    /// </summary>
    public abstract class ViewModelBase 
        : ObservableObject
    {
        #region · Constructors ·

        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModelBase"/> class.
        /// </summary>
        protected ViewModelBase()
            : base()
        {
        }

        #endregion

        #region · Protected Methods ·

        /// <summary>
        /// Gets the requested service instance.
        /// </summary>
        /// <typeparam name="TService">The type of the service.</typeparam>
        /// <returns></returns>
        protected TService GetService<TService>() where TService : class
        {
            return ServiceLocator.GetService<TService>();
        }

        /// <summary>
        /// Gets the requested view service.
        /// </summary>
        /// <typeparam name="TViewService">The type of the view service.</typeparam>
        /// <returns></returns>
        protected TViewService GetViewService<TViewService>() where TViewService : class
        {
            return ViewServiceLocator.GetViewService<TViewService>();
        }

        #endregion
    }
}