Exemplo n.º 1
0
        /// <summary>
        /// Creates a qualifier space given mappings from keys to list of eligible values.
        /// </summary>
        public QualifierSpaceId CreateQualifierSpace(params Tuple <string, string[]>[] keyValuesPairs)
        {
            Contract.RequiresNotNull(keyValuesPairs);
            Contract.Requires(
                Contract.ForAll(
                    keyValuesPairs,
                    pair => pair.Item1 != null && pair.Item2 != null && pair.Item2.Length > 0 && Contract.ForAll(pair.Item2, value => value != null)));

            var keyValuesPairIds = new QualifierSpaceEntry[keyValuesPairs.Length];

            for (int i = 0; i < keyValuesPairs.Length; ++i)
            {
                var kvp       = keyValuesPairs[i];
                var valuesIds = new StringId[kvp.Item2.Length];

                for (int j = 0; j < kvp.Item2.Length; ++j)
                {
                    valuesIds[j] = StringId.Create(StringTable, kvp.Item2[j]);
                }

                keyValuesPairIds[i] = QualifierSpaceEntry.Create(StringId.Create(StringTable, kvp.Item1), valuesIds);
            }

            return(CreateQualifierSpace(keyValuesPairIds));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a qualifier space given mappings from keys to list of eligible values.
        /// </summary>
        public QualifierSpaceId CreateQualifierSpace(IReadOnlyDictionary <string, IReadOnlyList <string> > keyValuesMap)
        {
            Contract.RequiresNotNull(keyValuesMap);
            Contract.Requires(
                Contract.ForAll(
                    keyValuesMap,
                    kvp => kvp.Key != null && kvp.Value != null && kvp.Value.Count > 0 && Contract.ForAll(kvp.Value, value => value != null)));

            var keyValuesPairIds = new QualifierSpaceEntry[keyValuesMap.Count];

            int i = 0;

            foreach (var kvp in keyValuesMap)
            {
                var valuesIds = new StringId[kvp.Value.Count];

                for (int j = 0; j < kvp.Value.Count; ++j)
                {
                    valuesIds[j] = StringId.Create(StringTable, kvp.Value[j]);
                }

                keyValuesPairIds[i] = QualifierSpaceEntry.Create(StringId.Create(StringTable, kvp.Key), valuesIds);
                ++i;
            }

            return(CreateQualifierSpace(keyValuesPairIds));
        }
        /// <summary>
        /// Creates a qualifier space given mappings from keys to list of eligible values.
        /// </summary>
        public QualifierSpaceId CreateQualifierSpace(params Tuple <string, string[]>[] keyValuesPairs)
        {
            var keyValuesPairIds = new QualifierSpaceEntry[keyValuesPairs.Length];

            for (int i = 0; i < keyValuesPairs.Length; ++i)
            {
                var kvp       = keyValuesPairs[i];
                var valuesIds = new StringId[kvp.Item2.Length];

                for (int j = 0; j < kvp.Item2.Length; ++j)
                {
                    valuesIds[j] = StringId.Create(StringTable, kvp.Item2[j]);
                }

                keyValuesPairIds[i] = QualifierSpaceEntry.Create(StringId.Create(StringTable, kvp.Item1), valuesIds);
            }

            return(CreateQualifierSpace(keyValuesPairIds));
        }