/// <summary>
        /// Resolves a reference from <paramref name="crossReference"/>
        /// </summary>
        /// <param name="crossReference">
        /// The cross reference instance
        /// </param>
        /// <param name="structRetrievalManager">
        /// The structure Retrieval Manager.
        /// </param>
        /// <returns>
        /// a reference from <paramref name="crossReference"/>
        /// </returns>
        public virtual IIdentifiableObject ResolveCrossReference(
            ICrossReference crossReference, ISdmxRetrievalManager structRetrievalManager)
        {
            if (crossReference.TargetReference == SdmxStructureEnumType.Agency)
            {
                return this.ResoveAgency(crossReference.ChildReference.Id);
            }

            var maintainableParent =
                crossReference.ReferencedFrom.GetParent<IMaintainableObject>(typeof(IMaintainableObject), true);
            IStructureReference maintainableReferenceObject;

            if (crossReference.HasChildReference())
            {
                maintainableReferenceObject = new StructureReferenceImpl(
                    crossReference.MaintainableReference, crossReference.MaintainableStructureEnumType);
            }
            else
            {
                maintainableReferenceObject = crossReference;
            }

            IMaintainableObject resolvedMaintainable = this.ResolveMaintainableFromLocalMaps(
                maintainableReferenceObject, maintainableParent);
            if (resolvedMaintainable == null && structRetrievalManager != null)
            {
                // TODO avoid try catch
                try
                {
                    resolvedMaintainable = structRetrievalManager.GetMaintainable(maintainableReferenceObject);
                }
                catch (Exception)
                {
                    throw new ReferenceException(crossReference);
                }
            }

            if (resolvedMaintainable == null)
            {
                throw new ReferenceException(crossReference);
            }

            // Add the maintainable to the local map, so we don't have to go back to the DAO if there is another reference to the same maintainable
            this._maintianables.Add(resolvedMaintainable);
            if (crossReference.HasChildReference())
            {
                string targetUrn = crossReference.TargetUrn;

                /* foreach */
                foreach (IIdentifiableObject currentComposite in resolvedMaintainable.IdentifiableComposites)
                {
                    if (currentComposite.Urn.Equals(targetUrn))
                    {
                        return currentComposite;
                    }
                }
            }
            else
            {
                return resolvedMaintainable;
            }

            throw new ReferenceException(crossReference);
        }