public void SequenceClone() { ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "SequenceClone test started")); string seqData = "ACGAACCGGAAACCCGGG"; Sequence orgSeq = new Sequence(Alphabets.DNA, seqData); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Original Sequence: " + orgSeq.ToString())); Sequence cloneSeq = orgSeq.Clone(); // Test the clone copy with original. Assert.AreEqual(cloneSeq.ToString(), orgSeq.ToString()); Assert.AreEqual(cloneSeq.Alphabet, orgSeq.Alphabet); Assert.AreEqual(cloneSeq.Complement.ToString(), orgSeq.Complement.ToString()); Assert.AreEqual(cloneSeq.Count, orgSeq.Count); Assert.AreEqual(cloneSeq.DisplayID, orgSeq.DisplayID); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Cloned Sequence: " + cloneSeq)); // Check whether modifying the clone sequence modifies the original sequence or not. cloneSeq.IsReadOnly = false; cloneSeq[1] = Alphabets.DNA.G; cloneSeq[2] = Alphabets.DNA.G; cloneSeq[3] = Alphabets.DNA.G; Assert.AreEqual(orgSeq.ToString(), seqData); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Original Sequence After modifying the cloned sequence: " + orgSeq.ToString())); // Test using ISequence interface. ISequence seq1 = orgSeq; ISequence seq2 = seq1.Clone(); Assert.AreEqual(seq1.ToString(), seq2.ToString()); // Test using ICloneable interface. ICloneable cloneseq1 = orgSeq; Sequence cloneseq2 = cloneseq1.Clone() as Sequence; Assert.AreEqual(cloneseq1.ToString(), cloneseq2.ToString()); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "SequenceClone test completed")); }
public object Clone() { RmAttributeValue newValue = new RmAttributeValue(); newValue.values = new List <IComparable>(); foreach (IComparable value in this.values) { ICloneable cloneValue = value as ICloneable; if (cloneValue == null) { newValue.values.Add(value); } else { IComparable cloneInsert = cloneValue.Clone() as IComparable; if (cloneInsert == null) { throw new InvalidOperationException("A comparable, when cloned, returned a non-comparable: " + cloneValue.ToString()); } newValue.values.Add(cloneInsert); } } return(newValue); }
public static string ExtendInterface(this ICloneable self) { return(self.ToString()); }