Ejemplo n.º 1
0
        private string ToString(QualifierSpaceId qualifierSpaceId, QualifierTable qualifierTable, FrontEndContext context)
        {
            Contract.Requires(context != null);
            Contract.Requires(qualifierTable != null);

            QualifierSpace qualifierSpace = qualifierTable.GetQualifierSpace(qualifierSpaceId);

            return(qualifierSpace.ToDisplayString(context.StringTable));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes a QualifierSpaceId using its underlying string representation
        /// </summary>
        public override void Write(QualifierSpaceId qualifierSpaceId)
        {
            Start <QualifierId>();
            Write(qualifierSpaceId.IsValid);

            if (qualifierSpaceId.IsValid)
            {
                var qualifierSpace = m_qualifierTable.GetQualifierSpace(qualifierSpaceId);

                var keys     = qualifierSpace.Keys;
                var values   = qualifierSpace.Values;
                var defaults = qualifierSpace.Defaults;

                // The qualifier space is stored as a <key, value[]>[]

                // Get the string representation based on the string table
                // The values of a given key are returned sorted, which means that, for V1, the default value (the first value in the list) might be off
                // So we retrieve the default as well and make sure it's the first one.
                var stringRepresentation = new Tuple <string, string[]> [keys.Count];
                for (var i = 0; i < keys.Count; i++)
                {
                    stringRepresentation[i] = new Tuple <string, string[]>(
                        keys[i].ToString(m_stringTable),

                        // We put the default first. This is for V1 compatibility.
                        new List <string> {
                        defaults[i].ToString(m_stringTable)
                    }.Concat(
                            values[i].Where(value => value != defaults[i]).Select(value => value.ToString(m_stringTable))).ToArray());
                }

                Write(
                    stringRepresentation,
                    (writer, tuple) =>
                {
                    writer.Write(tuple.Item1);
                    writer.Write(tuple.Item2, (writer2, value) => writer2.Write(value));
                });
            }

            End();
        }