示例#1
0
        /// <summary>
        /// Get all the strings this resource bundle contains, in a more C#-friendly way than the default C API provides.
        /// Any resources inside this bundle that were *not* strings (say, other bundles) will be skipped by this function.
        /// It will not recurse into "child" bundles, but only provide the strings that are direct children of this bundle.
        /// </summary>
        /// <returns>An IEnumerable providing all the string contents of this bundle.</returns>
        public IEnumerable <string> GetStringContents()
        {
            if (this.IsNullBundle)
            {
                yield break;
            }
            Icu.BeginResourceBundleIteration(m_bundle);
            string result;

            while ((result = Icu.GetNextStringInResourceBundleIteration(m_bundle)) != null)
            {
                yield return(result);
            }
        }
示例#2
0
        /// <summary>
        /// Get all the keyed strings this resource bundle contains, in a more C#-friendly way than the default C API provides.
        /// Any resources inside this bundle that were *not* strings (say, other bundles) will be skipped by this function, and
        /// any string contents that do *not* have keys will also be skipped. (If the bundle is a "table" -- a dictionary in C#
        /// terms -- then this function is appropriate. If the bundle is an array, then you want GetStringContents() instead.)
        /// It will not recurse into "child" bundles, but only provide the strings that are direct children of this bundle.
        /// </summary>
        /// <returns>An IEnumerable providing all the string contents of this bundle, along with the keys associated with those strings in the bundle.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetStringContentsWithKeys()
        {
            if (this.IsNullBundle)
            {
                yield break;
            }
            Icu.BeginResourceBundleIteration(m_bundle);
            string key;
            string strValue;

            while ((strValue = Icu.GetNextStringInResourceBundleIteration(m_bundle, out key)) != null)
            {
                if (key != null)
                {
                    yield return(new KeyValuePair <string, string>(key, strValue));
                }
            }
        }