/// <summary>
        /// Adds new concept scheme ref submission result.
        /// </summary>
        /// <param name="returnType">
        /// The return type.
        /// </param>
        /// <param name="structureReference">
        /// The structure reference.
        /// </param>
        /// <param name="exception">
        /// The exception.
        /// </param>
        private static void AddNewConceptSchemeRefSubmissionResult(
            SubmitStructureResponseType returnType, IStructureReference structureReference, Exception exception)
        {
            SubmissionResultType result = GetNewSubmissionResultType(returnType, exception);
            var submittedStructure = new SubmittedStructureType();
            result.SubmittedStructure = submittedStructure;
            var refType = new ConceptSchemeRefType();
            submittedStructure.ConceptSchemeRef = refType;

            IMaintainableRefObject maintainableReference = structureReference.MaintainableReference;
            refType.AgencyID = maintainableReference.AgencyId;
            refType.ConceptSchemeID = maintainableReference.MaintainableId;
            if (ObjectUtil.ValidString(structureReference.MaintainableUrn))
            {
                refType.URN = structureReference.MaintainableUrn;
            }

            string value = maintainableReference.Version;
            if (!string.IsNullOrWhiteSpace(value))
            {
                refType.Version = maintainableReference.Version;
            }
        }
        /// <summary>
        /// The set concept scheme ref attributes.
        /// </summary>
        /// <param name="refType">
        /// The ref type.
        /// </param>
        /// <param name="xref">
        /// The crossReference.
        /// </param>
        private static void SetConceptSchemeRefAttributes(ConceptSchemeRefType refType, IStructureReference xref)
        {
            IMaintainableRefObject maintainableReference = xref.MaintainableReference;
            string str0 = maintainableReference.AgencyId;
            if (!string.IsNullOrWhiteSpace(str0))
            {
                refType.AgencyID = maintainableReference.AgencyId;
            }

            string str1 = maintainableReference.MaintainableId;
            if (!string.IsNullOrWhiteSpace(str1))
            {
                refType.ConceptSchemeID = maintainableReference.MaintainableId;
            }

            refType.URN = xref.TargetUrn;

            string str3 = maintainableReference.Version;
            if (!string.IsNullOrWhiteSpace(str3))
            {
                refType.Version = maintainableReference.Version;
            }
        }
        /// <summary>
        /// The process concept scheme map.
        /// </summary>
        /// <param name="structureSetType">
        /// The structure set type.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        private void ProcessConceptSchemeMap(StructureSetType structureSetType, IItemSchemeMapObject buildFrom)
        {
            var conceptSchemeMap = new ConceptSchemeMapType();
            structureSetType.ConceptSchemeMap = conceptSchemeMap;

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

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

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

            if (buildFrom.SourceRef != null)
            {
                var refType = new ConceptSchemeRefType();
                conceptSchemeMap.ConceptSchemeRef = refType;
                SetConceptSchemeRefAttributes(refType, buildFrom.SourceRef);
            }

            if (buildFrom.TargetRef != null)
            {
                var refType0 = new ConceptSchemeRefType();
                conceptSchemeMap.TargetConceptSchemeRef = refType0;
                SetConceptSchemeRefAttributes(refType0, buildFrom.TargetRef);
            }

            IList<IItemMap> itemMapBeans = buildFrom.Items;
            if (ObjectUtil.ValidCollection(itemMapBeans))
            {
                /* foreach */
                foreach (IItemMap itemMapBean in itemMapBeans)
                {
                    var conceptMaptype = new ConceptMapType();
                    conceptSchemeMap.ConceptMap.Add(conceptMaptype);
                    string str1 = itemMapBean.SourceId;
                    if (!string.IsNullOrWhiteSpace(str1))
                    {
                        conceptMaptype.ConceptID = itemMapBean.SourceId;
                    }

                    string str2 = itemMapBean.TargetId;
                    if (!string.IsNullOrWhiteSpace(str2))
                    {
                        conceptMaptype.TargetConceptID = itemMapBean.TargetId;
                    }
                }
            }

            if (this.HasAnnotations(buildFrom))
            {
                conceptSchemeMap.Annotations = this.GetAnnotationsType(buildFrom);
            }
        }
        /// <summary>
        /// Process related structures.
        /// </summary>
        /// <param name="structureSetType">
        /// The structure set type.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        private static void ProcessRelatedStructures(StructureSetType structureSetType, IStructureSetObject buildFrom)
        {
            if (buildFrom.RelatedStructures != null)
            {
                var relatedStructuresType = new RelatedStructuresType();
                structureSetType.RelatedStructures = relatedStructuresType;
                IRelatedStructures relatedStructures = buildFrom.RelatedStructures;

                // KEY FAMILY REF
                foreach (ICrossReference xref in relatedStructures.DataStructureRef)
                {
                    var keyFamilyRefType = new KeyFamilyRefType();
                    relatedStructuresType.KeyFamilyRef.Add(keyFamilyRefType);
                    SetDataStructureRefAttributes(keyFamilyRefType, xref);
                }

                // METADATA STRUCTURE REF
                foreach (ICrossReference ref0 in relatedStructures.MetadataStructureRef)
                {
                    var refType = new MetadataStructureRefType();
                    relatedStructuresType.MetadataStructureRef.Add(refType);
                    SetMetadataStructureRefAttributes(refType, ref0);
                }

                // CONCEPT SCHEME REF
                foreach (ICrossReference ref1 in relatedStructures.ConceptSchemeRef)
                {
                    var refType2 = new ConceptSchemeRefType();
                    relatedStructuresType.ConceptSchemeRef.Add(refType2);
                    SetConceptSchemeRefAttributes(refType2, ref1);
                }

                // CATEGORY SCHEME REF
                foreach (ICrossReference ref3 in relatedStructures.CategorySchemeRef)
                {
                    var refType4 = new CategorySchemeRefType();
                    relatedStructuresType.CategorySchemeRef.Add(refType4);
                    SetCategorySchemeRefAttributes(refType4, ref3);
                }

                // ORGANISATION SCHEME REF
                foreach (ICrossReference ref5 in relatedStructures.OrgSchemeRef)
                {
                    var refType6 = new OrganisationSchemeRefType();
                    relatedStructuresType.OrganisationSchemeRef.Add(refType6);
                    SetOrganisationSchemeRefAttributes(refType6, ref5);
                }

                // HCL REF
                foreach (ICrossReference ref7 in relatedStructures.HierCodelistRef)
                {
                    var refType8 = new HierarchicalCodelistRefType();
                    relatedStructuresType.HierarchicalCodelistRef.Add(refType8);
                    SetHclRefAttributes(refType8, ref7);
                }
            }
        }