/// <summary> /// Parses TextResources on the specified folder or file at path in a Resources folder /// The parsed config is merged into the already loaded tree /// </summary> /// <param name="resourcePath">The path to parse resources at</param> /// <param name="parser">The type of parser to use</param> /// <returns>This builder instance</returns> public ConfigBuilder ParseTextResourceFiles(string resourcePath, ITextConfigParser parser) { CheckBuildState(); var configAssets = Resources.LoadAll <TextAsset>(resourcePath); ParseAndLoadConfigs(configAssets.Select(x => x.text), parser); return(this); }
private void ParseAndLoadConfigs(IEnumerable <string> contents, ITextConfigParser parser) { contents .Select(parser.ParseText) .OrderByDescending(x => { if (x.TryReadPath("meta", "priority") is int priority) { return(priority); } return(0); }).ToList().ForEach(map => _configMap = _configMap.Merge(map)); }
/// <summary> /// Parses the given string /// The parsed config is merged into the already loaded tree /// </summary> /// <param name="str">The string to parse</param> /// <param name="parser">The type of parser to use</param> /// <returns>This builder instance</returns> public ConfigBuilder ParseString(string str, ITextConfigParser parser) { CheckBuildState(); ParseAndLoadConfigs(new[] { str }, parser); return(this); }