本文整理汇总了C#中System.Resources.ResourceManager.GetResourceSet方法的典型用法代码示例。如果您正苦于以下问题:C# System.Resources.ResourceManager.GetResourceSet方法的具体用法?C# System.Resources.ResourceManager.GetResourceSet怎么用?C# System.Resources.ResourceManager.GetResourceSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Resources.ResourceManager
的用法示例。
在下文中一共展示了System.Resources.ResourceManager.GetResourceSet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPageShown
public override void OnPageShown()
{
if (EnvUtils.RunningOnWindows())
{
System.Resources.ResourceManager rm =
new System.Resources.ResourceManager("GitUI.Properties.Resources",
System.Reflection.Assembly.GetExecutingAssembly());
// dummy request; for some strange reason the ResourceSets are not loaded untill after the first object request... bug?
rm.GetObject("dummy");
System.Resources.ResourceSet resourceSet = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentUICulture, true, true);
contextMenuStrip_SplitButton.Items.Clear();
foreach (System.Collections.DictionaryEntry icon in resourceSet)
{
//add entry to toolstrip
if (icon.Value.GetType() == typeof(Icon))
{
//contextMenuStrip_SplitButton.Items.Add(icon.Key.ToString(), (Image)((Icon)icon.Value).ToBitmap(), SplitButtonMenuItem_Click);
}
else if (icon.Value.GetType() == typeof(Bitmap))
{
contextMenuStrip_SplitButton.Items.Add(icon.Key.ToString(), (Image)icon.Value, SplitButtonMenuItem_Click);
}
//var aa = icon.Value.GetType();
}
resourceSet.Close();
rm.ReleaseAllResources();
}
}
示例2: GetResource
public static string GetResource(Type t, string name, string lang)
{
if (string.IsNullOrEmpty(name)) return string.Empty;
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(t);
System.Resources.ResourceSet rs = rm.GetResourceSet(new System.Globalization.CultureInfo(lang), true, true);
return rs.GetString(name);
}
示例3: Exists
public static bool Exists(string path)
{
if (string.IsNullOrEmpty(path) || path.Length <= _resourceFilePrefix.Length)
return false;
path = path.Substring(_resourceFilePrefix.Length).ToLower();
if(_resourcePath==null)
{
_resourcePath = new Dictionary<string, string>();
var culture = System.Threading.Thread.CurrentThread.CurrentCulture;
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
var resourceName = assembly.GetName().Name + ".g";
var resourceManager = new System.Resources.ResourceManager(resourceName, assembly);
try
{
var resourceSet = resourceManager.GetResourceSet(culture, true, true);
foreach (System.Collections.DictionaryEntry resource in resourceSet)
{
_resourcePath.Add(resource.Key.ToString(), "");
}
}
finally
{
resourceManager.ReleaseAllResources();
}
}
return _resourcePath.ContainsKey(path);
}
示例4: GetImage
private string GetImage()
{
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
System.Globalization.CultureInfo culture = Thread.CurrentThread.CurrentCulture;
string resourceName = asm.GetName().Name + ".g";
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(resourceName, asm);
System.Resources.ResourceSet resourceSet = rm.GetResourceSet(culture, true, true);
List<string> resources = new List<string>();
foreach (DictionaryEntry resource in resourceSet)
{
if(((string)resource.Key).StartsWith("images/splash%20screens/"))
resources.Add((string)resource.Key);
}
rm.ReleaseAllResources();
Random r = new Random();
int i = r.Next(0, resources.Count());
return resources[i];
}
示例5: ConvertDate
//.........这里部分代码省略.........
dd = "0" + dd;
}
else
{
dd = "01";
}
}
else if (dd == "00")
{
dd = "01";
}
MM = dateInfo[1].Trim();
if (MM.Length != 2)
{
if (MM.Length > 2)
{
MM = MM.Substring(0, 2);
}
else if (MM.Length == 1)
{
MM = "0" + MM;
}
else
{
MM = "01";
}
}
else if (MM == "00")
{
MM = "01";
}
yyyy = dateInfo[2].Trim();
if (yyyy.Length == 2)
{
yyyy += "20";
}
else if (yyyy.Length != 4)
{
if (yyyy.Length > 4)
{
yyyy = yyyy.Substring(0, 4);
}
else
{
yyyy = DateTime.Now.ToString("yyyy");
}
}
else if (yyyy == "0000")
{
yyyy = DateTime.Now.ToString("yyyy");
}
}
else
{
return DateTime.MinValue;
}
xDateString = string.Format("{0}/{1}/{2}", dd, MM, yyyy);
break;
case DateFormat.ddMMyyyyn:
break;
case DateFormat.ddMMyyyysp:
break;
case DateFormat.ddMMyyyyd:
break;
case DateFormat.ddMMMyyyys:
break;
case DateFormat.ddMMMyyyyn:
break;
case DateFormat.ddMMMyyyysp:
break;
case DateFormat.ddMMMyyyyd:
break;
case DateFormat.MMMddyyyyspcm:
break;
case DateFormat.ddMMMyyyyspwt:
break;
case DateFormat.ddMMMyyyyHHmm:
break;
case DateFormat.yyyyMMMdd:
break;
case DateFormat.yyyyMMdd:
break;
case DateFormat.yyMMddHHmm:
break;
case DateFormat.MMMdd:
break;
case DateFormat.ddMMMyyyyddd:
break;
case DateFormat.ddMMMyyyyml:
break;
default:
break;
}
MutiLanguage.Languages lang = MutiLanguage.GetCultureType();
lang = isMutiLang ? lang : MutiLanguage.Languages.en_us;
string langstr = isMutiLang ? MutiLanguage.EnumToString(lang) : MutiLanguage.EnumToString(MutiLanguage.Languages.en_us);
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Resources.Date));
System.Resources.ResourceSet rs = rm.GetResourceSet(new System.Globalization.CultureInfo(langstr), true, true);
return DateTime.ParseExact(xDateString, rs.GetString(xDateFormat.ToString()), System.Globalization.DateTimeFormatInfo.InvariantInfo);
}
示例6: ConvertDate
/// <summary>
/// ��ָ����ʽ���ַ���ת��Ϊ����
/// </summary>
public static DateTime ConvertDate(string xDateString, string xDateFormat, bool isMutiLang)
{
MutiLanguage.Languages lang = MutiLanguage.GetCultureType();
lang = isMutiLang ? lang : MutiLanguage.Languages.en_us;
string langstr = isMutiLang ? MutiLanguage.EnumToString(lang) : MutiLanguage.EnumToString(MutiLanguage.Languages.en_us);
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Resources.Date));
System.Resources.ResourceSet rs = rm.GetResourceSet(new System.Globalization.CultureInfo(langstr), true, true);
string fmt = string.IsNullOrEmpty(rs.GetString(xDateFormat)) ? xDateFormat : rs.GetString(xDateFormat);
return DateTime.ParseExact(xDateString, fmt, System.Globalization.DateTimeFormatInfo.InvariantInfo);
}
示例7: WriteScripts
/// <summary>
/// Writes scripts (including localized script resources) to the specified stream
/// </summary>
/// <param name="scriptEntries">list of scripts to write</param>
/// <param name="outputWriter">writer for output stream</param>
private static void WriteScripts(List<ScriptEntry> scriptEntries, TextWriter outputWriter)
{
foreach (ScriptEntry scriptEntry in scriptEntries)
{
if (!scriptEntry.Loaded)
{
if (!IsScriptCombinable(scriptEntry))
{
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Combined script request includes uncombinable script \"{0}\".", scriptEntry.Name));
}
// This script hasn't been loaded by the browser, so add it to the combined script file
outputWriter.Write("//START ");
outputWriter.WriteLine(scriptEntry.Name);
string script = scriptEntry.GetScript();
if (WebResourceRegex.IsMatch(script))
{
// This script uses script substitution which isn't supported yet, so throw an exception since it's too late to fix
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "ToolkitScriptManager does not support <%= WebResource/ScriptResource(...) %> substitution as used by script file \"{0}\".", scriptEntry.Name));
}
outputWriter.WriteLine(script);
// Save current culture and set the specified culture
CultureInfo currentUiCulture = Thread.CurrentThread.CurrentUICulture;
try
{
try
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(scriptEntry.Culture);
}
catch (ArgumentException)
{
// Invalid culture; proceed with default culture (just as for unsupported cultures)
}
// Write out the associated script resources (if any) in the proper culture
Assembly scriptAssembly = scriptEntry.LoadAssembly();
foreach (ScriptResourceAttribute scriptResourceAttribute in scriptAssembly.GetCustomAttributes(typeof(ScriptResourceAttribute), false))
{
if (scriptResourceAttribute.ScriptName == scriptEntry.Name)
{
// Found a matching script resource; write it out
outputWriter.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0}={{", scriptResourceAttribute.TypeName));
// Get the script resource name (without the trailing ".resources")
string scriptResourceName = scriptResourceAttribute.ScriptResourceName;
if (scriptResourceName.EndsWith(".resources", StringComparison.OrdinalIgnoreCase))
{
scriptResourceName = scriptResourceName.Substring(0, scriptResourceName.Length - 10);
}
// Load a ResourceManager/ResourceSet and walk through the list to output them all
System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager(scriptResourceName, scriptAssembly);
using (System.Resources.ResourceSet resourceSet = resourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true))
{
bool first = true;
foreach (System.Collections.DictionaryEntry de in resourceSet)
{
if (!first)
{
// Need a comma between all entries
outputWriter.Write(",");
}
// Output the entry
string name = (string)de.Key;
string value = resourceManager.GetString(name);
outputWriter.Write(string.Format(CultureInfo.InvariantCulture, "\"{0}\":\"{1}\"", QuoteString(name), QuoteString(value)));
first = false;
}
}
outputWriter.WriteLine("};");
}
}
}
finally
{
// Restore culture
Thread.CurrentThread.CurrentUICulture = currentUiCulture;
}
// Done with this script
outputWriter.Write("//END ");
outputWriter.WriteLine(scriptEntry.Name);
}
// This script is now (or will be soon) loaded by the browser
scriptEntry.Loaded = true;
}
}
示例8: GetResourceDictionary
/// <summary>
/// GetResourceDictionary
/// </summary>
public static ResourceDictionary GetResourceDictionary(string name)
{
var resourceName = name;
if (string.IsNullOrEmpty(resourceName)) { resourceName = "themes/generic.xaml"; }
ResourceDictionary retVal = null;
if (_resourceDictionaryCache.TryGetValue(resourceName, out retVal)) { return retVal; }
System.Reflection.Assembly assembly = typeof(ResourceManager).Assembly;
string baseName = string.Format("{0}.g", assembly.FullName.Split(new char[] { ',' })[0]);
string fullName = string.Format("{0}.resources", baseName);
foreach (string s in assembly.GetManifestResourceNames())
{
if (s == fullName)
{
System.Resources.ResourceManager manager = new System.Resources.ResourceManager(baseName, assembly);
System.Resources.ResourceSet set = manager.GetResourceSet(CultureInfo.InvariantCulture, true, true);
foreach (System.Collections.DictionaryEntry entry in set)
{
Console.WriteLine("{0} {1}", entry.Key, entry.Value);
}
using (System.IO.Stream stream = manager.GetStream(resourceName))
{
using (System.IO.StreamReader reader = new System.IO.StreamReader(stream))
{
retVal = System.Windows.Markup.XamlReader.Load(stream) as ResourceDictionary;//reader.ReadToEnd()
if (retVal != null)
{
_resourceDictionaryCache.Add(resourceName, retVal);
return retVal;
}
}
}
break;
}
}
return null;
}