2 using System.Collections;
3 using System.Collections.Generic;
11 public IReadOnlyList<LocalizedString>
Substrings => substrings;
13 private class SubstringList : IReadOnlyList<LocalizedString>
15 public SubstringList(
LStringSplitter splitter) { this.splitter = splitter; }
18 private readonly List<LocalizedString> underlyingList =
new List<LocalizedString>();
20 public List<LocalizedString> UnderlyingList
24 splitter.UpdateSubstrings();
25 return underlyingList;
29 public IEnumerator<LocalizedString> GetEnumerator() => UnderlyingList.GetEnumerator();
31 IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
33 public int Count => UnderlyingList.Count;
38 private readonly SubstringList substrings;
39 private readonly
char[] separators;
41 private string[] substrValues;
43 private string cachedOriginal;
45 public bool Loaded => originalString.Loaded;
49 originalString = input;
50 substrings =
new SubstringList(
this);
51 substrValues = Array.Empty<
string>();
52 this.separators = separators;
56 private void UpdateSubstrings()
58 if (originalString.Value != cachedOriginal)
60 cachedOriginal = originalString.Value;
61 substrValues = cachedOriginal.Split(separators);
62 substrings.UnderlyingList.Clear();
63 substrings.UnderlyingList.AddRange(Enumerable.Range(0, substrValues.Length).Select(i =>
new SplitLString(
this, i) as
LocalizedString));
70 return substrValues[index];
76 private bool loaded =
false;
78 private readonly
int index;
82 this.splitter = splitter; this.index = index;
85 public override bool Loaded => loaded && splitter.Loaded;
LStringSplitter(LocalizedString input, params char[] separators)
string GetValue(int index)
IReadOnlyList< LocalizedString > Substrings
override void RetrieveValue()
SplitLString(LStringSplitter splitter, int index)