using System;
using System.Runtime.Serialization;
using Umbraco.Core;
namespace Umbraco.Web.Install.Models
{
///
/// Model to give to the front-end to collect the information for each step
///
[DataContract(Name = "step", Namespace = "")]
public abstract class InstallSetupStep : InstallSetupStep
{
///
/// Defines the step model type on the server side so we can bind it
///
[IgnoreDataMember]
public override Type StepType
{
get { return typeof(T); }
}
///
/// The step execution method
///
///
///
public abstract InstallSetupResult Execute(T model);
}
[DataContract(Name = "step", Namespace = "")]
public abstract class InstallSetupStep
{
protected InstallSetupStep()
{
var att = GetType().GetCustomAttribute(false);
if (att == null)
{
throw new InvalidOperationException("Each step must be attributed");
}
Name = att.Name;
View = att.View;
ServerOrder = att.ServerOrder;
Description = att.Description;
InstallTypeTarget = att.InstallTypeTarget;
PerformsAppRestart = att.PerformsAppRestart;
}
[DataMember(Name = "name")]
public string Name { get; private set; }
[DataMember(Name = "view")]
public virtual string View { get; private set; }
[DataMember(Name = "description")]
public string Description { get; private set; }
[IgnoreDataMember]
public InstallationType InstallTypeTarget { get; private set; }
[IgnoreDataMember]
public bool PerformsAppRestart { get; private set; }
///
/// Determines if this step needs to execute based on the current state of the application and/or install process
///
///
public abstract bool RequiresExecution();
///
/// Defines what order this step needs to execute on the server side since the
/// steps might be shown out of order on the front-end
///
[DataMember(Name = "serverOrder")]
public int ServerOrder { get; private set; }
///
/// Defines the step model type on the server side so we can bind it
///
[IgnoreDataMember]
public abstract Type StepType { get; }
[IgnoreDataMember]
public bool HasUIElement
{
get { return View.IsNullOrWhiteSpace() == false; }
}
}
}