/// <summary>
        /// Requests the partial codelist.
        /// </summary>
        /// <param name="dataflow">The dataflow.</param>
        /// <param name="firstDsd">The first DSD.</param>
        /// <param name="mutableSearchManager">The mutable search manager.</param>
        /// <returns>The criteria used.</returns>
        private static IEnumerable<IKeyValuesMutable> RequestPartialCodelist(IDataflowMutableObject dataflow, IDataStructureMutableObject firstDsd, IMutableStructureSearchManager mutableSearchManager)
        {
            var currentDataflowReference = _fromMutableBuilder.Build(dataflow);

            var previousMembers = new List<IKeyValuesMutable>();
            foreach (var dimension in firstDsd.Dimensions)
            {
                var representation = dimension.GetEnumeratedRepresentation(firstDsd);
                if (representation != null)
                {
                    IStructureReference codelistRef = new StructureReferenceImpl(representation.MaintainableReference, SdmxStructureEnumType.CodeList);

                    var id = dimension.Id;
                    var agencyId = firstDsd.AgencyId;
                    var version = firstDsd.Version;
                    var name = dimension.ConceptRef.ChildReference.Id;
                    var specialRequest = BuildConstrainableStructureReference(id, agencyId, version, name, previousMembers, currentDataflowReference);
                    var queries = new[] { specialRequest, codelistRef };
                    var objects = mutableSearchManager.RetrieveStructures(queries, false, false);
                    var message = string.Format("DataflowRef : {0}, CodelistRef : {1}", specialRequest, codelistRef);
                    Assert.IsNotNull(objects, message);
                    Assert.IsNotEmpty(objects.Codelists, message);
                    Assert.AreEqual(1, objects.Codelists.Count, message);

                    var codeIds = objects.Codelists.First().Items.TakeWhile(o => _random.Next() % 2 == 0).Select(o => o.Id).ToArray();

                    if (codeIds.Length > 0)
                    {
                        var criteria = new KeyValuesMutableImpl { Id = id };
                        criteria.KeyValues.AddAll(codeIds);
                        previousMembers.Add(criteria);
                    }
                }
                else if (dimension.TimeDimension)
                {
                    var id = dimension.Id;
                    var agencyId = firstDsd.AgencyId;
                    var version = firstDsd.Version;
                    var name = dimension.ConceptRef.ChildReference.Id;
                    IStructureReference specialRequest = BuildConstrainableStructureReference(id, agencyId, version, name, previousMembers, currentDataflowReference);
                    IStructureReference timeCodelistReference = new StructureReferenceImpl(
                        CustomCodelistConstants.Agency, 
                        CustomCodelistConstants.TimePeriodCodeList, 
                        CustomCodelistConstants.Version, 
                        SdmxStructureEnumType.CodeList);
                    var queries = new[] { specialRequest, timeCodelistReference };
                    var objects = mutableSearchManager.RetrieveStructures(queries, false, false);
                    var message = string.Format("DataflowRef : {0}, CodelistRef : {1}", specialRequest, timeCodelistReference);
                    Assert.IsNotNull(objects);
                    Assert.IsNotEmpty(objects.Codelists, message);
                    Assert.AreEqual(1, objects.Codelists.Count, message);
                    var timeCodelist = objects.Codelists.First();
                    Assert.GreaterOrEqual(timeCodelist.Items.Count, 1, message);
                    Assert.LessOrEqual(timeCodelist.Items.Count, 2, message);
                    foreach (var item in timeCodelist.Items)
                    {
                        DateTime date;
                        Assert.IsTrue(DateTime.TryParseExact(item.Id, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out date), "Invalid date : '{0}' for {1}", item.Id, specialRequest);
                    }
                    
                    if (timeCodelist.Items.Count > 0)
                    {
                        var criteria = new KeyValuesMutableImpl { Id = id };
                        criteria.KeyValues.AddAll(timeCodelist.Items.Select(o => o.Id));
                        previousMembers.Add(criteria);
                    }
                }
            }

            return previousMembers;
        }
 /// <summary>
 /// Requests the count.
 /// </summary>
 /// <param name="dataflowRef">The dataflow preference.</param>
 /// <param name="structureSearch">The structure search.</param>
 private static void RequestCount(IStructureReference dataflowRef, IMutableStructureSearchManager structureSearch)
 {
     var countRef = new StructureReferenceImpl(CustomCodelistConstants.Agency, CustomCodelistConstants.CountCodeList, CustomCodelistConstants.Version, SdmxStructureEnumType.CodeList);
     var queries = new[] { dataflowRef, countRef };
     var countResponse = structureSearch.RetrieveStructures(queries, false, false);
     Assert.IsNotNull(countResponse);
     Assert.IsNotEmpty(countResponse.Codelists);
     var countCodelist = countResponse.Codelists.First();
     Assert.AreEqual(CustomCodelistConstants.CountCodeList, countCodelist.Id);
     Assert.AreEqual(1, countCodelist.Items.Count);
     int count;
     Assert.IsTrue(int.TryParse(countCodelist.Items.First().Id, NumberStyles.Integer, CultureInfo.InvariantCulture, out count), "Dataflow {0}", dataflowRef);
     Assert.IsTrue(count > 0, "Dataflow {0}", ExtractInfo(dataflowRef));
 }