Example #1
0
File: NLSMap.cs Project: OniVe/nfx
      /// <summary>
      /// Takes entries from this instance and overides 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 NFXException("Exceeded NLSMap.MAX_ISO_COUNT");
        return new NLSMap( lst.ToArray() );
      }
Example #2
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);
     }
 }