当前位置: 首页>>代码示例>>C#>>正文


C# ResourceWriter.Dispose方法代码示例

本文整理汇总了C#中System.Resources.ResourceWriter.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceWriter.Dispose方法的具体用法?C# ResourceWriter.Dispose怎么用?C# ResourceWriter.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Resources.ResourceWriter的用法示例。


在下文中一共展示了ResourceWriter.Dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: ExceptionforResWriter03

 public static void ExceptionforResWriter03()
 {
     Assert.Throws<ArgumentNullException>(() =>
         {
             byte[] buffer = new byte[_RefBuffer.Length];
             using (var ms2 = new MemoryStream(buffer, true))
             {
                 var rw1 = new ResourceWriter(ms2);
                 try
                 {
                     rw1.AddResource(null, "args");
                 }
                 finally
                 {
                     Assert.Throws<ArgumentOutOfRangeException>(() =>
                         {
                             rw1.Dispose();
                         });
                 }
             }
         });
 }
开发者ID:gitter-badger,项目名称:corefx,代码行数:22,代码来源:ResourceWriterUnitTest.cs

示例3: Main

		static void Main(string[] args) {

			string dataDirectory = args[0];
			string targetFile = args[1];

			XmlDocument map = new XmlDocument();
			XmlNode xFilesNode = map.CreateElement("Files");
			ResourceWriter writer = new ResourceWriter(targetFile);

			foreach (string file in Directory.GetFiles(dataDirectory, "*", SearchOption.AllDirectories)) {

				XmlNode xFile = map.CreateElement("File");
				string id = Guid.NewGuid().ToString();
				string targetDirectory = Path.GetDirectoryName(file).Replace(dataDirectory, "");
				if (targetDirectory.StartsWith("\\"))
					targetDirectory = targetDirectory.Substring(1);

				xFile.AppendChild(createNode(map, "Id", id));
				xFile.AppendChild(createNode(map, "Directory", targetDirectory)); ;
				xFile.AppendChild(createNode(map, "Filename", Path.GetFileName(file)));
				xFilesNode.AppendChild(xFile);

				writer.AddResourceData(id, "setupData", Compress(File.ReadAllBytes(file)));
				
			}

			map.AppendChild(xFilesNode);
			using (MemoryStream msData = new MemoryStream()) {
				using (StreamWriter sw = new StreamWriter(msData, Encoding.UTF8)) {
					map.Save(sw);
					writer.AddResourceData("map", "setupData", msData.ToArray());
				}
			}

			writer.Generate();
			writer.Dispose();
		}
开发者ID:hbaes,项目名称:updateSystem.NET,代码行数:37,代码来源:Program.cs

示例4: WriteEnum

		[Test] // bug #82566
		public void WriteEnum ()
		{
			MemoryStream ms = new MemoryStream ();

			ResourceWriter writer = new ResourceWriter (ms);
			writer.AddResource ("Targets", AttributeTargets.Assembly);
			writer.Generate ();

			ms.Position = 0;

			bool found = false;

			ResourceReader reader = new ResourceReader (ms);
			foreach (DictionaryEntry de in reader) {
				string name = de.Key as string;
				Assert.IsNotNull (name, "#1");
				Assert.AreEqual ("Targets", name, "#2");
				Assert.IsNotNull (de.Value, "#3");
				Assert.AreEqual (AttributeTargets.Assembly, de.Value, "#4");
				found = true;
			}

			Assert.IsTrue (found, "#5");

			writer.Dispose ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:27,代码来源:ResourceWriterTest.cs

示例5: ExceptionforResWriter05

 public static void ExceptionforResWriter05()
 {
     Assert.Throws<InvalidOperationException>(() =>
         {
             byte[] buffer = new byte[_RefBuffer.Length];
             using (var ms2 = new MemoryStream(buffer, true))
             {
                 var rw1 = new ResourceWriter(ms2);
                 rw1.AddResource("key2", "args");
                 rw1.Dispose();
                 rw1.AddResource("key2", "args");
             }
         });
 }
开发者ID:gitter-badger,项目名称:corefx,代码行数:14,代码来源:ResourceWriterUnitTest.cs

示例6: ExceptionforResWriter06

 public static void ExceptionforResWriter06()
 {
     Assert.Throws<ArgumentOutOfRangeException>(() =>
         {
             byte[] buffer = new byte[_RefBuffer.Length];
             using (var ms2 = new MemoryStream(buffer, true))
             {
                 var rw1 = new ResourceWriter(ms2);
                 try
                 {
                     rw1.Generate();
                 }
                 finally
                 {
                     Assert.Throws<NotSupportedException>(() =>
                         {
                             rw1.Dispose();
                         });
                 }
             }
         });
 }
开发者ID:gitter-badger,项目名称:corefx,代码行数:22,代码来源:ResourceWriterUnitTest.cs

示例7: CompileResource

		string CompileResource (AppResourceFileInfo arfi, bool local)
		{
			string path = arfi.Info.FullName;
			string rname = Path.GetFileNameWithoutExtension (path) + ".resources";
			if (!local)
				rname = "Resources." + rname;
			
			string resource = Path.Combine (TempDirectory, rname);
			FileStream source = null, destination = null;
			IResourceReader reader = null;
			ResourceWriter writer = null;

			try {
				source = new FileStream (path, FileMode.Open, FileAccess.Read);
				destination = new FileStream (resource, FileMode.Create, FileAccess.Write);
				reader = GetReaderForKind (arfi.Kind, source, path);
				writer = new ResourceWriter (destination);
				foreach (DictionaryEntry de in reader) {
					object val = de.Value;
					if (val is string)
						writer.AddResource ((string)de.Key, (string)val);
					else
						writer.AddResource ((string)de.Key, val);
				}
			} catch (Exception ex) {
				throw new HttpException ("Failed to compile resource file", ex);
			} finally {
				if (reader != null)
					reader.Dispose ();
				if (source != null)
					source.Dispose ();
				if (writer != null)
					writer.Dispose ();
				if (destination != null)
					destination.Dispose ();
			}
			
			return resource;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:39,代码来源:AppResourcesCompiler.cs


注:本文中的System.Resources.ResourceWriter.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。