Make some classes ICloneable; implement SettingsRepositoryViewModel.

This commit is contained in:
Daniel Kraus
2015-08-01 21:23:56 +02:00
parent 5197c294b9
commit d0be7524d3
15 changed files with 478 additions and 67 deletions

View File

@ -36,5 +36,12 @@ namespace zaaReloaded2.Controller.Elements
{
formatter.WriteParagraph(Content);
}
protected override ElementBase CreateInstance()
{
CustomText clone = new CustomText();
clone.Content = Content;
return clone;
}
}
}

View File

@ -28,7 +28,7 @@ namespace zaaReloaded2.Controller.Elements
/// Base class for formatting elements.
/// </summary>
[Serializable]
public abstract class ElementBase
public abstract class ElementBase : ICloneable
{
/// <summary>
/// Returns the label for this formatting element.
@ -44,5 +44,16 @@ namespace zaaReloaded2.Controller.Elements
/// Element belongs to. The Formatter object provides access
/// to the current Word document etc.</param>
abstract public void Run(zaaReloaded2.Formatter.Formatter formatter);
public object Clone()
{
return CreateInstance();
}
/// <summary>
/// Creates a new instance that can be used for cloning.
/// </summary>
/// <returns>New instance of a derived class.</returns>
protected abstract ElementBase CreateInstance();
}
}

View File

@ -43,5 +43,10 @@ namespace zaaReloaded2.Controller.Elements
public SelectEachDay(IList<FormatElementBase> formatElements)
: base(formatElements)
{ }
protected override ElementBase CreateInstance()
{
return new SelectEachDay();
}
}
}

View File

@ -47,5 +47,10 @@ namespace zaaReloaded2.Controller.Elements
public SelectFirstDay(IList<FormatElementBase> formatElements)
: base(formatElements)
{ }
protected override ElementBase CreateInstance()
{
return new SelectFirstDay();
}
}
}

View File

@ -48,5 +48,10 @@ namespace zaaReloaded2.Controller.Elements
public SelectLastDay(IList<FormatElementBase> formatElements)
: base(formatElements)
{ }
protected override ElementBase CreateInstance()
{
return new SelectLastDay();
}
}
}