///
/// Copyright © 2003-2008 JetBrains s.r.o.
/// You may distribute under the terms of the GNU General Public License, as published by the Free Software Foundation, version 2 (see License.txt in the repository root folder).
///
using System;
using JetBrains.Build.Omea.Infra;
using JetBrains.Build.Omea.Util;
using Microsoft.Build.Utilities;
namespace JetBrains.Build.Omea.Resolved.Infra
{
///
/// The base class for the “Resolved” part of the product-dependent tasks.
/// These tasks require strong references to the product binaries. They're loaded into a different AppDomain (to unload on completion), and a special resolved is installed to locate them in the binaries folder.
/// These resolved task parts should be capable of reading the parameters their actual tasks receive, which is achieved thru the use of a property bag.
///
public abstract class TaskBaseResolved : MarshalByRefObject, ITaskBaseResolved
{
#region Data
///
/// .
///
private TaskLoggingHelper myLog;
#endregion
#region Attributes
///
/// Gets or sets the logger into which the progress/status messages should be emitted.
///
public TaskLoggingHelper Log
{
get
{
return myLog ?? (myLog = Bag.Get(AttributeName.AfxLog));
}
}
#endregion
#region Implementation
///
/// The method to be overriden in inheriting tasks.
/// Throw an exception in case of an errror.
///
protected abstract void ExecuteTaskResolved();
#endregion
#region ITaskBaseResolved Members
///
/// Executes the resolved task, catches and reports its exceptions.
/// Should not throw.
///
public void Execute()
{
if(Bag == null)
throw new InvalidOperationException(string.Format("The Parameter Bag must have been given to the task before executing it."));
ExecuteTaskResolved();
}
///
/// Gets or sets the task parameters bag that comes from the unresolved part of the task.
///
public Bag Bag { get; set; }
#endregion
}
}