Exemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataTargetCore"/> class.
        /// </summary>
        /// <param name="metadataTarget">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        protected internal MetadataTargetCore(MetadataTargetType metadataTarget, IMetadataStructureDefinitionObject parent)
            : base(metadataTarget, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataTarget), parent)
        {
            if (ObjectUtil.ValidCollection(metadataTarget.KeyDescriptorValuesTarget))
            {
                if (metadataTarget.KeyDescriptorValuesTarget.Count > 1)
                {
                    throw new SdmxSemmanticException(
                        "Metadata Target can not have more then one KeyDescriptorValuesTarget");
                }

                this.keyDescriptorValuesTarget =
                    new KeyDescriptorValuesTargetCore(metadataTarget.KeyDescriptorValuesTarget[0].Content, this);
            }

            if (ObjectUtil.ValidCollection(metadataTarget.DataSetTarget))
            {
                if (metadataTarget.DataSetTarget.Count > 1)
                {
                    throw new SdmxSemmanticException("Metadata Target can not have more then one DataSetTarget");
                }

                this.dataSetTarget = new DataSetTargetCore(metadataTarget.DataSetTarget[0].Content, this);
            }

            if (ObjectUtil.ValidCollection(metadataTarget.ReportPeriodTarget))
            {
                if (metadataTarget.ReportPeriodTarget.Count > 1)
                {
                    throw new SdmxSemmanticException("Metadata Target can not have more then one ReportPeriodTarget");
                }

                this.reportPeriodTarget = new ReportPeriodTargetCore(metadataTarget.ReportPeriodTarget[0].Content, this);
            }

            if (ObjectUtil.ValidCollection(metadataTarget.ConstraintContentTarget))
            {
                if (metadataTarget.DataSetTarget.Count > 1)
                {
                    throw new SdmxSemmanticException("Metadata Target can not have more then one ConstraintContentTarget");
                }

                this.constraintContentTarget = new ConstraintContentTargetCore(
                    metadataTarget.ConstraintContentTarget[0].Content, this);
            }

            if (metadataTarget.IdentifiableObjectTarget != null)
            {
                foreach (IdentifiableObjectTarget currentTarget in metadataTarget.IdentifiableObjectTarget)
                {
                    this._identifiableTarget.Add(new IdentifiableTargetCore(currentTarget.Content, this));
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
Exemplo n.º 2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataTargetCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.Throws Validate exception.
        /// </exception>
        public MetadataTargetCore(IIdentifiableObject parent, IMetadataTargetMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            if (itemMutableObject.ConstraintContentTarget != null)
            {
                this.constraintContentTarget = new ConstraintContentTargetCore(this, itemMutableObject.ConstraintContentTarget);
            }

            if (itemMutableObject.KeyDescriptorValuesTarget != null)
            {
                this.keyDescriptorValuesTarget = new KeyDescriptorValuesTargetCore(this, itemMutableObject.KeyDescriptorValuesTarget);
            }

            if (itemMutableObject.DataSetTarget != null)
            {
                this.dataSetTarget = new DataSetTargetCore(itemMutableObject.DataSetTarget, this);
            }

            if (itemMutableObject.ReportPeriodTarget != null)
            {
                this.reportPeriodTarget = new ReportPeriodTargetCore(this, itemMutableObject.ReportPeriodTarget);
            }

            if (itemMutableObject.IdentifiableTarget != null)
            {
                foreach (IIdentifiableTargetMutableObject identifiableTargetMutableObject in itemMutableObject.IdentifiableTarget)
                {
                    this._identifiableTarget.Add(new IdentifiableTargetCore(identifiableTargetMutableObject, this));
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataSetTargetMutableCore"/> class.
 /// </summary>
 /// <param name="objTarget">
 /// The obj target. 
 /// </param>
 public DataSetTargetMutableCore(IDataSetTarget objTarget)
     : base(objTarget)
 {
     this.textType = objTarget.TextType;
 }