本文整理汇总了C#中System.Resources.ResourceWriter类的典型用法代码示例。如果您正苦于以下问题:C# ResourceWriter类的具体用法?C# ResourceWriter怎么用?C# ResourceWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceWriter类属于System.Resources命名空间,在下文中一共展示了ResourceWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
Catalog catalog = new Catalog();
foreach(string fileName in Options.InputFiles)
{
Catalog temp = new Catalog();
temp.Load(fileName);
catalog.Append(temp);
}
using (ResourceWriter writer = new ResourceWriter(Options.OutFile))
{
foreach (CatalogEntry entry in catalog)
{
try
{
writer.AddResource(entry.Key, entry.IsTranslated ? entry.GetTranslation(0) : entry.String);
}
catch (Exception e)
{
string message = String.Format("Error adding item {0}", entry.String);
if (!String.IsNullOrEmpty(entry.Context))
message = String.Format("Error adding item {0} in context '{1}'",
entry.String, entry.Context);
throw new Exception(message, e);
}
}
writer.Generate();
}
}
开发者ID:rzaitov,项目名称:GetTextNet,代码行数:30,代码来源:ResourcesGen.cs
示例2: SystemResourceTests_Should_WriteUpdateValueToResx
public void SystemResourceTests_Should_WriteUpdateValueToResx()
{
var filename = Path.Combine(TestContext.TestRunDirectory, Guid.NewGuid().ToString() + ".resx");
var inputData = "TheInputData";
using (ResourceWriter w = new ResourceWriter(filename))
{
w.AddResource("InvariantName", inputData);
w.Generate();
}
inputData = "TheUpdatedInputData";
using (ResourceWriter w = new ResourceWriter(filename))
{
w.AddResource("InvariantName", inputData);
w.Generate();
}
var data = string.Empty;
using( var r = new ResourceReader(filename))
{
var rr = r.GetEnumerator();
rr.MoveNext();
data = rr.Value as string;
}
Assert.IsTrue(inputData == data);
}
开发者ID:zachbonham,项目名称:Lingua,代码行数:35,代码来源:System.Resource.Tests.cs
示例3: WriteEnglishResource
/// <summary>
/// 写入 英文 资源文件.
/// </summary>
public void WriteEnglishResource()
{
// 构造写入器.
ResourceWriter rw = new ResourceWriter("English.resource");
rw.AddResource("Hello", "Hello");
rw.Close();
}
开发者ID:mahuidong,项目名称:my-csharp-sample,代码行数:10,代码来源:ResourceSample.cs
示例4: WriteChinaResource
/// <summary>
/// 写入 中文 资源文件.
/// </summary>
public void WriteChinaResource()
{
// 构造写入器.
ResourceWriter rw = new ResourceWriter("China.resource");
rw.AddResource("Hello", "你好");
rw.Close();
}
开发者ID:mahuidong,项目名称:my-csharp-sample,代码行数:10,代码来源:ResourceSample.cs
示例5: Build
/// <summary>
/// Build .resx file to .resource
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
public static void Build(string input)
{
var resxs = Directory.GetFiles(input, "*.resx");
foreach (var resxFile in resxs)
{
var binFile = Path.GetDirectoryName(resxFile) +"\\"+ Path.GetFileNameWithoutExtension(resxFile) + ".resources";
if (File.Exists(binFile)) {
var resxFileInfo = new FileInfo(resxFile);
var binFileInfo = new FileInfo(binFile);
if (resxFileInfo.LastWriteTime > binFileInfo.LastWriteTime)
File.Delete(binFile); //Re-complied
}
if (!File.Exists(binFile))
{
using (var reader = new ResXResourceReader(resxFile))
{
using (var writer = new ResourceWriter(binFile))
{
foreach (DictionaryEntry d in reader)
{
writer.AddResource(d.Key.ToString(), d.Value);
}
}
}
}
}
}
开发者ID:howej,项目名称:dotnetage,代码行数:33,代码来源:ResBuilder.cs
示例6: 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();
}
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:31,代码来源:GenerateImageResources.cs
示例7: WriteResourceFile
private static void WriteResourceFile(string resxFilePath)
{
using (var fs = File.OpenRead(resxFilePath))
{
var document = XDocument.Load(fs);
var binDirPath = Path.Combine(Path.GetDirectoryName(resxFilePath), "bin");
if (!Directory.Exists(binDirPath))
{
Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(resxFilePath), "bin"));
}
// Put in "bin" sub-folder of resx file
var targetPath = Path.Combine(binDirPath, Path.ChangeExtension(Path.GetFileName(resxFilePath), ".resources"));
using (var targetStream = File.Create(targetPath))
{
var rw = new ResourceWriter(targetStream);
foreach (var e in document.Root.Elements("data"))
{
var name = e.Attribute("name").Value;
var value = e.Element("value").Value;
rw.AddResource(name, value);
}
rw.Generate();
}
}
}
开发者ID:morarsebastian,项目名称:i18nStarterWeb,代码行数:31,代码来源:ResxFileCompilation.cs
示例8: 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();
}
}
开发者ID:RobertCL,项目名称:MissionPlanner,代码行数:35,代码来源:SpecialResourceWriter.cs
示例9: InitRes
private void InitRes()
{
if(rw == null)
{
resourceFilePath = OutDirMan.MakeOutFileName(resourceFilePath);
rw = new ResourceWriter(resourceFilePath);
}
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-msnet-netz-compressor-madebits,代码行数:8,代码来源:ResMan.cs
示例10: ExceptionforResWriter01
public static void ExceptionforResWriter01()
{
Assert.Throws<ArgumentNullException>(() =>
{
MemoryStream ms2 = null;
var rw = new ResourceWriter(ms2);
});
}
开发者ID:gitter-badger,项目名称:corefx,代码行数:8,代码来源:ResourceWriterUnitTest.cs
示例11: WriteCollectedBamlStreams
private void WriteCollectedBamlStreams(ResourceWriter resourceWriter)
{
foreach (var bamlStream in _bamlStreams)
{
resourceWriter.AddResourceData(
GetResourceName(bamlStream.Key, bamlStream.Value), bamlStream.Key.type, bamlStream.Key.data);
}
}
开发者ID:jinjingcai2014,项目名称:il-repack,代码行数:8,代码来源:BamlStreamCollector.cs
示例12: Process
public void Process(EmbeddedResource embeddedResource, ResourceWriter resourceWriter)
{
if (_bamlStreams.Count == 0)
return;
WriteCollectedBamlStreams(resourceWriter);
PatchGenericThemesBaml(resourceWriter);
}
开发者ID:jinjingcai2014,项目名称:il-repack,代码行数:8,代码来源:BamlStreamCollector.cs
示例13: BuildResource
public void BuildResource(string outputPath)
{
using (ResourceWriter w1 = new ResourceWriter(outputPath))
{
foreach (Item item in _items)
w1.AddResource(item.Name, item.Value);
}
}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:8,代码来源:TestResourceBuilder.cs
示例14: 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();
}
开发者ID:pavelsavara,项目名称:nMars,代码行数:9,代码来源:ResourceUtil.cs
示例15: MakeResourceStream
private static Stream MakeResourceStream()
{
var stream = new MemoryStream();
var resourceWriter = new ResourceWriter(stream);
resourceWriter.AddResource("TestName", "value");
resourceWriter.Generate();
stream.Position = 0;
return stream;
}
开发者ID:qiudesong,项目名称:Localization,代码行数:9,代码来源:ResourceManagerStringLocalizerTest.cs
示例16: Main
static void Main(string[] args)
{
var getopt = new Getopt(Assembly.GetExecutingAssembly().GetName().Name, args, "i:o:") { Opterr = false };
string input = null;
string output = null;
int option;
while (-1 != (option = getopt.getopt()))
{
switch (option)
{
case 'i': input = getopt.Optarg; break;
case 'o': output = getopt.Optarg; break;
default: PrintUsage(); return;
}
}
if (input == null || output == null)
{
PrintUsage();
return;
}
try
{
if (!File.Exists(input))
{
Console.WriteLine("File {0} not found", input);
return;
}
Dictionary<string, string> entries;
var parser = new PoParser();
using (var reader = new StreamReader(input))
{
entries = parser.ParseIntoDictionary(reader);
}
using (var writer = new ResourceWriter(output))
{
foreach (var kv in entries)
{
try { writer.AddResource(kv.Key, kv.Value); }
catch (Exception e) { Console.WriteLine("Error adding item {0}: {1}", kv.Key, e.Message); }
}
writer.Generate();
}
}
catch (Exception ex)
{
Console.WriteLine("Error during execution: {0}", ex.Message);
return;
}
}
开发者ID:neiljbrookes,项目名称:SparkleShare,代码行数:56,代码来源:Program.cs
示例17: Process
public bool Process(
AssemblyDefinition containingAssembly, Res resource, ResReader resourceReader, ResourceWriter resourceWriter)
{
if (!resource.IsBamlStream)
return false;
resource.data = GetProcessedResource(resource, containingAssembly);
return false;
}
开发者ID:huoxudong125,项目名称:il-repack,代码行数:10,代码来源:BamlResourcePatcher.cs
示例18: ResWriterData
internal ResWriterData(ResourceWriter resWriter, Stream memoryStream, string strName, string strFileName, string strFullFileName, ResourceAttributes attribute)
{
this.m_resWriter = resWriter;
this.m_memoryStream = memoryStream;
this.m_strName = strName;
this.m_strFileName = strFileName;
this.m_strFullFileName = strFullFileName;
this.m_nextResWriter = null;
this.m_attribute = attribute;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:ResWriterData.cs
示例19: 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();
}
开发者ID:nezlobin,项目名称:ASP,代码行数:10,代码来源:ResourceObj.cs
示例20: EnsureRepositoryFileExists
internal void EnsureRepositoryFileExists()
{
if (!File.Exists(this.RepositoryFilename))
{
using (IResourceWriter writer = new ResourceWriter(this.RepositoryFilename))
{
writer.Generate();
}
}
}
开发者ID:dangilkerson,项目名称:ApprovalTestsVS2010,代码行数:10,代码来源:ImageAdornmentRepositoryService.cs
注:本文中的System.Resources.ResourceWriter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论