Hishop.Components.Validation/ResourceLoader.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

namespace Hishop.Components.Validation
{
    using System;
    using System.Reflection;
    using System.Resources;

    public static class ResourceLoader
    {
        private static string LoadAssemblyString(Assembly asm, string baseName, string resourceName)
        {
            try
            {
                ResourceManager manager = new ResourceManager(baseName, asm);
                return manager.GetString(resourceName);
            }
            catch (MissingManifestResourceException)
            {
            }
            return null;
        }

        public static string LoadString(string baseName, string resourceName)
        {
            return LoadString(baseName, resourceName, Assembly.GetCallingAssembly());
        }

        public static string LoadString(string baseName, string resourceName, Assembly asm)
        {
            if (string.IsNullOrEmpty(baseName))
            {
                throw new ArgumentNullException("baseName");
            }
            if (string.IsNullOrEmpty(resourceName))
            {
                throw new ArgumentNullException("resourceName");
            }
            string str = null;
            if (asm != null)
            {
                str = SearchForResource(asm, baseName, resourceName);
            }
            if (str == null)
            {
                str = LoadAssemblyString(Assembly.GetExecutingAssembly(), baseName, resourceName);
            }
            if (str == null)
            {
                return string.Empty;
            }
            return str;
        }

        private static string SearchForResource(Assembly asm, string baseName, string resourceName)
        {
            foreach (string str in asm.GetManifestResourceNames())
            {
                string str2 = (string) str.Clone();
                if (str.EndsWith(".resources"))
                {
                    str2 = str.Replace(".resources", string.Empty);
后面还有 12 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。