/* Settings.cs * part of zaaReloaded2 * * Copyright 2015 Daniel Kraus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using zaaReloaded2.Formatter; using zaaReloaded2.Controller.Elements; namespace zaaReloaded2.Controller { /// /// Holds settings related to controlling laboratory output. /// [Serializable] public class Settings : ICloneable { #region Properties /// /// Gets or sets the name of these settings. /// public string Name { get; set; } /// /// Gets or sets the reference style. /// public ReferenceStyle ReferenceStyle { get; set; } /// /// Gets the list of controlling elements. /// public IList Elements { get; private set; } #endregion #region Constructors public Settings() { Elements = new List(); } public Settings(string name) : this() { Name = name; } /// /// Creates a new Settings object with an initial /// set of elements. /// /// Set of ElementBase /// object (or derived ones). public Settings(IList initialElements) { Elements = initialElements; } /// /// Creates a new Settings object with an initial /// set of elements and a name. /// /// Set of ElementBase /// object (or derived ones). /// Name of these settings. public Settings(string name, IList initialElements) : this(initialElements) { Name = name; } #endregion #region Public methods /// /// Adds an element to the list of Elements. /// /// Element to add. public void AddElement(ElementBase element) { Elements.Add(element); } #endregion #region Implementation of ICloneable public object Clone() { Settings clone = new Settings( String.Format("Kopie von {0}", Name), Elements.Select(e => e.Clone() as ElementBase).ToList() ); clone.ReferenceStyle = ReferenceStyle; return clone; } #endregion } }