Exemple #1
0
        /// <summary>
        /// Creates a qualifier from a given input qualifier such that the resulting qualifier respects target qualifier space.
        /// </summary>
        public bool TryCreateQualifierForQualifierSpace(
            PathTable pathTable,
            LoggingContext loggingContext,
            QualifierId qualifierId,
            QualifierSpaceId qualifierSpaceId,
            bool useDefaultsForCoercion,
            out QualifierId resultingQualifierId,
            out UnsupportedQualifierValue error)
        {
            Contract.RequiresNotNull(pathTable);
            Contract.RequiresNotNull(loggingContext);
#if DEBUG
            Contract.Requires(IsValidQualifierId(qualifierId));
            Contract.Requires(qualifierSpaceId.IsValid);
            Contract.Requires(IsValidQualifierSpaceId(qualifierSpaceId), "Id " + qualifierSpaceId.Id + " is not valid.");
#endif

            Qualifier      qualifier      = GetQualifier(qualifierId);
            QualifierSpace qualifierSpace = GetQualifierSpace(qualifierSpaceId);
            Qualifier      resultingQualifier;

            bool success = qualifierSpace.TryCreateQualifierForQualifierSpace(
                StringTable,
                pathTable,
                loggingContext,
                qualifier,
                out resultingQualifier,
                out error,
                useDefaultsForCoercion);
            resultingQualifierId = success ? GetOrAddQualifier(resultingQualifier) : EmptyQualifierId;

            return(success);
        }
Exemple #2
0
        /// <summary>
        /// Creates a qualifier space given mappings from keys to list of eligible values.
        /// </summary>
        public QualifierSpaceId CreateQualifierSpace(params QualifierSpaceEntry[] keyValuesPairs)
        {
            Contract.RequiresNotNull(keyValuesPairs);
#if DEBUG
            Contract.RequiresForAll(keyValuesPairs, e => e.IsValid);
#endif


            QualifierSpace qualifierSpace = QualifierSpace.CreateQualifierSpace(StringTable, keyValuesPairs);
            return(GetOrAddQualifierSpace(qualifierSpace));
        }
Exemple #3
0
        /// <summary>
        /// Creates a qualifier space given mappings from keys to list of eligible values.
        /// </summary>
        public QualifierSpaceId CreateQualifierSpace(params QualifierSpaceEntry[] keyValuesPairs)
        {
            Contract.Requires(keyValuesPairs != null);
#if DEBUG
            Contract.RequiresForAll(keyValuesPairs, e => e.IsValid);
#endif

            Contract.Ensures(IsValidQualifierSpaceId(Contract.Result <QualifierSpaceId>()));

            QualifierSpace qualifierSpace = QualifierSpace.CreateQualifierSpace(StringTable, keyValuesPairs);
            return(GetOrAddQualifierSpace(qualifierSpace));
        }
Exemple #4
0
 /// <summary>
 /// Gets or adds a qualifier space.
 /// </summary>
 private QualifierSpaceId GetOrAddQualifierSpace(QualifierSpace qualifierSpace) => m_qualifierSpaces.GetOrAdd(qualifierSpace);