Exemplo n.º 1
0
        /// <summary>
        /// Writes NLSMap either as a dict or as a {n:"", d: ""} pair as Options.NLSMapLanguageISO filter dictates
        /// </summary>
        void IJsonWritable.WriteAsJson(TextWriter wri, int nestingLevel, JsonWritingOptions options)
        {
            if (m_Data == null)
            {
                wri.Write("{}");
                return;
            }

            if (options == null ||
                options.Purpose == JsonSerializationPurpose.Marshalling ||
                options.NLSMapLanguageISO.IsZero)
            {
                JsonWriter.WriteMap(wri, nestingLevel, options,
                                    m_Data.Select
                                    (
                                        e => new System.Collections.DictionaryEntry(e.ISO.Value, e)
                                    ).ToArray());

                return;
            }

            var pair = this[options.NLSMapLanguageISO];

            if (!pair.IsAssigned && options.NLSMapLanguageISODefault != options.NLSMapLanguageISO)
            {
                pair = this[options.NLSMapLanguageISODefault];
            }

            if (pair.IsAssigned)
            {
                JsonWriter.WriteMap(wri, nestingLevel, options, new System.Collections.DictionaryEntry("n", pair.Name),
                                    new System.Collections.DictionaryEntry("d", pair.Description));
            }
            else
            {
                JsonWriter.WriteMap(wri, nestingLevel, options, new System.Collections.DictionaryEntry("n", null),
                                    new System.Collections.DictionaryEntry("d", null));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes NLSMap either as a dict or as a {n:"", d: ""} pair as Options.NLSMapLanguageISO filter dictates
        /// </summary>
        void IJsonWritable.WriteAsJson(TextWriter wri, int nestingLevel, JsonWritingOptions options = null)
        {
            if (m_Data == null)
            {
                wri.Write("{}");
                return;
            }

            if (options == null ||
                options.Purpose == JsonSerializationPurpose.Marshalling ||
                options.NLSMapLanguageISO.IsNullOrWhiteSpace())
            {
                JsonWriter.WriteMap(wri, nestingLevel, options,
                                    m_Data.Select
                                    (
                                        e => new System.Collections.DictionaryEntry(IOUtils.UnpackISO3CodeFromInt(e.ISO), e)
                                    ).ToArray());

                return;
            }

            var pair = this[options.NLSMapLanguageISO];

            if (!pair.IsAssigned && !options.NLSMapLanguageISODefault.EqualsOrdIgnoreCase(options.NLSMapLanguageISO))
            {
                pair = this[options.NLSMapLanguageISODefault];
            }

            if (pair.IsAssigned)
            {
                JsonWriter.WriteMap(wri, nestingLevel, options, new System.Collections.DictionaryEntry("n", pair.Name),
                                    new System.Collections.DictionaryEntry("d", pair.Description));
            }
            else
            {
                JsonWriter.WriteMap(wri, nestingLevel, options, new System.Collections.DictionaryEntry("n", null),
                                    new System.Collections.DictionaryEntry("d", null));
            }
        }
Exemplo n.º 3
0
 void IJsonWritable.WriteAsJson(TextWriter wri, int nestingLevel, JsonWritingOptions options)
 {
     JsonWriter.WriteMap(wri, nestingLevel, options, new System.Collections.DictionaryEntry("n", Name),
                         new System.Collections.DictionaryEntry("d", Description));
 }