//===============================================================================
// Microsoft patterns & practices
// Web Service Software Factory
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.RecipeFramework;
using EnvDTE;
using Microsoft.Practices.SoftwareFactories.ServiceFactory.Actions.Configuration.Helpers; 
#endregion

namespace Microsoft.Practices.SoftwareFactories.ServiceFactory.Actions.Configuration
{
    /// <summary>
    /// Action that returns a Configuration Item
    /// </summary>
    public class GetConfigurationItemAction : Action
    {
        #region Input Properties
        Project project;
        /// <summary>
        /// The project that owns the configuration file
        /// </summary>
        [Input(Required = true)]
        public Project Project
        {
            get { return project; }
            set { project = value; }
        }
        #endregion

        #region Output Properties
        ProjectItem projectItem;
        /// <summary>
        /// The configuration project item
        /// </summary>
        [Output]
        public ProjectItem ProjectItem
        {
            get { return projectItem; }
            set { projectItem = value; }
        }
	    #endregion

        #region Action Implementation
        /// <summary>
        /// See <see cref="M:Microsoft.Practices.RecipeFramework.IAction.Execute"/>.
        /// </summary>
        public override void Execute()
        {
            projectItem = ConfigurationVSHelper.GetConfigurationItem(project);
        }

        /// <summary>
        /// See <see cref="M:Microsoft.Practices.RecipeFramework.IAction.Undo"/>.
        /// </summary>
        public override void Undo()
        {
            this.ProjectItem = null;
        } 
        #endregion
    }
}
