Esempio n. 1
0
        private ICollection<KeyValuePair<string, object>> GetTextResourceContent(ResourceSet set, string lang)
        {
            var resourceDictionary = set.Cast<DictionaryEntry>()
                                        .ToDictionary(r => r.Key.ToString(),
                                                      r => r.Value.ToString());
            var content = (ICollection<KeyValuePair<string, object>>)new ExpandoObject();

            foreach (var item in resourceDictionary)
            {
                content.Add(new KeyValuePair<string, object>(item.Key, item.Value));
            }

            return content;
        }
Esempio n. 2
0
 /// <summary>
 /// Gets the items from resource.
 /// </summary>
 /// <param name="prefix">The prefix.</param>
 /// <param name="resourceSet">The resource set.</param>
 /// <returns></returns>
 private static IEnumerable<KeyValuePair<string, string>> GetItemsFromResource(string prefix,
     ResourceSet resourceSet)
 {
     return (from entry in resourceSet.Cast<DictionaryEntry>()
             where entry.Key.ToString().StartsWith(prefix)
             select new KeyValuePair<string, string>(entry.Key.ToString(), entry.Value.ToString())).ToList();
 }
Esempio n. 3
0
 protected override void LoadChildren()
 {
     EmbeddedResource er = r as EmbeddedResource;
     if (er != null) {
         try {
             Stream s = er.GetResourceStream();
             if (er.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) {
                 ResourceSet set = new ResourceSet(s);
                 foreach (DictionaryEntry entry in set.Cast<DictionaryEntry>().OrderBy(e => e.Key.ToString())) {
                     if (entry.Value is Stream)
                         Children.Add(new ResourceEntryNode(entry.Key.ToString(), (Stream)entry.Value));
                 }
             }
         } catch (ArgumentException) {
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Gets all items from resource.
 /// </summary>
 /// <param name="resourceSet">The resource set.</param>
 /// <returns></returns>
 private static IEnumerable<KeyValuePair<string, string>> GetAllItemsFromResource(ResourceSet resourceSet)
 {
     return (from entry in resourceSet.Cast<DictionaryEntry>()
             select new KeyValuePair<string, string>(entry.Key.ToString(), entry.Value.ToString())).ToList();
 }