/// <summary> /// Populates the properties of the given IComponentMutableObject object from the given xml attributes dictionary /// </summary> /// <param name="component"> /// The given IComponentMutableObject object /// </param> /// <param name="attributes"> /// The dictionary contains the attributes of the element /// </param> private static void ParseAttributes(IMetadataAttributeMutableObject component, IDictionary<string, string> attributes) { ParseComponentConceptAttributes(component, attributes); var usageStatus = Helper.TrySetFromAttribute(attributes, AttributeNameTable.usageStatus, string.Empty); component.MaxOccurs = 1; switch (usageStatus) { case "Mandatory": component.MinOccurs = 1; break; default: component.MinOccurs = 0; break; } // code list attributes string codelist = Helper.TrySetFromAttribute(attributes, AttributeNameTable.representationScheme, string.Empty); if (!string.IsNullOrEmpty(codelist)) { component.Representation = new RepresentationMutableCore(); string codelistVersion = Helper.TrySetFromAttribute(attributes, AttributeNameTable.representationSchemeVersion, string.Empty); string codelistAgency = Helper.TrySetFromAttribute(attributes, AttributeNameTable.representationSchemeAgency, string.Empty); component.Representation.Representation = new StructureReferenceImpl(codelistAgency, codelist, codelistVersion, SdmxStructureEnumType.CodeList); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="MetadataAttributeObjectCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="itemMutableObject"> /// The sdmxObject. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public MetadataAttributeObjectCore(IIdentifiableObject parent, IMetadataAttributeMutableObject itemMutableObject) : base(itemMutableObject, parent) { this.metadataAttributes = new List<IMetadataAttributeObject>(); this.presentational = TertiaryBool.GetFromEnum(TertiaryBoolEnumType.Unset); try { if (itemMutableObject.MetadataAttributes != null) { foreach (IMetadataAttributeMutableObject currentMa in itemMutableObject.MetadataAttributes) { this.metadataAttributes.Add(new MetadataAttributeObjectCore(this, currentMa)); } } if (itemMutableObject.MinOccurs != null) { this.minOccurs = itemMutableObject.MinOccurs; } if (itemMutableObject.MaxOccurs != null) { this.maxOccurs = itemMutableObject.MaxOccurs; } this.presentational = itemMutableObject.Presentational; } catch (Exception th) { throw new SdmxSemmanticException("IsError creating structure: " + this, th); } try { this.Validate(); } catch (SdmxSemmanticException e) { throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this); } }
/// <summary> /// Handles the Component element child elements /// </summary> /// <param name="parent"> /// The parent IComponentMutableObject object /// </param> /// <param name="localName"> /// The name of the current XML element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> private ElementActions HandleChildElements(IMetadataAttributeMutableObject parent, object localName) { if (NameTableCache.IsElement(localName, ElementNameTable.TextFormat)) { parent.Representation = new RepresentationMutableCore { TextFormat = HandleTextFormat(this.Attributes) }; //// TextFormatType has only attributes so we do not expect anything else. return ElementActions.Empty; } if (ElementNameTable.MetadataAttribute.Is(localName)) { IMetadataAttributeMutableObject attribute = new MetadataAttributeMutableCore(); ParseAttributes(attribute, this.Attributes); parent.MetadataAttributes.Add(attribute); return this.AddAnnotableAction(attribute, this.HandleChildElements, DoNothing); } return null; }