예제 #1
0
    string LocalizedName(string name)
    {
        var desktopIni = new SimpleIniFile(Path.Combine(folder, "desktop.ini"));
        var localized  = desktopIni.Read("LocalizedFileNames", name, string.Empty);

        if (localized == string.Empty)
        {
            return(Path.GetFileNameWithoutExtension(name));
        }
        if (localized[0] != '@')
        {
            return(localized);
        }
        try
        {
            return(Utils.ExtractStringFromDLL(localized));
        }
        catch (SystemException)
        {
            // 资源文件可能不存在,回退到文件名
            return(Path.GetFileNameWithoutExtension(name));
        }
    }
예제 #2
0
    public void GetNonExistValue()
    {
        var file = new SimpleIniFile("Resources/Config.ini");

        Assert.AreEqual("s", file.Read("server", "non-exists", "s"));
    }
예제 #3
0
    public void GetValue()
    {
        var file = new SimpleIniFile("Resources/Config.ini");

        Assert.AreEqual("hello world", file.Read("server", "key", null));
    }
예제 #4
0
    public void GetNonExistFile()
    {
        var file = new SimpleIniFile("non-exists.ini");

        Assert.AreEqual("s", file.Read("server", "non-exists", "s"));
    }