示例#1
0
 /// <summary>
 /// Tries to get the specified part(s) from the JSON content that represents map defaulting to another lang if requested lang is not found.
 /// Returns null if nothing is found
 /// </summary>
 public static bool TryGet(string json, out string result, GetParts tp, string langIso = null, string dfltLangIso = null, string concat = null)
 {
     try
     {
         var nls = new NLSMap(json);
         result = nls.Get(tp, langIso, dfltLangIso, concat);
         return(true);
     }
     catch
     {
         result = null;
         return(false);
     }
 }
示例#2
0
        public bool Equals(NLSMap other)
        {
            if (this.m_Data == null)
            {
                if (other.m_Data == null)
                {
                    return(true);
                }
                return(false);
            }
            if (other.m_Data == null)
            {
                return(false);
            }

            if (m_Data.Length != other.m_Data.Length)
            {
                return(false);
            }

            return(m_Data.SequenceEqual(other.m_Data));
        }
示例#3
0
        /// <summary>
        /// Takes entries from this instance and overrides them by ISO keys from another instance returning the new instance
        /// </summary>
        public NLSMap OverrideBy(NLSMap other)
        {
            if (m_Data == null)
            {
                return(other);
            }
            if (other.m_Data == null)
            {
                return(this);
            }

            var lst = new List <NDPair>(m_Data);

            for (var j = 0; j < other.m_Data.Length; j++)
            {
                var found = false;
                for (var i = 0; i < lst.Count; i++)
                {
                    if (lst[i].ISO == other.m_Data[j].ISO)
                    {
                        lst[i] = other.m_Data[j];
                        found  = true;
                        break;
                    }
                }
                if (!found)
                {
                    lst.Add(other.m_Data[j]);
                }
            }
            if (lst.Count > MAX_ISO_COUNT)
            {
                throw new AzosException("Exceeded NLSMap.MAX_ISO_COUNT");
            }

            return(new NLSMap(lst.ToArray()));
        }