コード例 #1
0
        /// <summary>
        /// Get resource from <see cref="dictionary"/> by converting <paramref name="key"/> to <see cref="string"/> with <see cref="lineFormat"/>.
        /// </summary>
        /// <param name="key"></param>
        /// <returns>resource or null</returns>
        public LineResourceBytes GetResourceBytes(ILine key)
        {
            byte[] result = null;
            string id     = lineFormat.Print(key);

            // Search dictionary
            if (dictionary.TryGetValue(id, out result))
            {
                return(new LineResourceBytes(key, result, LineStatus.ResolveOkFromAsset));
            }
            else
            {
                return(new LineResourceBytes(key, LineStatus.ResolveFailedNoValue));
            }
        }
コード例 #2
0
 /// <summary>
 /// Build name for key.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="policy">(optional)</param>
 /// <returns>full name string or null</returns>
 public static string Print(this ILine key, ILineFormat policy)
 {
     if (policy == null)
     {
         policy = LineParameterPrinter.Default;
     }
     return(policy.Print(key));
 }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public ILine GetLine(ILine key)
        {
            string      id      = namePolicy.Print(key);
            CultureInfo culture = null;

            key.TryGetCultureInfo(out culture);
            try
            {
                string value = culture == null?ResourceManager.GetString(id) : ResourceManager.GetString(id, culture);

                if (value == null)
                {
                    return(null);
                }
                IString str = ValueParser.Parse(value);
                return(key.String(str));
            }
            catch (Exception e)
            {
                throw new LocalizationException(id, e);
                //return null;
            }
        }