/// <summary>
        /// Sets the current DSD.
        /// </summary>
        /// <param name="currentDsd">
        /// The current DSD.
        /// </param>
        protected void SetCurrentDsd(ICrossSectionalDataStructureObject currentDsd)
        {
            this._currentDsd = currentDsd;
            foreach (var component in currentDsd.Components)
            {
                this._conceptToComponentId[component.ConceptRef.FullId] = component.Id;
            }

            this._availableDimensions.AddRange(currentDsd.GetDimensions(SdmxStructureEnumType.Dimension).Select(dimension => dimension.Id));
            this._availableMeasureDimensions.AddRange(currentDsd.GetDimensions(SdmxStructureEnumType.MeasureDimension).Select(dimension => dimension.Id));
            this._availableCrossSectionalMeasures.AddRange(currentDsd.CrossSectionalMeasures.Select(measure => measure.Id));
            this._primaryMeasure = currentDsd.PrimaryMeasure.Id;
            if (currentDsd.TimeDimension != null)
            {
                this._timeDimensionId = currentDsd.TimeDimension.Id;
            }

            // If the current dataset header does not reference a DSD then amend it
            var datasetHeader = this._datasetHeader;
            if (datasetHeader != null && datasetHeader.DataStructureReference == null)
            {
                IDatasetStructureReference datasetStructureReference = new DatasetStructureReferenceCore(currentDsd.AsReference);
                this._datasetHeader = this._datasetHeader.ModifyDataStructureReference(datasetStructureReference);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CrossSectionalDataStructureMutableCore"/> class.
        /// </summary>
        /// <param name="objTarget">
        /// The obj target. 
        /// </param>
        public CrossSectionalDataStructureMutableCore(ICrossSectionalDataStructureObject objTarget)
            : base(objTarget)
        {
            this._crossSectionalMeasures = new List<ICrossSectionalMeasureMutableObject>();
            this._crossSectionalAttachDataSet = new List<string>();
            this._crossSectionalAttachGroup = new List<string>();
            this._crossSectionalAttachSection = new List<string>();
            this._crossSectionalAttachObservation = new List<string>();
            this._attributeToMeasureMap = new DictionaryOfLists<string, string>(StringComparer.Ordinal);
            PopulateList(this._crossSectionalAttachDataSet, objTarget.GetCrossSectionalAttachDataSet(false));
            PopulateList(this._crossSectionalAttachGroup, objTarget.GetCrossSectionalAttachGroup(false));
            PopulateList(this._crossSectionalAttachObservation, objTarget.GetCrossSectionalAttachObservation());
            PopulateList(this._crossSectionalAttachSection, objTarget.GetCrossSectionalAttachSection(false));

            foreach (IAttributeObject attribute in objTarget.Attributes)
            {
                IList<string> measureIds = new List<string>();

                foreach (ICrossSectionalMeasure xsMeasure in objTarget.GetAttachmentMeasures(attribute))
                {
                    measureIds.Add(xsMeasure.Id);
                }

                this._attributeToMeasureMap.Add(attribute.Id, measureIds);
            }

            foreach (ICrossSectionalMeasure measure in objTarget.CrossSectionalMeasures)
            {
                this._crossSectionalMeasures.Add(new CrossSectionalMeasureMutableCore(measure));
            }

            foreach (var dimension in objTarget.GetDimensions(SdmxStructureEnumType.MeasureDimension))
            {
                var codelistForMeasureDimension = objTarget.GetCodelistForMeasureDimension(dimension.Id);
                if (codelistForMeasureDimension != null)
                {
                    this._measureCodelistMapping[dimension.Id] = codelistForMeasureDimension.CreateMutableInstance();
                }
                
            }
        }