Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

File reader

Alexanderius edited this page Jun 30, 2019 · 3 revisions

File reader

FileReader is a class for loading localizable text files from data folder specified in Simplify.Web configuration.

  • File name should contain language prefix, for example, if you loading file Menu.xml, then it should be named Menu.{language}.xml in data folder;
  • File will be loaded for current language, if current language file does not exist, then the file for default language will be loaded.

Example

public class MyController : Controller
{
    public override ControllerResponse Invoke()
    {
        // It loads Menu.en.xml file
        var myData = FileReader.LoadXDocument("Menu.xml");
        ...
    }
}

If you are loading XML files via LoadXDocument then you can specify file name without extension

public class MyController : Controller
{
    public override ControllerResponse Invoke()
    {
        // It loads Menu.en.xml file
        var myData = FileReader.LoadXDocument("Menu");
        ...
    }
}

And just some text files can be loaded (for example, HTML file)

public class MyController : Controller
{
    public override ControllerResponse Invoke()
    {
        // It loads Menu.en.xml file
        var myData = FileReader.LoadTextDocument("SomeFile.html");
        ...
    }
}

Files can be cached in memory, that should be specified by the second parameter

...
FileReader.LoadTextDocument("SomeFile.html", true);
FileReader.LoadXDocument("Menu", true);
...

Files cache can be globally disabled via Simplify.Web configuration.

<< Previous page Next page >>

Clone this wiki locally