本文整理汇总了C#中System.Resources.ResourceWriter.Close方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceWriter.Close方法的具体用法?C# ResourceWriter.Close怎么用?C# ResourceWriter.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Resources.ResourceWriter
的用法示例。
在下文中一共展示了ResourceWriter.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
ResourceWriter myResource = new ResourceWriter("Images.resources");
myResource.AddResource("flash", new Bitmap("flashScreen.png"));
Image simpleImage = new Image();
simpleImage.Margin = new Thickness(0);
BitmapImage bi = new BitmapImage();
//BitmapImage.UriSource must be in a BeginInit/EndInit block
bi.BeginInit();
bi.UriSource = new Uri(@"pack://siteoforigin:,,,/alarm3.png");
bi.EndInit();
//set image source
simpleImage.Source = bi;
// simpleImage.Stretch = Stretch.None;
simpleImage.HorizontalAlignment = HorizontalAlignment.Center;
simpleImage.Visibility = Visibility.Hidden;
simpleImage.Name = "AlarmIndicator";
simpleImage.Width = 13;
myResource.AddResource("alarm", new Image("alarm3.png"));
myResource.Close();
}
示例2: WriteChinaResource
/// <summary>
/// 写入 中文 资源文件.
/// </summary>
public void WriteChinaResource()
{
// 构造写入器.
ResourceWriter rw = new ResourceWriter("China.resource");
rw.AddResource("Hello", "你好");
rw.Close();
}
示例3: WriteEnglishResource
/// <summary>
/// 写入 英文 资源文件.
/// </summary>
public void WriteEnglishResource()
{
// 构造写入器.
ResourceWriter rw = new ResourceWriter("English.resource");
rw.AddResource("Hello", "Hello");
rw.Close();
}
示例4: SpecialResourceWriter
public SpecialResourceWriter()
{
// Load all bunlde
IList<IResourceBundle> allBundle = new List<IResourceBundle>(20);
allBundle.Add(ResourceBundleFactory.CreateBundle("CanonMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("CasioMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("Commons", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("ExifInteropMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("ExifMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("FujiFilmMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("GpsMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("IptcMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("JpegMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("KodakMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("KyoceraMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("NikonTypeMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("OlympusMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("PanasonicMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("PentaxMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
allBundle.Add(ResourceBundleFactory.CreateBundle("SonyMarkernote", null, ResourceBundleFactory.USE_TXTFILE));
foreach(IResourceBundle bdl in allBundle)
{
ResourceWriter rw = new ResourceWriter(bdl.Fullname+".resources");
IDictionary<string,string> idic = bdl.Entries;
IDictionaryEnumerator enumDic = (IDictionaryEnumerator)idic.GetEnumerator();
while (enumDic.MoveNext())
{
rw.AddResource((string)enumDic.Key, (string)enumDic.Value);
}
rw.Close();
rw.Dispose();
}
}
示例5: AddFileAsStringResource
public static void AddFileAsStringResource(string resourceFile, string resourceName, string inputFile)
{
ResourceWriter writer = new ResourceWriter(resourceFile);
StreamReader reader = new StreamReader(inputFile);
string s = reader.ReadToEnd();
reader.Close();
writer.AddResource(resourceName, s);
writer.Close();
}
示例6: InsertEmployee
public static void InsertEmployee(ResourceObj emp)
{
l.Add(emp);
ResourceWriter rsxw = new ResourceWriter(path);
for (int i = 0; i < l.Count; i++)
{
rsxw.AddResource("obj" + i.ToString(), l[i]);
}
rsxw.Close();
}
示例7: GenerationData
void GenerationData(int countOfObj)
{
Random rand = new Random();
ResourceWriter rsxw = new ResourceWriter(Server.MapPath("~/Resources/") + "res.resx");
for (int i = 0; i < countOfObj; i++)
{
rsxw.AddResource("obj" + i.ToString(), new ResourceObj(rand));
}
rsxw.Close();
}
示例8: WriteImageResource
/// <summary>
/// Creates a resources file with an image
/// </summary>
/// <param name="imageSourcePath"></param>
/// <param name="outputPath"></param>
public static void WriteImageResource(string imageSourcePath, string outputPath) {
Debug.Assert(imageSourcePath.EndsWith(".png"));
Debug.Assert(outputPath.EndsWith(".resources"));
FileInfo fileInfo = new FileInfo(imageSourcePath);
FileStream fsSource = fileInfo.OpenRead();
byte[] bytes = new byte[fileInfo.Length + 1];
int bytesRead = fsSource.Read(bytes, 0, bytes.Length);
Debug.Assert(bytesRead == fileInfo.Length);
MemoryStream memoryStream = new MemoryStream(bytes, 0, bytesRead);
ResourceWriter resw = new ResourceWriter(outputPath);
resw.AddResource(imageSourcePath.ToLowerInvariant(), memoryStream);
resw.Close();
}
示例9: WriteResource
// Read all msgid/msgstr pairs (each string being NUL-terminated and
// UTF-8 encoded) and write the .resources file to the given filename.
WriteResource(String filename)
{
Stream input = new BufferedStream(Console.OpenStandardInput());
reader = new StreamReader(input, new UTF8Encoding());
if (filename.Equals("-")) {
BufferedStream output = new BufferedStream(Console.OpenStandardOutput());
// A temporary output stream is needed because ResourceWriter.Generate
// expects to be able to seek in the Stream.
MemoryStream tmpoutput = new MemoryStream();
ResourceWriter rw = new ResourceWriter(tmpoutput);
ReadAllInput(rw);
#if __CSCC__
// Use the ResourceReader to check against pnet-0.6.0 ResourceWriter
// bug.
try {
ResourceReader rr = new ResourceReader(new MemoryStream(tmpoutput.ToArray()));
foreach (System.Collections.DictionaryEntry entry in rr);
} catch (IOException e) {
throw new Exception("class ResourceWriter is buggy", e);
}
#endif
tmpoutput.WriteTo(output);
rw.Close();
output.Close();
} else {
#if __CSCC__
MemoryStream tmpoutput = new MemoryStream();
ResourceWriter rw = new ResourceWriter(tmpoutput);
ReadAllInput(rw);
// Use the ResourceReader to check against pnet-0.6.0 ResourceWriter
// bug.
try {
ResourceReader rr = new ResourceReader(new MemoryStream(tmpoutput.ToArray()));
foreach (System.Collections.DictionaryEntry entry in rr);
} catch (IOException e) {
throw new Exception("class ResourceWriter is buggy", e);
}
BufferedStream output = new BufferedStream(new FileStream(filename, FileMode.Create, FileAccess.Write));
tmpoutput.WriteTo(output);
rw.Close();
output.Close();
#else
ResourceWriter rw = new ResourceWriter(filename);
ReadAllInput(rw);
rw.Close();
#endif
}
}
示例10: UpdateEmployee
public static void UpdateEmployee(ASP_ex5.ResourceObj emp)
{
ResourceWriter rsxw = new ResourceWriter(path);
for (int i = 0; i < l.Count; i++)
{
if (l[i].key == emp.key)
{
l[i].comment = emp.comment;
l[i].key = emp.key;
l[i].value = emp.value;
}
rsxw.AddResource("obj" + i.ToString(), l[i]);
}
rsxw.Close();
}
示例11: Bug81759
public void Bug81759 ()
{
MemoryStream ms = new MemoryStream ();
using (ResourceReader xr = new ResourceReader (
"Test/resources/bug81759.resources")) {
ResourceWriter rw = new ResourceWriter (ms);
foreach (DictionaryEntry de in xr)
rw.AddResource ((string) de.Key, de.Value);
rw.Close ();
}
ResourceReader rr = new ResourceReader (new MemoryStream (ms.ToArray ()));
foreach (DictionaryEntry de in rr) {
Assert.AreEqual ("imageList.ImageSize", de.Key as string, "#1");
Assert.AreEqual ("Size", de.Value.GetType ().Name, "#2");
}
}
示例12: Close
public void Close ()
{
MemoryStream ms = new MemoryStream ();
ResourceWriter writer = new ResourceWriter (ms);
writer.AddResource ("Name", "Miguel");
Assert.IsTrue (ms.CanWrite, "#A1");
Assert.IsTrue (ms.GetBuffer ().Length == 0, "#A2");
writer.Close ();
Assert.IsFalse (ms.CanWrite, "#B1");
Assert.IsFalse (ms.GetBuffer ().Length == 0, "#B2");
writer.Close ();
}
示例13: AddResource
[Test] // AddResource (string, string)
public void AddResource2_Value_Null ()
{
MemoryStream ms = new MemoryStream ();
ResourceWriter writer = new ResourceWriter (ms);
writer.AddResource ("Name", (string) null);
writer.Generate ();
ms.Position = 0;
ResourceReader rr = new ResourceReader (ms);
IDictionaryEnumerator enumerator = rr.GetEnumerator ();
Assert.IsTrue (enumerator.MoveNext (), "#1");
Assert.AreEqual ("Name", enumerator.Key, "#2");
Assert.IsNull (enumerator.Value, "#3");
Assert.IsFalse (enumerator.MoveNext (), "#4");
writer.Close ();
}
示例14: AddResource_Name_Duplicate
public void AddResource_Name_Duplicate ()
{
MemoryStream ms = new MemoryStream ();
ResourceWriter writer = new ResourceWriter (ms);
writer.AddResource ("FirstName", "Miguel");
try {
writer.AddResource ("FirstNaMe", "Chris");
Assert.Fail ("#1");
} catch (ArgumentException ex) {
// Item has already been added. Key is dictionary:
// 'FirstName' Key being added: 'FirstNaMe'
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsNull (ex.ParamName, "#5");
}
writer.AddResource ("Name", "Miguel");
writer.Close ();
}
示例15: DeleteEmployee
public static void DeleteEmployee(ASP_ex5.ResourceObj emp)
{
ResourceWriter rsxw = new ResourceWriter(path);
for (int i = 0; i < l.Count; i++)
{
if (l[i].key != emp.key)
{
rsxw.AddResource("obj" + i.ToString(), l[i]);
}
}
rsxw.Close();
}