using RuriLib.ViewModels;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RuriLib.Models
{
///
/// The pool where data lines are taken from.
///
public class DataPool : ViewModelBase
{
/// The IEnumerable of all available data lines.
public IEnumerable List { get; }
/// The total number of lines.
public int Size { get; set; }
///
/// Creates a DataPool given an IEnumerable and counts the amount of lines.
///
/// The IEnumerable to pick lines from
public DataPool(IEnumerable list)
{
List = list;
Size = List.Count();
}
///
/// Creates a DataPool by loading lines from a file.
///
/// The name of the file to load data lines from
public DataPool(string fileName)
{
List = File.ReadLines(fileName);
Size = List.Count();
}
///
/// Creates a DataPool by generating all the possible combinations of a string.
///
/// The allowed character set (one after the other like in the string "abcdef")
/// The length of the output combinations
public DataPool(string charSet, int length)
{
List = charSet.Select(x => x.ToString());
for (int i = 0; i < length; i++)
List = List.SelectMany(x => charSet, (x, y) => x + y);
Size = (int)Math.Pow(charSet.Length, length);
}
}
}