Beispiel #1
0
        /// <summary>
        /// Create copy of DataSourceDefinition.
        /// </summary>
        /// <param name="dataSourceDefinition"></param>
        public object Clone()
        {
            DataSourceDefinition dataSourceDefinition = (DataSourceDefinition)this.MemberwiseClone();

            dataSourceDefinition.Fields = new List <DBField>();
            for (int fieldIdx = 0; fieldIdx < Fields.Count; fieldIdx++)
            {
                DBField newField = (DBField)Fields[fieldIdx].Clone();
                dataSourceDefinition.Fields.Add(newField);
            }

            dataSourceDefinition.Keys = new List <DBKey>();
            for (int keyIdx = 0; keyIdx < Keys.Count; keyIdx++)
            {
                DBKey newKey = (DBKey)Keys[keyIdx].Clone();
                for (int segmentIdx = 0; segmentIdx < newKey.Segments.Count; segmentIdx++)
                {
                    DBSegment segment = (DBSegment)newKey.Segments[segmentIdx];
                    segment.Field = dataSourceDefinition.Fields.Find(x => x.Isn == Keys[keyIdx].Segments[segmentIdx].Field.Isn);
                }
                dataSourceDefinition.Keys.Add(newKey);
            }

            dataSourceDefinition.Segments = new List <DBSegment>();
            for (int segmentIdx = 0; segmentIdx < Segments.Count; segmentIdx++)
            {
                DBSegment newSegment = (DBSegment)Segments[segmentIdx].Clone();
                newSegment.Field = dataSourceDefinition.Fields.Find(x => x.Isn == Segments[segmentIdx].Field.Isn);
                dataSourceDefinition.Segments.Add(newSegment);
            }

            return(dataSourceDefinition);
        }
Beispiel #2
0
        /// <summary>
        /// Create copy of the DBSegment.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            DBSegment segment = (DBSegment)this.MemberwiseClone();

            //Here field of segment can not be cloned as it containes the reference of field from datasourcedefinition.
            //Caller of the clone method for segment should assign segment's field correctly. So assign null value for field.
            //TODO (Snehal) : Instead of maintaining field in the segment, we can maintain only field Isn.
            segment.Field = null;

            return(segment);
        }
Beispiel #3
0
        /// <summary>
        /// Create copy of the DBKey.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            DBKey key = (DBKey)this.MemberwiseClone();

            key.Segments = new List <DBSegment>();

            for (int segmentIdx = 0; segmentIdx < Segments.Count; segmentIdx++)
            {
                DBSegment segment = (DBSegment)Segments[segmentIdx].Clone();
                key.Segments.Add(segment);
            }

            return(key);
        }