Exemplo n.º 1
0
    async Task <string> ISimpleConfig.GetStringAsync(string key)
    {
        string path = await _locator.GetConfigLocationAsync(); //this is intended to get from local disk;

        if (ff.FileExists(path) == false)
        {
            throw new CustomBasicException($"Path at {path} does not exist.");
        }
        if (path.ToLower().EndsWith("txt") == false)
        {
            throw new CustomBasicException(@"Only text files are supported.  Rethink");
        }
        BasicList <string> firstList = await ff.ReadAllLinesAsync(path);

        Dictionary <string, string> output = new();

        firstList.ForEach(row =>
        {
            BasicList <string> nextList = row.Split(Constants.VBTab).ToBasicList();
            if (nextList.Count != 2)
            {
                throw new CustomBasicException($"Needs 2 items for value pair.  Value or row was {row}");
            }
            bool rets = output.TryAdd(nextList.First(), nextList.Last());
            if (rets == false)
            {
                throw new CustomBasicException($"{key} was duplicated");
            }
        });
        return(output[key]);
    }
Exemplo n.º 2
0
    public static int RoundToLowerNumber(this double thisDou)
    {
        string thisStr = thisDou.ToString();

        if (thisStr.Contains(".") == false)
        {
            return(int.Parse(thisDou.ToString()));
        }
        BasicList <string> thisList = thisStr.Split(".").ToBasicList();

        return(int.Parse(thisList.First()));
    }
Exemplo n.º 3
0
    public static int RoundToHigherNumber(this double thisDou)
    {
        string str = thisDou.ToString();

        if (str.Contains(".") == false)
        {
            return(int.Parse(thisDou.ToString()));
        }
        BasicList <string> list = str.Split(".").ToBasicList();
        int value = int.Parse(list.First());

        return(value + 1);
    }
Exemplo n.º 4
0
    public static int GetMajorVersion(this string payLoad)
    {
        BasicList <string> output = payLoad.Split(".").ToBasicList();

        return(int.Parse(output.First()));
    }