本文整理汇总了C#中ResourceManager.GetObject方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceManager.GetObject方法的具体用法?C# ResourceManager.GetObject怎么用?C# ResourceManager.GetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceManager
的用法示例。
在下文中一共展示了ResourceManager.GetObject方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main ()
{
string dir = AppDomain.CurrentDomain.BaseDirectory;
Assembly asm = Assembly.LoadFrom (Path.Combine (dir, "../localized/localized.dll"));
ResourceManager rm = new ResourceManager ("MyClass", asm);
Assert.AreEqual ("System information", rm.GetObject ("SystemInformation", new CultureInfo ("en-US")), "#1");
Assert.AreEqual ("Informació del sistema", rm.GetObject ("SystemInformation", new CultureInfo ("ca-ES")), "#2");
Assert.AreEqual ("Systeeminformatie", rm.GetObject ("SystemInformation", new CultureInfo ("nl-BE")), "#3");
}
示例2: Net20Comp
// a default, no parameter constructor is required
public Net20Comp()
{
System.Reflection.Assembly a = this.GetType().Assembly;
ResourceManager rm = new ResourceManager("net20comp", a);
byte[] data = (byte[])rm.GetObject("head");
head = Encoding.ASCII.GetString(data);
data = (byte[])rm.GetObject("body");
body = Encoding.ASCII.GetString(data);
rm.ReleaseAllResources();
}
示例3: Main
static void Main ()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler (CurrentDomain_AssemblyResolve);
try {
Assembly a = Assembly.GetExecutingAssembly ();
a.GetSatelliteAssembly (new CultureInfo ("ja-JP"), new Version ("3.0"));
Assert.Fail ("#A1");
} catch (FileNotFoundException) {
Assert.AreEqual (1, _AssemblyResolves.Count, "#A2");
Assert.AreEqual ("test.resources, Version=3.0, Culture=ja-JP, PublicKeyToken=null", _AssemblyResolves [0], "#A3");
}
_AssemblyResolves.Clear ();
try {
ResourceManager rm = new ResourceManager ("foo", Assembly.GetExecutingAssembly ());
rm.GetObject ("bar", new CultureInfo ("fr-FR"));
Assert.Fail ("#B1");
} catch (MissingManifestResourceException) {
Assert.AreEqual (2, _AssemblyResolves.Count, "#B2");
Assert.AreEqual ("test.resources, Version=0.0.0.0, Culture=fr-FR, PublicKeyToken=null", _AssemblyResolves [0], "#B3");
Assert.AreEqual ("test.resources, Version=0.0.0.0, Culture=fr, PublicKeyToken=null", _AssemblyResolves [1], "#B4");
}
}
示例4: addSubeditorButton
public void addSubeditorButton(FormMain formMain)
{
this.formMain = formMain;
var rm = new ResourceManager("PluginChrView.Icon", this.GetType().Assembly);
var icon = (System.Drawing.Bitmap)rm.GetObject("icon_video");
var item = new ToolStripButton("View video", icon, btHex_Click);
item.DisplayStyle = ToolStripItemDisplayStyle.Image;
formMain.addSubeditorButton(item);
}
示例5: Main
static void Main ()
{
ResourceManager resMgr = new ResourceManager (typeof (MainForm));
ImageList imgList = new ImageList ();
imgList.ColorDepth = ColorDepth.Depth16Bit;
imgList.ImageSize = new Size (16, 16);
imgList.ImageStream = ((ImageListStreamer) (resMgr.GetObject ("Locs.ImageStream")));
imgList.TransparentColor = Color.Transparent;
}
示例6: GetObject
public static void GetObject(string key, object expectedValue)
{
var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx.netstandard17", typeof(ResourceManagerTests).GetTypeInfo().Assembly);
Assert.Equal(expectedValue, manager.GetObject(key));
Assert.Equal(expectedValue, manager.GetObject(key, new CultureInfo("en-US")));
}
示例7: GetXAPFromResources
public static byte[] GetXAPFromResources()
{
try
{
var res = new ResourceManager("SLViewer", Assembly.GetExecutingAssembly());
return (byte[])res.GetObject("content.xap"); ;
}
catch
{
return null;
}
}
示例8: DoThings
private Boolean DoThings()
{
int iCountErrors = 0;
int iCountTestcases = 0;
String temp;
String line;
StringReader table;
String fileName;
String[] values;
Boolean firstLine;
Boolean pass;
String format;
String[] expectedValues;
CultureInfo[] cultures;
ResourceManager manager;
Calendar otherCalendar;
Calendar gregorian;
Hashtable calendars;
calendars = new Hashtable();
calendars.Add(0x0401, new HijriCalendar());
calendars.Add(0x0404, new TaiwanCalendar());
calendars.Add(0x040D, new HebrewCalendar());
calendars.Add(0x0411, new JapaneseCalendar());
calendars.Add(0x0412, new KoreanCalendar());
calendars.Add(0x041E, new ThaiBuddhistCalendar());
otherCalendar = null;
gregorian = new GregorianCalendar();
pass = true;
try{
manager = new ResourceManager(resourceBaseName, this.GetType().Assembly, null);
}catch(Exception){
throw new Exception("ResourceFileNotFound");
}
if(manager == null)
throw new Exception("ResourceFileNotFound");
iCountTestcases++;
cultures = (CultureInfo[])manager.GetObject(resCultures);
foreach(CultureInfo culture in cultures){
if(calendars.ContainsKey(culture.LCID))
otherCalendar = (Calendar)calendars[culture.LCID];
fileName = baseFileName + fileFormalFormats + culture.ToString() + false.ToString();
if(verbose)
Console.WriteLine("Processing formal Formatting with Gregorian, FileName - <{0}>", fileName);
temp = manager.GetString(fileName);
if(temp == null)
throw new Exception(String.Format("Formatting table for {0} locale not found", culture.ToString()));
culture.DateTimeFormat.Calendar = gregorian;
table = new StringReader(temp);
firstLine = false;
while(true){
line = table.ReadLine();
if(line==null)
break;
values = line.Split(new Char[]{separator[0]});
if(!firstLine){
if(values[values.Length-1] == String.Empty)
dateTable = new DateTime[values.Length-2];
else
dateTable = new DateTime[values.Length-1];
for(int i=0; i<dateTable.Length; i++){
dateTable[i] = DateTime.ParseExact(values[i+1], "G", culture);
}
firstLine = true;
}
else{
format = values[0].Trim();
if(values[values.Length-1] == String.Empty)
expectedValues = new String[values.Length-2];
else
expectedValues = new String[values.Length-1];
for(int i=0; i<expectedValues.Length; i++)
expectedValues[i] = values[i+1];
for(int i=0;i<dateTable.Length; i++){
if(verbose)
Console.WriteLine("Date: <{0}>, Format: <{1}>, Expected: <{2}>", dateTable[i], format, expectedValues[i]);
if(!dateTable[i].ToString(format, culture).Equals(expectedValues[i])){
pass = false;
Console.WriteLine("Err_#45232! Date: <{0}>, Format: <{1}>, Expected: <{2}>, Returned: <{3}>", dateTable[i], format, expectedValues[i], dateTable[i].ToString(format, culture));
}
}
}
}
table.Close();
fileName = baseFileName + fileFormalFormats + culture.ToString() + true.ToString();
temp = manager.GetString(fileName);
if(temp != null){
if(culture.LCID == 0x040D)
break;
if(verbose)
Console.WriteLine("Processing formal Formatting with other otherCalendar, FileName - <{0}>", fileName);
culture.DateTimeFormat.Calendar = otherCalendar;
table = new StringReader(temp);
firstLine = false;
while(true){
line = table.ReadLine();
if(line==null)
break;
values = line.Split(new Char[]{separator[0]});
if(!firstLine){
if(values[values.Length-1] == String.Empty)
//.........这里部分代码省略.........
示例9: MainForm
public MainForm ()
{
ResourceManager resources = new ResourceManager (typeof (MainForm));
//
// _panel
//
_panel = new Panel ();
_panel.BackColor = Color.Transparent;
_panel.BackgroundImage = ((Bitmap) (resources.GetObject ("_panel.BackgroundImage")));
_panel.Dock = DockStyle.Fill;
_panel.Size = new Size (248, 192);
_panel.TabIndex = 0;
_panel.MouseUp += new MouseEventHandler (Panel_MouseUp);
_panel.MouseMove += new MouseEventHandler (Panel_MouseMove);
_panel.MouseDown += new MouseEventHandler (Panel_MouseDown);
Controls.Add (_panel);
//
// _quitButton
//
_quitButton = new Button ();
_quitButton.BackColor = Color.Sienna;
_quitButton.Font = new Font ("Microsoft Sans Serif", 6.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte) (0)));
_quitButton.ForeColor = Color.White;
_quitButton.Location = new Point (108, 116);
_quitButton.Size = new Size (42, 16);
_quitButton.Visible = false;
_quitButton.TabIndex = 3;
_quitButton.Text = "Quit?";
_quitButton.Click += new EventHandler (QuitButton_Click);
_panel.Controls.Add (_quitButton);
//
// _label
//
_label = new Label ();
_label.BackColor = Color.Sienna;
_label.Font = new Font ("Microsoft Sans Serif", 6.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte) (0)));
_label.ForeColor = Color.White;
_label.Location = new Point (40, 114);
_label.Size = new Size (160, 10);
_label.TabIndex = 1;
_label.TextAlign = ContentAlignment.MiddleCenter;
_label.Text = "Please wait ...";
_panel.Controls.Add (_label);
//
// _progressBar
//
_progressBar = new ProgressBar ();
_progressBar.Location = new Point (40, 124);
_progressBar.Size = new Size (160, 8);
_progressBar.TabIndex = 0;
_panel.Controls.Add (_progressBar);
//
// _timer
//
_timer = new Timer ();
_timer.Enabled = true;
_timer.Interval = 25;
_timer.Tick += new EventHandler (Timer_Tick);
//
// MainForm
//
AutoScaleBaseSize = new Size (5, 13);
BackColor = Color.White;
ClientSize = new Size (248, 192);
FormBorderStyle = FormBorderStyle.None;
Location = new Point (250, 100);
StartPosition = FormStartPosition.Manual;
Text = "bug #80855";
TransparencyKey = Color.White;
Load += new EventHandler (MainForm_Load);
}
示例10: ReadManaged
public byte[] ReadManaged()
{
ResourceManager Manager = new ResourceManager("Encrypted", Assembly.GetExecutingAssembly());
byte[] bytes = (byte[])Manager.GetObject("encfile");
return bytes;
}
示例11: DoThings
private Boolean DoThings()
{
Int64 numberValue;
Int32 i32Value;
Int32 i32Value_1;
Int16 i16Value;
Int16 i16Value_1;
SByte i8Value;
SByte i8Value_1;
Byte ui8Value;
Byte ui8Value_1;
UInt16 ui16Value;
UInt16 ui16Value_1;
UInt32 ui32Value;
UInt32 ui32Value_1;
UInt64 ui64Value;
UInt64 ui64Value_1;
Decimal decimalValue;
Double doubleValue;
String temp;
String line;
StringReader table;
String fileName;
String[] values;
Boolean firstLine;
Boolean pass;
Boolean parse;
String format;
String[] expectedValues;
String expectedValue;
CultureInfo[] cultures;
NumberFormatInfo numInfo;
ResourceManager manager;
NumberStyles styles = NumberStyles.Number;
pass = true;
try{
manager = new ResourceManager(resourceBaseName, this.GetType().Assembly, null);
}catch(Exception){
throw new Exception("ResourceFileNotFound");
}
if(manager == null)
throw new Exception("ResourceFileNotFound");
cultures = (CultureInfo[])manager.GetObject(resCultures);
foreach(CultureInfo culture in cultures){
if(verbose)
Console.WriteLine("Looking at culture, <{0}>", culture);
numInfo = NumberFormatInfo.GetInstance(culture);
fileName = baseFileName + strInt + culture.ToString();
if(verbose)
Console.WriteLine("Processing Integer Formatting, FileName - <{0}>", fileName);
temp = manager.GetString(fileName);
if(temp == null)
throw new Exception(String.Format("Formatting table for {0} locale not found", culture.ToString()));
table = new StringReader(temp);
firstLine = false;
while(true){
line = table.ReadLine();
if(line==null)
break;
if(line.Trim()==String.Empty)
continue;
values = line.Split(new Char[]{separator[0]});
if(!firstLine){
if(values[values.Length-1] == String.Empty)
numberTable = new Int64[values.Length-2];
else
numberTable = new Int64[values.Length-1];
for(int i=0; i<numberTable.Length; i++){
numberTable[i] = Int64.Parse(values[i+1], numInfo);
}
firstLine = true;
}
else{
format = values[0];
if(values[values.Length-1] == String.Empty)
expectedValues = new String[values.Length-2];
else
expectedValues = new String[values.Length-1];
for(int i=0; i<expectedValues.Length; i++)
expectedValues[i] = values[i+1];
styles = GetNumberStyle(format[0], out parse);
for(int i=0;i<numberTable.Length; i++){
if(verbose)
Console.WriteLine("Number: <{0}>, Format: <{1}>, Expected: <{2}>", numberTable[i], format, expectedValues[i]);
if(!numberTable[i].ToString(format, numInfo).Equals(expectedValues[i])){
pass = false;
Console.WriteLine("Err_#45232! Number: <{0}>, Format: <{1}>, Expected: <{2}>, Returned: <{3}>", numberTable[i], format, expectedValues[i], numberTable[i].ToString(format, numInfo));
}
if(parse){
try{
numberValue = Int64.Parse(expectedValues[i], styles, numInfo);
if(numberValue != numberTable[i]){
if(!AreTheseNumbersEqual(numberValue, numberTable[i], format, culture)){
pass = false;
Console.WriteLine("Err_32985sdg! Expected: {0}, Returned: {1}", numberTable[i], numberValue);
}
}
}catch(OverflowException){
}
}
//.........这里部分代码省略.........
示例12: GetTransformReader
private static XmlTextReader GetTransformReader()
{
XmlTextReader reader = null;
Assembly assembly = Assembly.GetAssembly(typeof(XmlResultVisitor));
ResourceManager resourceManager = new ResourceManager("NUnit.Framework.Transform",assembly);
string xmlData = (string)resourceManager.GetObject("Summary.xslt");
return new XmlTextReader(new StringReader(xmlData));
}
示例13: PaintValue
public override void PaintValue(PaintValueEventArgs pe)
{
string bmpName = null;
int g = (int)pe.Value;
//Load SampleResources file
string m = this.GetType().Module.Name;
m = m.Substring(0, m.Length - 4);
ResourceManager resourceManager = new ResourceManager(m + ".Resource1", Assembly.GetExecutingAssembly());
if (g > 80)
{
bmpName = "best";
}
else if (g > 60)
{
bmpName = "ok";
}
else
{
bmpName = "bad";
}
//Draw the corresponding image
Bitmap newImage = (Bitmap)resourceManager.GetObject(bmpName);
Rectangle destRect = pe.Bounds;
//destRect.Width *= 4;
newImage.MakeTransparent();
pe.Graphics.DrawImage(newImage, destRect);
// Bitmap b = new Bitmap(typeof(GradeEditor), bmpName);
// pe.Graphics.DrawImage(Image.FromFile(Environment.CurrentDirectory + "\\" + bmpName), pe.Bounds);
// pe.Graphics.DrawImage(b, pe.Bounds);
// b.Dispose();
}