本文整理汇总了C#中System.Resources.ResourceSet类的典型用法代码示例。如果您正苦于以下问题:C# ResourceSet类的具体用法?C# ResourceSet怎么用?C# ResourceSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceSet类属于System.Resources命名空间,在下文中一共展示了ResourceSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalGetResourceSet
protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
{
ResourceSet resourceSet = (ResourceSet)ResourceSets[culture];
if (resourceSet == null)
{
// Lazy-load default language (without caring about duplicate assignment in race conditions, no harm done);
if (neutralResourcesCulture == null)
{
neutralResourcesCulture = GetNeutralResourcesLanguage(MainAssembly);
}
// If we're asking for the default language, then ask for the invariant (non-specific) resources.
if (neutralResourcesCulture.Equals(culture))
{
culture = CultureInfo.InvariantCulture;
}
string resourceFileName = GetResourceFileName(culture);
Stream store = MainAssembly.GetManifestResourceStream(contextTypeInfo, resourceFileName);
// If we found the appropriate resources in the local assembly...
if (store != null)
{
resourceSet = new ResourceSet(store);
// Save for later.
AddResourceSet(ResourceSets, culture, ref resourceSet);
}
else
{
resourceSet = base.InternalGetResourceSet(culture, createIfNotExists, tryParents);
}
}
return resourceSet;
}
开发者ID:YuriyGuts,项目名称:unicode-virtual-keyboard,代码行数:34,代码来源:SingleAssemblyComponentResourceManager.cs
示例2: Init
public void Init()
{
// Determine if the Preset settings files exist for the routine //
// This has been changed so that the XML files are now embedded resources //
var presetResourceSet =
new ResourceSet(
Assembly.GetExecutingAssembly().GetManifestResourceStream("Paws.Properties.Resources.resources"));
// Determine if the Preset settings files exist for the current character //
var characterSettingsDirectory = Path.Combine(CharacterSettingsDirectory, "Paws");
if (!Directory.Exists(characterSettingsDirectory))
{
Directory.CreateDirectory(characterSettingsDirectory);
Log.Diagnostics("Character Settings Directory Established... generating default presets.");
var resourceCount = 0;
foreach (DictionaryEntry entry in presetResourceSet)
{
using (
var streamWriter =
new StreamWriter(
Path.Combine(characterSettingsDirectory, entry.Key.ToString().Replace("_", " ") + ".xml"),
false))
{
streamWriter.Write(entry.Value);
resourceCount++;
}
}
Log.Diagnostics(string.Format("...Finished generating {0} preset files", resourceCount));
}
}
示例3: InternalGetResourceSet
protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
{
ResourceSet rs = (ResourceSet)this.ResourceSets[culture];
if (rs == null)
{
Stream store = null;
string resourceFileName = null;
//lazy-load default language;
if (this._neutralResourcesCulture == null)
{
this._neutralResourcesCulture = GetNeutralResourcesLanguage(this.MainAssembly);
}
//if we're asking for the default language, then ask for the invaliant (non-specific) resources.
if (_neutralResourcesCulture.Equals(culture))
culture = CultureInfo.InvariantCulture;
resourceFileName = GetResourceFileName(culture);
store = this.MainAssembly.GetManifestResourceStream(this._contextTypeInfo, resourceFileName);
//If we found the appropriate resources in the local assembly
if (store != null)
{
rs = new ResourceSet(store);
//save for later.
AddResourceSet(this.ResourceSets, culture, ref rs);
}
else
{
rs = base.InternalGetResourceSet(culture, createIfNotExists, tryParents);
}
}
return rs;
}
示例4: CreateIconSetBitmaps
public static Dictionary<String, Bitmap> CreateIconSetBitmaps(ResourceSet resSet, Boolean invert)
{
Dictionary<String, Bitmap> icons = new Dictionary<String, Bitmap>();
if (resSet != null)
{
foreach (System.Collections.DictionaryEntry e in resSet)
{
if (e.Key is String && e.Value is Bitmap)
{
Bitmap b = (Bitmap)e.Value;
if (invert)
{
BitmapProcessing.Desaturate(b);
BitmapProcessing.Invert(b);
BitmapProcessing.AdjustBrightness(b, 101);
}
Bitmap b_hidden = new Bitmap(b);
BitmapProcessing.AdjustOpacity(b_hidden, 100);
Bitmap b_filtered = new Bitmap(b);
BitmapProcessing.AdjustOpacity(b_filtered, Outliner.Controls.Tree.TreeNode.FilteredNodeOpacity);
icons.Add((String)e.Key, b);
icons.Add((String)e.Key + "_hidden", b_hidden);
icons.Add((String)e.Key + "_filtered", b_filtered);
}
}
}
return icons;
}
示例5: AddResources
private static void AddResources(Dictionary<String, String> resources,
ResourceManager resourceManager, ResourceSet neutralSet) {
foreach (DictionaryEntry res in neutralSet) {
string key = (string)res.Key;
string value = resourceManager.GetObject(key) as string;
if (value != null) {
resources[key] = value;
}
}
}
示例6: ConvertResourceSetToDictionaryEntries
private static IEnumerable<DictionaryEntry> ConvertResourceSetToDictionaryEntries( ResourceSet resourceSet )
{
var dictionaryEntries = new List<DictionaryEntry>();
foreach ( DictionaryEntry entry in resourceSet )
{
dictionaryEntries.Add( entry );
}
return dictionaryEntries;
}
示例7: BeforeLocalizeType
protected override void BeforeLocalizeType(Type controlType)
{
if (this.FIniSource != null)
{
this.ResourceSet = new IniResourceSet(this.FIniSource, controlType);
}
else if (this.FIniPath != null)
{
this.ResourceSet = new IniResourceSet(this.FIniPath, controlType);
}
}
示例8: IconPackImageProvider
public IconPackImageProvider(string iconPackPath)
{
this.IconPack = new ResourceSet(iconPackPath);
foreach (DefaultIcon icon in Enum.GetValues(typeof(DefaultIcon)))
{
this.DefaultIconMap.Add(icon, string.Intern("DefaultIcon." + icon.ToString()));
}
foreach (VolumeType type in Enum.GetValues(typeof(VolumeType)))
{
this.VolumeTypeMap.Add(type, string.Intern("VolumeType." + type.ToString()));
}
}
示例9: GetTextResourceContent
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;
}
示例10: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
strs = new ArrayList();
rs = Properties.Resources.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
foreach (DictionaryEntry entry in rs)
{
if (entry.Key.ToString().Contains("_"))
continue;
strs.Add(entry.Key);
}
strs.Sort();
foreach(string s in strs)
comboBox1.Items.Add(s);
}
示例11: InternalGetResourceSet
/// <summary>
/// This method will return a resource set based on a Culture set by application.
/// </summary>
/// <param name="culture"></param>
/// <param name="createIfNotExists"></param>
/// <param name="tryParents"></param>
/// <returns>ResourceSet</returns>
protected override ResourceSet InternalGetResourceSet(System.Globalization.CultureInfo culture, bool createIfNotExists, bool tryParents)
{
ResourceSet rs = null;
lock (this.cultureResourceSetDictionary)
{
if (false == this.cultureResourceSetDictionary.TryGetValue(culture.Name, out rs))
{
rs = new ResourceSet(new DBResourceReader(culture, this.dataProvider));
this.cultureResourceSetDictionary[culture.Name] = rs;
}
}
return rs;
}
示例12: LoadLanguage
static ResourceManager LoadLanguage(CultureInfo culture, ref ResourceSet rs)
{
Current = culture;
if (rs != null) { rs.Dispose(); rs = null; }
try
{
ResourceManager rManager = new ResourceManager("XPloit.Res.Res", typeof(Lang).Assembly) { IgnoreCase = true };
rs = rManager.GetResourceSet(culture, true, true);
return rManager;
}
catch { }
return null;
}
示例13: AddLocalizedResource
private static void AddLocalizedResource(ResourceManager resourceMgr, string cultureName)
{
using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("ExBuddy.Localization.Localization." + cultureName + ".resources"))
{
if (s == null)
{
Logging.WriteDiagnostic("Couldn't find {0}", "ExBuddy.Localization.Localization." + cultureName + ".resources");
return;
}
FieldInfo resourceSetsField = typeof(ResourceManager).GetField("_resourceSets", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField);
Dictionary<string, ResourceSet> resourceSets = (Dictionary<string, ResourceSet>)resourceSetsField.GetValue(resourceMgr);
ResourceSet resources = new ResourceSet(s);
resourceSets.Add(cultureName, resources);
}
}
示例14: InternalGetResourceSet
protected override ResourceSet InternalGetResourceSet(CultureInfo culture,
bool createIfNotExists, bool tryParents)
{
ResourceSet rs = (ResourceSet)ResourceSets[culture];
if (rs == null)
{
string resourceFileName = null;
//lazy-load default language (without caring about duplicate assignment in race conditions, no harm done);
if (_neutralResourcesCulture == null)
{
_neutralResourcesCulture =
GetNeutralResourcesLanguage(MainAssembly);
}
// if we're asking for the default language, then ask for the
// invariant (non-specific) resources.
if (_neutralResourcesCulture.Equals(culture))
culture = CultureInfo.InvariantCulture;
resourceFileName = GetResourceFileName(culture);
// Only bother to try the lookup based on the resource property if we haven't tried this language before
if (!_prevCultures.Contains(culture.ToString()) && culture != CultureInfo.InvariantCulture)
{
_prevCultures.Add(culture.ToString());
// The T4 template resource generator will link the culture specific resources in to the invariant culture resource
// We'll try and load the culture specific resource here
var content = GetString("Resources." + culture);
if (content != null)
{
using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(content)))
using (var reader = new ResXResourceReader(stream))
{
rs = new ResourceSet(reader);
}
}
}
if (rs == null)
rs = base.InternalGetResourceSet(culture, createIfNotExists, tryParents);
}
return rs;
}
示例15: GetResourceManager
private static ResourceManager GetResourceManager(ref ResourceManager field, ResourceSet name)
{
if (null == field)
{
lock (sync)
{
if (null == field)
{
var t = typeof(ActionText);
var qualifiedName = t.Namespace + "." + Enum.GetName(typeof(ResourceSet), name);
field = new ResourceManager(qualifiedName, t.Assembly);
}
}
}
return field;
}