Exemplo n.º 1
0
 /// <summary>Creates a new object that is a copy of the current instance.</summary>
 /// <remarks>
 /// <para>
 /// Clone can be implemented either as a deep copy or a shallow copy. In a deep copy, all objects are duplicated;
 /// in a shallow copy, only the top-level objects are duplicated and the lower levels contain references.
 /// </para>
 /// <para>
 /// The resulting clone must be of the same type as, or compatible with, the original instance.
 /// </para>
 /// <para>
 /// See <see cref="Object.MemberwiseClone"/> for more information on cloning, deep versus shallow copies, and examples.
 /// </para>
 /// </remarks>
 /// <param name = "objectToBeCopied">The object being copied.</param>
 public CapeObjectBase(CapeObjectBase objectToBeCopied)
     : base((CapeIdentification)objectToBeCopied)
 {
     m_SimulationContext = objectToBeCopied.m_SimulationContext;
     m_Parameters.Clear();
     foreach (CapeParameter parameter in objectToBeCopied.Parameters)
     {
         m_Parameters.Add((CapeParameter)parameter.Clone());
     }
     this.m_ValidationMessage = "This object has not been validated.";
     _disposed = false;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.</summary>
        /// <remarks>
        /// <para>
        /// Clone can be implemented either as a deep copy or a shallow copy. In a deep copy, all objects are duplicated;
        /// in a shallow copy, only the top-level objects are duplicated and the lower levels contain references.
        /// </para>
        /// <para>
        /// The resulting clone must be of the same type as, or compatible with, the original instance.
        /// </para>
        /// <para>
        /// See <see cref="Object.MemberwiseClone"/> for more information on cloning, deep versus shallow copies, and examples.
        /// </para>
        /// </remarks>
        /// <returns>A new object that is a copy of this instance.</returns>
        override public object Clone()
        {
            CapeObjectBase retVal = (CapeObjectBase)AppDomain.CurrentDomain.CreateInstanceAndUnwrap(this.GetType().AssemblyQualifiedName, this.GetType().FullName);

            retVal.Parameters.Clear();
            foreach (CapeParameter param in this.Parameters)
            {
                retVal.Parameters.Add((CapeParameter)param.Clone());
            }
            retVal.SimulationContext = null;
            if (retVal.GetType().IsAssignableFrom(typeof(ICapeSimulationContext)))
            {
                retVal.SimulationContext = (ICapeSimulationContext)this.m_SimulationContext;
            }
            return(retVal);
        }