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


C# ResourceInfo类代码示例

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


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

示例1: GetFileInfo

 public static void GetFileInfo(string fileName)
 {
     ResourceInfo model = new ResourceInfo();            
     model.Md5 = MD5Hash(fileName);
     if (ResourceInfo.FindAllByName(ResourceInfo._.Md5, model.Md5, "", 0, 0).Count <1)
     {
         model.PublishingCompany = "暂无";
         FileInfo fi = new FileInfo(fileName);
         model.Keywords = fi.Name;
         model.Author = "暂无";
         model.BigCategory = "暂无分类";
         model.SmallCategory = "暂无分类";
         model.Source = "网络";
         model.ContentIntroduce = "暂无介绍";
         model.Format = fi.Extension.Replace(".", "");
         model.ISBN = string.Empty;
         model.PublishingDate = DateTime.Now;
         model.Remark = string.Empty;
         model.ResourceName = fi.Name;
         model.ResourceScore = 7;
         model.Size = (int)(fi.Length / 1024);//Kb
         model.StorageLocation = fileName.Substring(1, fileName.Length - 1);//只存储相对位置,把盘符去掉               
         model.Insert();
     }
 }
开发者ID:windygu,项目名称:asxinyunet,代码行数:25,代码来源:ResourceHelper.cs

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

示例3: btnOK_Click

    /// <summary>
    /// Handles btnOK's OnClick event - Save resource info.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // finds whether required fields are not empty
        string result = new Validator().NotEmpty(tbModuleDisplayName.Text.Trim(), GetString("Administration-Module_New.ErrorEmptyModuleDisplayName")).NotEmpty(tbModuleCodeName.Text, GetString("Administration-Module_New.ErrorEmptyModuleCodeName"))
            .IsCodeName(tbModuleCodeName.Text, GetString("general.invalidcodename"))
            .Result;

        if (result == "")
        {
            // finds if the resource code name is unique
            if (ResourceInfoProvider.GetResourceInfo(tbModuleCodeName.Text) == null)
            {
                //Save resource info
                ResourceInfo ri = new ResourceInfo();
                ri.ResourceName = tbModuleCodeName.Text;
                ri.ResourceDisplayName = tbModuleDisplayName.Text.Trim();

                ResourceInfoProvider.SetResourceInfo(ri);

                URLHelper.Redirect("Module_Edit_Frameset.aspx?moduleID=" + ri.ResourceId + "&saved=1");
            }
            else
            {
                // Show error message
                ShowError(GetString("Administration-Module_New.UniqueCodeName"));
            }
        }
        else
        {
            // Show error message
            ShowError(result);
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:36,代码来源:Module_New.aspx.cs

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

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

示例6: GetResourceInfo

        public ResourceInfo GetResourceInfo(string resourcePath)
        {
            var fullPath = this.FindFullPath(resourcePath);
            var info = new ResourceInfo { FullPath = fullPath };

            if (!fullPath.StartsWith(this.rootPath))
            {
                info.Type = ResourceType.NotFound;
            }
            else if (File.Exists(fullPath))
            {
                info.Type = ResourceType.File;
                info.FileSystemInfo = new FileInfo(fullPath);
            }
            else if (Directory.Exists(fullPath))
            {
                info.Type = ResourceType.Directory;
                info.FileSystemInfo = new DirectoryInfo(fullPath);
            }
            else
            {
                info.Type = ResourceType.NotFound;
                info.FileSystemInfo = fullPath.EndsWith(Path.DirectorySeparatorChar.ToString())
                    ? (FileSystemInfo)new DirectoryInfo(fullPath)
                    : new FileInfo(fullPath);
            }

            if (info.Type != ResourceType.NotFound)
            {
                info.LocalPath = fullPath.Substring(this.rootPath.Length).Replace(@"\", @"/");
                info.Name = info.FileSystemInfo.Name;
            }

            return info;
        }
开发者ID:cwattengard,项目名称:WebGitNet,代码行数:35,代码来源:FileManager.cs

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

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

示例9: btnOK_Click

    /// <summary>
    /// Handles btnOK's OnClick event - Update resource info.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Finds whether required fields are not empty
        string result = new Validator().NotEmpty(tbModuleDisplayName.Text.Trim(), GetString("Administration-Module_New.ErrorEmptyModuleDisplayName")).NotEmpty(tbModuleCodeName.Text, GetString("Administration-Module_New.ErrorEmptyModuleCodeName"))
            .IsCodeName(tbModuleCodeName.Text, GetString("general.invalidcodename"))
            .Result;

        if (result == "")
        {
            // Check unique name
            ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(tbModuleCodeName.Text);
            if ((ri == null) || (ri.ResourceId == moduleId))
            {
                // Get object
                if (ri == null)
                {
                    ri = ResourceInfoProvider.GetResourceInfo(moduleId);
                    if (ri == null)
                    {
                        ri = new ResourceInfo();
                    }
                }

                // Update resource info
                ri.ResourceId = moduleId;
                ri.ResourceName = tbModuleCodeName.Text;
                ri.ResourceDescription = txtModuleDescription.Text.Trim();
                ri.ResourceDisplayName = tbModuleDisplayName.Text.Trim();

                ResourceInfoProvider.SetResourceInfo(ri);

                // Update root UIElementInfo of the module
                UIElementInfo elemInfo = UIElementInfoProvider.GetRootUIElementInfo(ri.ResourceId);
                if (elemInfo == null)
                {
                    elemInfo = new UIElementInfo();
                }
                elemInfo.ElementResourceID = ri.ResourceId;
                elemInfo.ElementDisplayName = ri.ResourceDisplayName;
                elemInfo.ElementName = ri.ResourceName.ToLowerCSafe().Replace(".", "");
                elemInfo.ElementIsCustom = false;
                UIElementInfoProvider.SetUIElementInfo(elemInfo);

                // Show message
                ShowChangesSaved();
            }
            else
            {
                // Show error message
                ShowError(GetString("Administration-Module_New.UniqueCodeName"));
            }
        }
        else
        {
            // Show error message
            ShowError(result);
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:61,代码来源:Module_Edit_General.aspx.cs

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

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

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

示例13: CopyFileProperties

        private bool CopyFileProperties(string targetFile, string sourceFile)
        {
            VersionResource targetVersion;

            using (var sourceInfo = new ResourceInfo())
            {
                using (var targetInfo = new ResourceInfo())
                {
                    try
                    {
                        sourceInfo.Load(sourceFile);
                        targetInfo.Load(targetFile);
                    }
                    catch (Win32Exception)
                    {
                        if (ContinueOnError)
                            return true;
                        throw;
                    }

                    VersionResource sourceVersion = sourceInfo.OfType<VersionResource>().FirstOrDefault();

                    targetVersion = targetInfo.OfType<VersionResource>().FirstOrDefault();

                    var valuesToCopy = new[] { "FileDescription", "InternalName" };

                    StringTable sourceDefaultStringTable = ((StringFileInfo)(sourceVersion["StringFileInfo"])).Default;
                    StringTable targetDefaultStringTable = ((StringFileInfo)(targetVersion["StringFileInfo"])).Default;

                    foreach (var value in valuesToCopy)
                    {
                        targetDefaultStringTable.Strings[value].Value = sourceDefaultStringTable.Strings[value].Value;
                    }
                }
            }

            try
            {
                targetVersion.SaveTo(targetFile);
            }
            catch (Win32Exception)
            {
                if (ContinueOnError)
                    return true;
                throw;
            }

            return true;
        }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:49,代码来源:CopyResourcesTask.cs

示例14: CheckAccess

        public static bool CheckAccess(List<RoleDefinition> roleDefinitions, List<RoleAssignment> roleAssigments, string user, string resource, string action)
        {
            List<Claim> claims = new List<Claim>(1);
            claims.Add(new Claim("oid", user));
            ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(new ClaimsIdentity(claims));

            ResourceInfo resourceInfo = new ResourceInfo("/" + resource);
            ActionInfo actionInfo = new ActionInfo("/"+ resource + "/" + action);            
            
            DefaultPolicyProvider policyProvider = new DefaultPolicyProvider(roleDefinitions, roleAssigments);

            AadAuthorizationEngine engine = new AadAuthorizationEngine(policyProvider);

            return engine.CheckAccess(claimsPrincipal, resourceInfo, actionInfo);
        }
开发者ID:wstcilzm,项目名称:CAT_ITALite,代码行数:15,代码来源:InprocFlagProvider.cs

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


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