#region Using Statements
using System;
using System.Text;
using System.Diagnostics;
using EnvDTE;
using Microsoft.Practices.ComponentModel;
using Microsoft.Practices.RecipeFramework; 
#endregion

namespace Microsoft.Practices.RecipeFramework.Extensions.ValueProviders.VisualStudio
{
    /// <summary>
    /// ValueProvider that returns the Active Document selected
    /// in the selected Project
    /// </summary>
    [ServiceDependency(typeof(DTE))]
    public class CurrentItemProvider : ValueProvider
    {
        /// <summary>
        /// Sets the newValue to the selected Document
        /// </summary>
        /// <param name="currentValue"></param>
        /// <param name="newValue"></param>
        /// <returns></returns>
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            DTE vs = (DTE)GetService(typeof(DTE));
            newValue = vs.SelectedItems.Item(1).ProjectItem as ProjectItem;
            return true;
        }
    }
}