Example #1
0
            protected override object HandleGetObject(string key)
            {
                // Fast path for common cases: Avoid creating UResourceBundles if possible.
                // It would be even better if we could override getString(key)/getStringArray(key),
                // so that we know the expected object type,
                // but those are final in java.util.ResourceBundle.
                ICUResourceBundleReader reader = wholeBundle.reader;
                int index = ((ICUResourceBundleReader.Table)value).FindTableItem(reader, key);

                if (index >= 0)
                {
                    int res = value.GetContainerResource(reader, index);
                    // getString(key)
                    string s = reader.GetString(res);
                    if (s != null)
                    {
                        return(s);
                    }
                    // getStringArray(key)
                    ICUResourceBundleReader.Container array = reader.GetArray(res);
                    if (array != null)
                    {
                        int      length  = array.Length;
                        string[] strings = new string[length];
                        for (int j = 0; ; ++j)
                        {
                            if (j == length)
                            {
                                return(strings);
                            }
                            s = reader.GetString(array.GetContainerResource(reader, j));
                            if (s == null)
                            {
                                // Equivalent to resolveObject(key, requested):
                                // If this is not a string array,
                                // then build and return a UResourceBundle.
                                break;
                            }
                            strings[j] = s;
                        }
                    }
                }
                return(base.HandleGetObject(key));
            }
Example #2
0
            /// <summary>
            /// Returns a String if found, or null if not found or if the key item is not a string.
            /// </summary>
            internal virtual string FindString(string key)
            {
                ICUResourceBundleReader reader = wholeBundle.reader;
                int index = ((ICUResourceBundleReader.Table)value).FindTableItem(reader, key);

                if (index < 0)
                {
                    return(null);
                }
                return(reader.GetString(value.GetContainerResource(reader, index)));
            }
Example #3
0
            protected override string[] HandleGetStringArray()
            {
                ICUResourceBundleReader reader = wholeBundle.reader;
                int length = value.Length;

                string[] strings = new string[length];
                for (int i = 0; i < length; ++i)
                {
                    string s = reader.GetString(value.GetContainerResource(reader, i));
                    if (s == null)
                    {
                        throw new UResourceTypeMismatchException("");
                    }
                    strings[i] = s;
                }
                return(strings);
            }