public GenericMetadataType()
 {
     this.footerField = new List<FooterMessageType>();
     this.metadataSetField = new List<MetadataSetType>();
     this.headerField = new GenericMetadataHeaderType();
 }
        public SDMXObjectModel.Message.GenericMetadataHeaderType Get_Appropriate_Header(MetadataTypes metadataType)
        {
            SDMXObjectModel.Message.GenericMetadataHeaderType RetVal;
            SenderType Sender;
            PartyType Receiver;

            if (this._header == null)
            {
                Sender = new SenderType(Constants.Header.SenderId, Constants.Header.SenderName, Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(Constants.Header.Sender, Constants.Header.SenderDepartment, Constants.Header.SenderRole, Constants.DefaultLanguage));
                Sender.Contact[0].Items = new string[] { Constants.Header.SenderTelephone, Constants.Header.SenderEmail, Constants.Header.SenderFax };
                Sender.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

                Receiver = new PartyType(Constants.Header.ReceiverId, Constants.Header.ReceiverName, Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(Constants.Header.Receiver, Constants.Header.ReceiverDepartment, Constants.Header.ReceiverRole, Constants.DefaultLanguage));
                Receiver.Contact[0].Items = new string[] { Constants.Header.ReceiverTelephone, Constants.Header.ReceiverEmail, Constants.Header.ReceiverFax };
                Receiver.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

                RetVal = new GenericMetadataHeaderType(Constants.Header.Id, true, DateTime.Now, Sender, Receiver);
            }
            else
            {
                Sender = new SenderType(this._header.Sender.ID, this._header.Sender.Name, Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(this._header.Sender.Contact.Name, this._header.Sender.Contact.Department, this._header.Sender.Contact.Role, Constants.DefaultLanguage));
                Sender.Contact[0].Items = new string[] { this._header.Sender.Contact.Telephone, this._header.Sender.Contact.Email, this._header.Sender.Contact.Fax };
                Sender.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

                Receiver = new PartyType(this._header.Receiver.ID, this._header.Receiver.Name, Constants.DefaultLanguage, new SDMXObjectModel.Message.ContactType(this._header.Receiver.Contact.Name, this._header.Receiver.Contact.Department, this._header.Receiver.Contact.Role, Constants.DefaultLanguage));
                Receiver.Contact[0].Items = new string[] { this._header.Receiver.Contact.Telephone, this._header.Receiver.Contact.Email, this._header.Receiver.Contact.Fax };
                Receiver.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

                RetVal = new GenericMetadataHeaderType(this._header.ID, true, DateTime.Now, Sender, Receiver);
            }

            RetVal.Structure = new List<GenericMetadataStructureType>();
            RetVal.Structure.Add(new GenericMetadataStructureType());

            switch (metadataType)
            {
                case MetadataTypes.Area:
                    RetVal.Structure[0].structureID = Constants.MSD.Area.Id;
                    RetVal.Structure[0].Item = new MetadataStructureReferenceType();
                    ((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items = new List<object>();
                    ((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items.Add(new MetadataStructureRefType(Constants.MSD.Area.Id, this._agencyId, Constants.MSD.Area.Version));
                    break;
                case MetadataTypes.Indicator:
                    RetVal.Structure[0].structureID = Constants.MSD.Indicator.Id;
                    RetVal.Structure[0].Item = new MetadataStructureReferenceType();
                    ((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items = new List<object>();
                    ((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items.Add(new MetadataStructureRefType(Constants.MSD.Indicator.Id, this._agencyId, Constants.MSD.Indicator.Version));
                    break;
                case MetadataTypes.Source:
                    RetVal.Structure[0].structureID = Constants.MSD.Source.Id;
                    RetVal.Structure[0].Item = new MetadataStructureReferenceType();
                    ((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items = new List<object>();
                    ((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items.Add(new MetadataStructureRefType(Constants.MSD.Source.Id, this._agencyId, Constants.MSD.Source.Version));
                    break;
                case MetadataTypes.Layer:
                    RetVal.Structure[0].structureID = Constants.MSD.Area.Id;
                    RetVal.Structure[0].Item = new MetadataStructureReferenceType();
                    ((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items = new List<object>();
                    ((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items.Add(new MetadataStructureRefType(Constants.MSD.Area.Id, this._agencyId, Constants.MSD.Area.Version));
                    break;
                default:
                    break;
            }

            ((MetadataStructureRefType)((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items[0]).local = false;
            ((MetadataStructureRefType)((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items[0]).localSpecified = true;

            ((MetadataStructureRefType)((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items[0]).@class = ObjectTypeCodelistType.MetadataStructure;
            ((MetadataStructureRefType)((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items[0]).classSpecified = true;

            ((MetadataStructureRefType)((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items[0]).package = PackageTypeCodelistType.metadatastructure;
            ((MetadataStructureRefType)((MetadataStructureReferenceType)RetVal.Structure[0].Item).Items[0]).packageSpecified = true;

            return RetVal;
        }