/// <summary>
        /// Initializes a new instance of the <see cref="StructureMapMutableCore"/> class.
        /// </summary>
        /// <param name="objTarget">
        /// The obj target. 
        /// </param>
        public StructureMapMutableCore(IStructureMapObject objTarget)
            : base(objTarget)
        {
            this._extension = objTarget.Extension;

            // create mutable list of component maps
            if (objTarget.Components != null)
            {
                foreach (IComponentMapObject componentMapObject in objTarget.Components)
                {
                    this.AddComponent(new ComponentMapMutableCore(componentMapObject));
                }
            }
        }
        // private ICrossReference getCrossReferenceFromRef(ICrossReference dsdRef, RefBaseType ref) {
        // SdmxStructureType structureType = SdmxStructureType.parseClass(dsdRef.get().toString());
        // string agencyId = dsdRef.getMaintainableReference().getAgencyId();
        // string id = dsdRef.getMaintainableReference().getMaintainableId();
        // string version = dsdRef.getMaintainableReference().getVersion();
        // string componentId = ref.getId();
        // return  new CrossReferenceCore(this, agencyId, id, version, structureType, componentId);
        // }

        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentMapCore"/> class.
        /// </summary>
        /// <param name="compMap">
        /// The comp map. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// ///
        /// <exception cref="SdmxNotImplementedException">
        /// Throws Unsupported Exception.
        /// </exception>
        protected internal ComponentMapCore(
            Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.ComponentMapType compMap, IStructureMapObject parent)
            : base(null, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryMap), parent)
        {
            throw new SdmxNotImplementedException("ComponentMapCore at version 2.0");

            // super(null, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryMap), parent);
            // this.mapConceptRef = getCrossReferenceFromV2Ref(parent.getSourceRef(), compMap.getMapConceptRef());
            // this.mapTargetConceptRef = getCrossReferenceFromV2Ref(parent.getTargetRef(), compMap.getMapTargetConceptRef());
            // if (compMap.getRepresentationMapRef() != null) {
            // this.repMapRef =  new RepresentationMapRefCore(compMap.getRepresentationMapRef(), this);
            // }
            // if(compMap.getToTextFormat() != null) {
            // this.repMapRef = new RepresentationMapRefCore(compMap.getToTextFormat(), compMap.getToValueType(), this);
            // }
            // try {
            // validate();
            // } catch(ValidationException e) {
            // throw new SdmxSemmanticException(e, ExceptionCode.FAIL_VALIDATION, this);
            // }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentMapCore"/> class.
        /// </summary>
        /// <param name="compMap">
        /// The comp map. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        protected internal ComponentMapCore(ComponentMapType compMap, IStructureMapObject parent)
            : base(null, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryMap), parent)
        {
            this.mapConceptRef = compMap.Source.GetTypedRef<LocalComponentListComponentRefType>().id;
            this.mapTargetConceptRef = compMap.Target.GetTypedRef<LocalComponentListComponentRefType>().id;
            if (compMap.RepresentationMapping != null)
            {
                this.repMapRef = new RepresentationMapRefCore(compMap.RepresentationMapping, this);
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        /// <summary>
        /// The process structure map.
        /// </summary>
        /// <param name="structureSetType">
        /// The structure set type.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        private void ProcessStructureMap(StructureSetType structureSetType, IStructureMapObject buildFrom)
        {
            var structureMapType = new StructureMapType();
            structureSetType.StructureMap = structureMapType;

            structureMapType.isExtension = buildFrom.Extension;

            string str0 = buildFrom.Id;
            if (!string.IsNullOrWhiteSpace(str0))
            {
                structureMapType.id = buildFrom.Id;
            }

            IList<ITextTypeWrapper> names = buildFrom.Names;
            if (ObjectUtil.ValidCollection(names))
            {
                structureMapType.Name = this.GetTextType(names);
            }

            IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions;
            if (ObjectUtil.ValidCollection(descriptions))
            {
                structureMapType.Description = this.GetTextType(descriptions);
            }

            if (buildFrom.SourceRef != null)
            {
                if (buildFrom.SourceRef.TargetReference.EnumType == SdmxStructureEnumType.Dsd)
                {
                    var keyFamilyRef = new KeyFamilyRefType();
                    structureMapType.KeyFamilyRef = keyFamilyRef;
                    SetDataStructureRefAttributes(keyFamilyRef, buildFrom.SourceRef);
                }
                else if (buildFrom.SourceRef.TargetReference.EnumType == SdmxStructureEnumType.Msd)
                {
                    var refType = new MetadataStructureRefType();
                    structureMapType.MetadataStructureRef = refType;
                    SetMetadataStructureRefAttributes(refType, buildFrom.SourceRef);
                }
            }

            if (buildFrom.TargetRef != null)
            {
                if (buildFrom.TargetRef.TargetReference.EnumType == SdmxStructureEnumType.Dsd)
                {
                    var keyFamilyRef = new KeyFamilyRefType();
                    structureMapType.TargetKeyFamilyRef = keyFamilyRef;
                    SetDataStructureRefAttributes(keyFamilyRef, buildFrom.TargetRef);
                }
                else if (buildFrom.TargetRef.TargetReference.EnumType == SdmxStructureEnumType.Msd)
                {
                    var refType1 = new MetadataStructureRefType();
                    structureMapType.TargetMetadataStructureRef = refType1;
                    SetMetadataStructureRefAttributes(refType1, buildFrom.TargetRef);
                }
            }

            IList<IComponentMapObject> componentMapObjects = buildFrom.Components;
            if (ObjectUtil.ValidCollection(componentMapObjects))
            {
                /* foreach */
                foreach (IComponentMapObject componentMapBean in componentMapObjects)
                {
                    var componentMapType = new ComponentMapType();
                    structureMapType.ComponentMap.Add(componentMapType);
                    this.ProcessComponent(componentMapType, componentMapBean);
                }
            }

            if (this.HasAnnotations(buildFrom))
            {
                structureMapType.Annotations = this.GetAnnotationsType(buildFrom);
            }
        }