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


C# ResourceInfo.Load方法代码示例

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


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

示例1: TestSaveStringResource

 public void TestSaveStringResource()
 {
     Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
     string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));
     string sourceFilename = Path.Combine(uriPath, @"Binaries\gutils.dll");
     string targetFilename = Path.Combine(Path.GetTempPath(), "testSaveStringResource.dll");
     File.Copy(sourceFilename, targetFilename, true);
     // a new resource
     StringResource sr = new StringResource();
     sr.Name = new ResourceId(StringResource.GetBlockId(1256));
     sr[1256] = Guid.NewGuid().ToString();
     sr.SaveTo(targetFilename);
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(targetFilename);
         Assert.AreEqual(2, ri[Kernel32.ResourceTypes.RT_STRING].Count);
         Assert.AreEqual(StringResource.GetBlockId(1256), ri[Kernel32.ResourceTypes.RT_STRING][1].Name.Id.ToInt32());
         Assert.AreEqual(sr[1256], ((StringResource) ri[Kernel32.ResourceTypes.RT_STRING][1])[1256]);
         foreach (StringResource rc in ri[Kernel32.ResourceTypes.RT_STRING])
         {
             Console.WriteLine("StringResource: {0}, {1}", rc.Name, rc.TypeName);
             DumpResource.Dump(rc);
         }
     }
 }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:25,代码来源:StringResourceTests.cs

示例2: TestAddDialogResource

 public void TestAddDialogResource()
 {
     Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
     string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));
     string gutilsdll = Path.Combine(uriPath, @"Binaries\gutils.dll");
     int dialogsBefore = 0;
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(gutilsdll);
         dialogsBefore = ri.Resources[new ResourceId(Kernel32.ResourceTypes.RT_DIALOG)].Count;
     }
     string targetFilename = Path.Combine(Path.GetTempPath(), "testAddDialogResource.dll");
     File.Copy(gutilsdll, targetFilename, true);
     // copy an existing dialog inside gutils.dll
     DialogResource sourceDialog = new DialogResource();
     sourceDialog.Name = new ResourceId("GABRTDLG");
     sourceDialog.LoadFrom(gutilsdll);
     sourceDialog.Name = new ResourceId("NEWGABRTDLG");
     Console.WriteLine(targetFilename);
     sourceDialog.SaveTo(targetFilename);
     // check that the dialog was written
     sourceDialog.LoadFrom(targetFilename);
     DumpResource.Dump(sourceDialog);
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(targetFilename);
         int dialogsAfter = ri.Resources[new ResourceId(Kernel32.ResourceTypes.RT_DIALOG)].Count;
         DumpResource.Dump(ri);
         Assert.AreEqual(dialogsBefore + 1, dialogsAfter);
     }
 }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:31,代码来源:DialogResourceTests.cs

示例3: TestCustom

 public void TestCustom()
 {
     Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
     string filename = Path.Combine(Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath)), "Binaries\\custom.exe");
     Assert.IsTrue(File.Exists(filename));
     using (ResourceInfo vi = new ResourceInfo())
     {
         vi.Load(filename);
         // version resources (well-known)
         List<Resource> versionResources = vi[Kernel32.ResourceTypes.RT_VERSION]; // RT_VERSION
         Assert.IsNotNull(versionResources);
         Assert.AreEqual(1, versionResources.Count);
         Resource versionResource = versionResources[0];
         Assert.AreEqual(versionResource.Name.ToString(), "1");
         Assert.AreEqual(versionResource.Type.ToString(), "16");
         // custom resources
         List<Resource> customResources = vi["CUSTOM"];
         Assert.IsNotNull(customResources);
         Assert.AreEqual(1, customResources.Count);
         Resource customResource = customResources[0];
         // check whether the properties are string representations
         Assert.AreEqual(customResource.Name.ToString(), "RES_CONFIGURATION");
         Assert.AreEqual(customResource.Type.ToString(), "CUSTOM");
     }
 }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:25,代码来源:ResourceTests.cs

示例4: FindSmallestBinaryWithResources

        //[Test]
        //public void FindSmallestBinaryWithResources()
        //{
        //    FindSmallestBinaryWithResources(
        //        Environment.SystemDirectory,
        //        "*.exe", 
        //        Kernel32.ResourceTypes.RT_MENU);
        //}

        private void FindSmallestBinaryWithResources(
            string path, string ext, Kernel32.ResourceTypes rt)
        {
            long smallest = 0;
            string[] files = Directory.GetFiles(path, ext);
            foreach (string filename in files)
            {
                try
                {
                    using (ResourceInfo ri = new ResourceInfo())
                    {
                        ri.Load(filename);

                        if (!ri.Resources.ContainsKey(new ResourceId(rt)))
                            continue;

                        FileInfo fi = new FileInfo(filename);
                        //if (fi.Length < smallest || smallest == 0)
                        //{
                            Console.WriteLine("{0} {1}", filename, new FileInfo(filename).Length);
                            smallest = fi.Length;
                        // }
                        break;
                    }
                }
                catch
                {
                }
            }
        }
开发者ID:mcintosh,项目名称:resourcelib,代码行数:39,代码来源:ResourceInfoTests.cs

示例5: TestLoad

        public void TestLoad()
        {
            Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
            string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));

            string[] files = 
            {
                // Path.Combine(Environment.SystemDirectory, "regedt32.exe"),
                // Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "explorer.exe"),
                Path.Combine(uriPath, "Binaries\\gutils.dll"),
                Path.Combine(uriPath, "Binaries\\6to4svc.dll"),
                Path.Combine(uriPath, "Binaries\\custom.exe"),
            };

            foreach (string filename in files)
            {
                Console.WriteLine(filename);
                Assert.IsTrue(File.Exists(filename));
                using (ResourceInfo vi = new ResourceInfo())
                {
                    vi.Load(filename);
                    DumpResource.Dump(vi);
                }
            }
        }
开发者ID:mcintosh,项目名称:resourcelib,代码行数:25,代码来源:ResourceInfoTests.cs

示例6: TestLoad

 public void TestLoad(string filename)
 {
     Console.WriteLine(filename);
     Assert.IsTrue(File.Exists(filename));
     using (ResourceInfo vi = new ResourceInfo())
     {
         vi.Load(filename);
         DumpResource.Dump(vi);
     }
 }
开发者ID:dblock,项目名称:resourcelib,代码行数:10,代码来源:ResourceInfoTests.cs

示例7: TestLoadMenuResourcesEx

 public void TestLoadMenuResourcesEx()
 {
     string filename = Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "explorer.exe");
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(filename);
         foreach (MenuResource rc in ri[Kernel32.ResourceTypes.RT_MENU])
         {
             Console.WriteLine("MenuResource: {0}, {1}", rc.Name, rc.TypeName);
             DumpResource.Dump(rc);
         }
     }
 }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:13,代码来源:MenuResourceTests.cs

示例8: TestLoadBitmapResources

 public void TestLoadBitmapResources()
 {
     string filename = Path.Combine(Environment.SystemDirectory, "msftedit.dll");
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(filename);
         foreach(BitmapResource rc in ri[Kernel32.ResourceTypes.RT_BITMAP])
         {
             Console.WriteLine("BitmapResource: {0}, {1}", rc.Name, rc.TypeName);
             Console.WriteLine("DIB: {0}x{1} {2}", rc.Bitmap.Image.Width, rc.Bitmap.Image.Height, 
                 rc.Bitmap.Header.PixelFormatString);
         }
     }
 }
开发者ID:xingkongtianyu,项目名称:Apex-Crypter,代码行数:14,代码来源:BitmapResourceTests.cs

示例9: TestLoadMenuResourcesEx

 public void TestLoadMenuResourcesEx()
 {
     Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
     string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));
     string filename = Path.Combine(uriPath, @"Binaries\custom.exe");
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(filename);
         foreach (MenuResource rc in ri[Kernel32.ResourceTypes.RT_MENU])
         {
             Console.WriteLine("MenuResource: {0}, {1}", rc.Name, rc.TypeName);
             DumpResource.Dump(rc);
         }
     }
 }
开发者ID:redwyre,项目名称:resourcelib,代码行数:15,代码来源:MenuResourceTests.cs

示例10: CopyResources

        /// <summary>
        ///     A
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        public static void CopyResources(this FileInfo target, FileInfo source) {
            if (File.Exists(target.FullName) == false) throw new FileNotFoundException("Couldnt find the given file", target.FullName);
            if (File.Exists(source.FullName) == false) throw new FileNotFoundException("Couldnt find the given file", source.FullName);

            var ri = new ResourceInfo();
            ri.Load(source.FullName);
            foreach (var res in ri) {
                try {
                    res.SaveTo(target.FullName);
                } catch { //copy what ever it can. skip errory ones.
                }
            }
            ri.Dispose();
            
        }
开发者ID:Nucs,项目名称:nlib,代码行数:20,代码来源:FileInfoHelper.cs

示例11: SampleEnumerateResources

 public void SampleEnumerateResources(string filename)
 {
     using (ResourceInfo vi = new ResourceInfo())
     {
         vi.Load(filename);
         foreach (ResourceId id in vi.ResourceTypes)
         {
             Console.WriteLine(id);
             foreach (Resource resource in vi.Resources[id])
             {
                 Console.WriteLine("{0} ({1}) - {2} byte(s)",
                     resource.Name, resource.Language, resource.Size);
             }
         }
     }
 }
开发者ID:dblock,项目名称:resourcelib,代码行数:16,代码来源:ResourceTests.cs

示例12: TestLoadStringResources

 public void TestLoadStringResources()
 {
     Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
     string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));
     string filename = Path.Combine(uriPath, @"Binaries\gutils.dll");
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(filename);
         Assert.AreEqual(1, ri[Kernel32.ResourceTypes.RT_STRING].Count);
         foreach (StringResource rc in ri[Kernel32.ResourceTypes.RT_STRING])
         {
             Console.WriteLine("StringResource: {0}, {1}", rc.Name, rc.TypeName);
             DumpResource.Dump(rc);
         }
     }
 }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:16,代码来源:StringResourceTests.cs

示例13: TestControlLicenseResources

 public void TestControlLicenseResources()
 {
     InstallerLinkerArguments args = new InstallerLinkerArguments();
     string licenseFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".txt");
     try
     {
         Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
         string binPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));
         ConfigFile configFile = new ConfigFile();
         SetupConfiguration setupConfiguration = new SetupConfiguration();
         configFile.Children.Add(setupConfiguration);
         ControlLicense license = new ControlLicense();
         license.LicenseFile = licenseFile;
         Console.WriteLine("Writing '{0}'", license.LicenseFile);
         File.WriteAllText(license.LicenseFile, "Lorem ipsum");
         setupConfiguration.Children.Add(license);
         args.config = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
         Console.WriteLine("Writing '{0}'", args.config);
         configFile.SaveAs(args.config);
         args.output = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe");
         Console.WriteLine("Linking '{0}'", args.output);
         args.template = dotNetInstallerExeUtils.Executable;
         InstallerLib.InstallerLinker.CreateInstaller(args);
         // check that the linker generated output
         Assert.IsTrue(File.Exists(args.output));
         Assert.IsTrue(new FileInfo(args.output).Length > 0);
         using (ResourceInfo ri = new ResourceInfo())
         {
             ri.Load(args.output);
             Assert.IsTrue(ri.Resources.ContainsKey(new ResourceId("CUSTOM")));
             List<Resource> custom = ri.Resources[new ResourceId("CUSTOM")];
             Assert.AreEqual("RES_BANNER", custom[0].Name.Name);
             Assert.AreEqual("RES_CONFIGURATION", custom[1].Name.ToString());
             Assert.AreEqual("RES_LICENSE", custom[2].Name.ToString());
         }
     }
     finally
     {
         if (File.Exists(licenseFile))
             File.Delete(licenseFile);
         if (File.Exists(args.config))
             File.Delete(args.config);
         if (File.Exists(args.output))
             File.Delete(args.output);
     }
 }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:46,代码来源:InstallerLinkerUnitTests.cs

示例14: TestLoadAcceleratorResources

 public void TestLoadAcceleratorResources()
 {
     Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
     string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));
     string filename = Path.Combine(uriPath, @"Binaries\custom.exe");
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(filename);
         Assert.AreEqual(2, ri[Kernel32.ResourceTypes.RT_ACCELERATOR].Count);
         foreach (AcceleratorResource rc in ri[Kernel32.ResourceTypes.RT_ACCELERATOR])
         {
             Console.WriteLine("AcceleratorResource: {0}, {1}", rc.Name, rc.TypeName);
             DumpResource.Dump(rc);
         }
         Assert.AreEqual(109, ri[Kernel32.ResourceTypes.RT_ACCELERATOR][0].Name.Id.ToInt64());
         Assert.AreEqual(110, ri[Kernel32.ResourceTypes.RT_ACCELERATOR][1].Name.Id.ToInt64());
     }
 }
开发者ID:xingkongtianyu,项目名称:Apex-Crypter,代码行数:18,代码来源:AcceleratorResourceTests.cs

示例15: TestReadWriteMenuMixedResourceBytes

 public void TestReadWriteMenuMixedResourceBytes()
 {
     string filename = Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "explorer.exe");
     using (ResourceInfo ri = new ResourceInfo())
     {
         ri.Load(filename);
         foreach (MenuResource rc in ri[Kernel32.ResourceTypes.RT_MENU])
         {
             GenericResource genericResource = new GenericResource(
                 rc.Type,
                 rc.Name,
                 rc.Language);
             genericResource.LoadFrom(filename);
             byte[] data = rc.WriteAndGetBytes();
             ByteUtils.CompareBytes(genericResource.Data, data);
         }
     }
 }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:18,代码来源:MenuResourceTests.cs


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