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


C# ResourceReader.Close方法代码示例

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


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

示例1: ResourceHelper

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="filepath">资源文件路径</param>
        public ResourceHelper(string filepath)
        {
            this.m_FilePath = filepath;
            this.m_Hashtable = new Hashtable();

            //如果存在
            if (File.Exists(filepath))
            {
                string tempFile = HConst.TemplatePath + "\\decryptFile.resx";

                //解密文件
                //System.Net.Security tSecurity = new Security();
                //tSecurity.DecryptDES(filepath, tempFile);
                File.Copy(filepath, tempFile);

                using (ResourceReader ResReader = new ResourceReader(tempFile))
                {
                    IDictionaryEnumerator tDictEnum = ResReader.GetEnumerator();
                    while (tDictEnum.MoveNext())
                    {
                        this.m_Hashtable.Add(tDictEnum.Key, tDictEnum.Value);
                    }

                    ResReader.Close();
                }

                //删除临时文件
                File.Delete(tempFile);
            }
        }
开发者ID:canneljls,项目名称:JLSAutoCode,代码行数:34,代码来源:ResourceHelper.cs

示例2: build_page_1

        private void build_page_1()
        {
            TextView tv1 = new TextView ();

            try
            {
                string rez = "Adeptus.Resources.resources";
                string key = "mystring1";
                string resourceType = "";
                byte[] resourceData;
                ResourceReader r = new ResourceReader(rez);
                r.GetResourceData (key, out resourceType, out resourceData);
                r.Close();
                System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                tv1.Buffer.Text = enc.GetString (resourceData);
            }
            catch (Exception exp)
            {
                tv1.Buffer.Text = exp.Message;
            }

            tv1.WrapMode = WrapMode.Word;
            tv1.Editable = false;

            this.AppendPage (tv1);
            this.SetPageTitle (tv1, "Introduction");
            this.SetPageType (tv1, AssistantPageType.Intro);
            this.SetPageComplete (tv1, true);
        }
开发者ID:sgtnasty,项目名称:battle,代码行数:29,代码来源:NewCharacterWindow.cs

示例3: ConstructorString

		public void ConstructorString () 
		{
			if (!File.Exists(m_ResourceFile)) {
				Fail ("Resource file is not where it should be:" + Path.Combine (Directory.GetCurrentDirectory(), m_ResourceFile));
			}
			ResourceReader r = new ResourceReader(m_ResourceFile);
			AssertNotNull ("ResourceReader", r);
			r.Close();
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:ResourceReaderTest.cs

示例4: Generate

        /// <summary>
        /// Generates localized Baml from translations
        /// </summary>
        /// <param name="options">LocBaml options</param>
        /// <param name="dictionaries">the translation dictionaries</param>
        internal static void Generate(LocBamlOptions options, TranslationDictionariesReader dictionaries)
        {
            // base on the input, we generate differently
            switch(options.InputType)
            {
                case FileType.BAML :
                {
                    // input file name
                    string bamlName = Path.GetFileName(options.Input);

                    // outpuf file name is Output dir + input file name
                    string outputFileName = GetOutputFileName(options);

                    // construct the full path
                    string fullPathOutput = Path.Combine(options.Output, outputFileName);

                    options.Write(StringLoader.Get("GenerateBaml", fullPathOutput));

                    using (Stream input = File.OpenRead(options.Input))
                    {
                        using (Stream output = new FileStream(fullPathOutput, FileMode.Create))
                        {
                            BamlLocalizationDictionary dictionary = dictionaries[bamlName];

                            // if it is null, just create an empty dictionary.
                            if (dictionary == null)
                                dictionary = new BamlLocalizationDictionary();

                            GenerateBamlStream(input, output, dictionary, options);
                        }
                    }

                    options.WriteLine(StringLoader.Get("Done"));
                    break;
                }
                case FileType.RESOURCES :
                {
                    string outputFileName = GetOutputFileName(options);
                    string fullPathOutput = Path.Combine(options.Output, outputFileName);

                    using (Stream input = File.OpenRead(options.Input))
                    {
                        using (Stream output = File.OpenWrite(fullPathOutput))
                        {
                            // create a Resource reader on the input;
                            IResourceReader reader = new ResourceReader(input);

                            // create a writer on the output;
                            IResourceWriter writer = new ResourceWriter(output);

                            GenerateResourceStream(
                                options,         // options
                                options.Input,   // resources name
                                reader,          // resource reader
                                writer,          // resource writer
                                dictionaries);   // translations

                            reader.Close();

                            // now generate and close
                            writer.Generate();
                            writer.Close();
                        }
                    }

                    options.WriteLine(StringLoader.Get("DoneGeneratingResource", outputFileName));
                    break;
                }
            case FileType.EXE:
                case FileType.DLL:
                {
                    GenerateAssembly(options, dictionaries);
                    break;
                }
                default:
                {
                    Debug.Assert(false, "Can't generate to this type");
                    break;
                }
            }
        }
开发者ID:jayawantsawant,项目名称:WPFSamples,代码行数:86,代码来源:ResourceGenerator.cs

示例5: DatabaseType

        /// <summary> Creates a new <code>DatabaseType</code>.
        /// 
        /// </summary>
        /// <param name="databaseType">the type of database
        /// </param>
        public DatabaseType(System.String databaseType)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            string resourceName = string.Format("AutopatchNet.{0}.resources", databaseType.ToLower());
            System.IO.Stream rs = assembly.GetManifestResourceStream(resourceName);
            if (rs == null)
            {
                throw new System.ArgumentException("Could not find SQL resources file for database '" + databaseType + "'; make sure that there is a '" + databaseType.ToLower() + ".resources' file in package.");
            }
            try
            {
                ResourceReader reader = new ResourceReader(rs);
                IDictionaryEnumerator en = reader.GetEnumerator();
                while(en.MoveNext())
                {
                    string sqlkey = (string)en.Key;
                    string sql = (string)en.Value;
                    properties.Add(sqlkey, sql);
                }

                reader.Close();
            }
            catch (System.IO.IOException e)
            {
                throw new System.ArgumentException("Could not read SQL resources file for database '" + databaseType + "'.", e);
            }
            finally
            {
                rs.Close();
            }

            this.databaseType = databaseType;
        }
开发者ID:easel,项目名称:autopatch,代码行数:38,代码来源:DatabaseType.cs

示例6: GetRessources

        // Retrieve key=>values from DLL ressource file
        private static Hashtable GetRessources(Assembly pluginAssembly)
        {
            string[] names = pluginAssembly.GetManifestResourceNames();
            Hashtable ressources = new Hashtable();
            foreach (string name in names)
            {
                if (name.EndsWith(".resources"))
                {
                    ResourceReader reader = null;

                    reader = new ResourceReader(pluginAssembly.GetManifestResourceStream(name));
                    IDictionaryEnumerator en = reader.GetEnumerator();

                    while (en.MoveNext())
                    {
                        // add key and value for plugin
                        ressources.Add(en.Key, en.Value);
                        //Console.WriteLine(en.Key + " => " + en.Value);
                    }
                    reader.Close();
                }
            }
            return ressources;
        }
开发者ID:HCSAnalyzer,项目名称:HCS-Analyzer,代码行数:25,代码来源:PluginDescriptor.cs

示例7: WriteResource

        private int WriteResource(IResource resource)
        {
            IEmbeddedResource embeddedResource = resource as IEmbeddedResource;
            if (embeddedResource != null)
            {
                try
                {
                    byte[] buffer = embeddedResource.Value;
                    string fileName = Path.Combine(_outputDirectory, resource.Name);

                    if (resource.Name.EndsWith(".resources"))
                    {
                        fileName = Path.ChangeExtension(fileName, ".resx");
                        using (MemoryStream ms = new MemoryStream(embeddedResource.Value))
                        {
                            ResXResourceWriter resxw = new ResXResourceWriter(fileName);
                            IResourceReader reader = new ResourceReader(ms);
                            IDictionaryEnumerator en = reader.GetEnumerator();
                            while (en.MoveNext())
                            {
                                resxw.AddResource(en.Key.ToString(), en.Value);
                            }
                            reader.Close();
                            resxw.Close();
                        }
                    }
                    else // other embedded resource
                    {
                        if (buffer != null)
                        {
                            using (Stream stream = File.Create(fileName))
                            {
                                stream.Write(buffer, 0, buffer.Length);
                            }
                        }
                    }
                    AddToProjectFiles(fileName);
                    return 0;
                }
                catch (Exception ex)
                {
                    WriteLine("Error in " + resource.Name + " : " + ex.Message);
                }
            }

            return WriteOtherResource(resource);
        }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:47,代码来源:FileDisassemblerHelper.cs

示例8: GetResourceData2

		public void GetResourceData2 ()
		{
			byte [] expected = new byte [] {
				0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
				0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
				0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x51, 0x53,
				0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x44, 0x72,
				0x61, 0x77, 0x69, 0x6E, 0x67, 0x2C, 0x20, 0x56,
				0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x32,
				0x2E, 0x30, 0x2E, 0x30, 0x2E, 0x30, 0x2C, 0x20,
				0x43, 0x75, 0x6C, 0x74, 0x75, 0x72, 0x65, 0x3D,
				0x6E, 0x65, 0x75, 0x74, 0x72, 0x61, 0x6C, 0x2C,
				0x20, 0x50, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x4B,
				0x65, 0x79, 0x54, 0x6F, 0x6B, 0x65, 0x6E, 0x3D,
				0x62, 0x30, 0x33, 0x66, 0x35, 0x66, 0x37, 0x66,
				0x31, 0x31, 0x64, 0x35, 0x30, 0x61, 0x33, 0x61,
				0x05, 0x01, 0x00, 0x00, 0x00, 0x13, 0x53, 0x79,
				0x73, 0x74, 0x65, 0x6D, 0x2E, 0x44, 0x72, 0x61,
				0x77, 0x69, 0x6E, 0x67, 0x2E, 0x53, 0x69, 0x7A,
				0x65, 0x02, 0x00, 0x00, 0x00, 0x05, 0x77, 0x69,
				0x64, 0x74, 0x68, 0x06, 0x68, 0x65, 0x69, 0x67,
				0x68, 0x74, 0x00, 0x00, 0x08, 0x08, 0x02, 0x00,
				0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00,
				0x00, 0x00, 0x0B};
			ResourceReader r = new ResourceReader ("Test/resources/bug81759.resources");
			string type;
			byte [] bytes;
			r.GetResourceData ("imageList.ImageSize", out type, out bytes);
			// Note that const should not be used here.
			Assert.AreEqual ("System.Drawing.Size, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", type, "#1");
			Assert.AreEqual (expected, bytes, "#2");
			r.Close ();
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:33,代码来源:ResourceReaderTest.cs

示例9: GetResourceDataNullName

		public void GetResourceDataNullName ()
		{
			ResourceReader r = new ResourceReader ("Test/resources/StreamTest.resources");
			string type;
			byte [] bytes;

			try {
				r.GetResourceData (null, out type, out bytes);
				Assert.Fail ("#1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.IsNotNull (ex.ParamName, "#5");
				Assert.AreEqual ("resourceName", ex.ParamName, "#6");
			} finally {
				r.Close ();
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:19,代码来源:ResourceReaderTest.cs

示例10: AddResource_Stream_Default

		public void AddResource_Stream_Default ()
		{
			MemoryStream stream = new MemoryStream ();
			byte [] buff = Encoding.Unicode.GetBytes ("Miguel");
			stream.Write (buff, 0, buff.Length);
			stream.Position = 0;

			ResourceWriter rw = new ResourceWriter ("Test/resources/AddResource_Stream.resources");
			rw.AddResource ("Name", (object)stream);
			rw.Close ();

			ResourceReader rr = new ResourceReader ("Test/resources/AddResource_Stream.resources");
			IDictionaryEnumerator enumerator = rr.GetEnumerator ();

			// Get the first element
			Assert.AreEqual (true, enumerator.MoveNext (), "#A0");

			DictionaryEntry de = enumerator.Entry;
			Assert.AreEqual ("Name", enumerator.Key, "#A1");
			Stream result_stream = de.Value as Stream;
			Assert.AreEqual (true, result_stream != null, "#A2");

			// Get the data and compare
			byte [] result_buff = new byte [result_stream.Length];
			result_stream.Read (result_buff, 0, result_buff.Length);
			string string_res = Encoding.Unicode.GetString (result_buff);
			Assert.AreEqual ("Miguel", string_res, "#A3");

			rr.Close ();
			stream.Close ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:31,代码来源:ResourceWriterTest.cs

示例11: LoadFile

		public void LoadFile(FileName filename, Stream stream)
		{
			resources.Clear();
			metadata.Clear();
			switch (Path.GetExtension(filename).ToLowerInvariant()) {
				case ".resx":
					ResXResourceReader rx = new ResXResourceReader(stream);
					ITypeResolutionService typeResolver = null;
					rx.BasePath = Path.GetDirectoryName(filename);
					rx.UseResXDataNodes = true;
					IDictionaryEnumerator n = rx.GetEnumerator();
					while (n.MoveNext()) {
						if (!resources.ContainsKey(n.Key.ToString())) {
							ResXDataNode node = (ResXDataNode)n.Value;
							resources.Add(n.Key.ToString(), new ResourceItem(node.Name, node.GetValue(typeResolver), node.Comment));
						}
					}
					
					n = rx.GetMetadataEnumerator();
					while (n.MoveNext()) {
						if (!metadata.ContainsKey(n.Key.ToString())) {
							ResXDataNode node = (ResXDataNode)n.Value;
							metadata.Add(n.Key.ToString(), new ResourceItem(node.Name, node.GetValue(typeResolver)));
						}
					}
					
					rx.Close();
					break;
				case ".resources":
					ResourceReader rr=null;
					try {
						rr = new ResourceReader(stream);
						foreach (DictionaryEntry entry in rr) {
							if (!resources.ContainsKey(entry.Key.ToString()))
								resources.Add(entry.Key.ToString(), new ResourceItem(entry.Key.ToString(), entry.Value));
						}
					}
					finally {
						if (rr != null) {
							rr.Close();
						}
					}
					break;
			}
			InitializeListView();
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:46,代码来源:ResourceList.cs

示例12: WriteResource

		private int WriteResource(IResource resource)
		{
			IEmbeddedResource embeddedResource = resource as IEmbeddedResource;
			if (embeddedResource != null)
			{
				try 
				{
					byte[] buffer = embeddedResource.Value;
                    string fileName = Path.Combine(_outputDirectory, GetResourceFileName(resource));
					
					if (resource.Name.EndsWith(".resources"))
					{
						fileName = Path.ChangeExtension(fileName, ".resx");
						using (MemoryStream ms = new MemoryStream(embeddedResource.Value))
						{
							ResXResourceWriter resxw = new ResXResourceWriter(fileName);
							IResourceReader reader = new ResourceReader(ms);
							IDictionaryEnumerator en = reader.GetEnumerator();
							while (en.MoveNext()) 
							{
                                bool handled = false;
                                
                                if (en.Value != null)
                                {
                                    Type type = en.Value.GetType();
                                    if (type.FullName.EndsWith("Stream"))
                                    {
                                        Stream s = en.Value as Stream;
                                        if (s != null)
                                        {
                                            byte[] bytes = new byte[s.Length];
                                            if (s.CanSeek) s.Seek(0, SeekOrigin.Begin);
                                            s.Read(bytes, 0, bytes.Length);
                                            resxw.AddResource(en.Key.ToString(), new MemoryStream(bytes));
                                            handled = true;
                                        }
                                    }
                                }
                                if (handled) continue;

								resxw.AddResource(en.Key.ToString(), en.Value);
							}
							reader.Close();
							resxw.Close();
						}
					}
					else // other embedded resource
					{
						if (buffer != null)
						{
							using (Stream stream = File.Create(fileName))
							{
								stream.Write(buffer, 0, buffer.Length);
							}
						}
					}
					AddToProjectFiles(fileName);
					return 0;
				}
				catch (Exception ex)
				{
					WriteLine("Error in " + resource.Name + " : " + ex.Message);
				}
			}

			return WriteOtherResource(resource);
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:67,代码来源:FileDisassemblerHelper.cs

示例13: Stream

		public void Stream ()
		{
			Stream stream = new FileStream (m_ResourceFile, FileMode.Open);
			ResourceReader r = new ResourceReader (stream);
			AssertNotNull ("ResourceReader", r);
			r.Close();
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:ResourceReaderTest.cs

示例14: accessUpdatePackage

		/// <summary>
		/// Bietet Zugriff auf die Resourcen in einem Updatepaket.
		/// </summary>
		/// <param name="packagePath">Der Pfad zu dem Updatepaket.</param>
		/// <param name="resID">Die ID der Resource die ausgelesen werden soll.</param>
		/// <returns>Gibt die Resource in Form eines ByteArrays zurück.</returns>
		protected byte[] accessUpdatePackage(string packagePath, string resID) {
			var resReader = new ResourceReader(packagePath);
			try {
				byte[] outData;
				string outType;
				resReader.GetResourceData(resID, out outType, out outData);
				return outData;
			}
			finally {
				resReader.Close();
			}
		}
开发者ID:hbaes,项目名称:updateSystem.NET,代码行数:18,代码来源:applyUpdateBase.cs

示例15: Main

        static void Main(string[] args)
        {
            if(args.Length !=1)
            {
                Console.Write("[-] Error\nnetZunpacker.exe packedfile.exe\nPress Enter to Exit");
                Console.Read();
                return;
            }
            try
            {
                String path;

                if (!Path.IsPathRooted(args[0]))
                {
                    path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + args[0];
                }
                else
                {
                    path = args[0];
                }
                Assembly a = Assembly.LoadFile(path);
                ResourceManager rm = new ResourceManager("app", a);

                String[] resourceNames = a.GetManifestResourceNames();
                int p;
                foreach (string resName in resourceNames)
                {
                    Stream resStream = a.GetManifestResourceStream(resName);
                    var rr = new ResourceReader(resStream);
                    IDictionaryEnumerator dict = rr.GetEnumerator();
                    int ctr = 0;
                    while (dict.MoveNext())
                    {
                        ctr++;
                        //Console.WriteLine("\n{0:00}: {1} = {2}", ctr, dict.Key, dict.Value);
                        if (((byte[])rm.GetObject(dict.Key.ToString()))[0] == 120)
                        {
                            Decoder((byte[])rm.GetObject(dict.Key.ToString()), dict.Key.ToString());
                        }
                    }

                    rr.Close();

                }
            }
            catch(Exception e)
            {
                String s = e.Message;
                Console.Write(s);
            }
        }
开发者ID:0x410c,项目名称:netZUnpacker,代码行数:51,代码来源:Program.cs


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