public static string CreateJson(
            PaletteOffsetCollections collections,
            Options options)
        {
            var offsets = new List <int[]>();

            foreach (var array in collections.GetCollections(options))
            {
                offsets.Add(array.ToArray());
            }

            var result = JsonSerializer.Serialize(offsets);
            var sb     = new StringBuilder();

            sb.Append('[');
            sb.Append(Environment.NewLine);
            foreach (var match in OffsetFormat.Matches(result))
            {
                sb.Append("  ");
                sb.Append(match);
                sb.Append(Environment.NewLine);
            }

            sb.Append(']');
            return(sb.ToString());
        }
        public void RebuildCollections()
        {
            PaletteEditorsInternal.Clear();
            var offsetCollection = PaletteOffsetCollections.GetCollections(Options);

            foreach (var offsets in offsetCollection)
            {
                PaletteEditorsInternal.Add(new PaletteEditor(Rom, offsets));
            }
        }
 public PaletteRandomizer(
     Options options,
     IColorFGenerator generator)
 {
     Options = options
               ?? throw new ArgumentNullException(nameof(options));
     Generator = generator
                 ?? throw new ArgumentNullException(nameof(generator));
     Rom = File.ReadAllBytes(options.InputRomPath);
     PaletteOffsetCollections = new PaletteOffsetCollections();
     PaletteEditorsInternal   = new Collection <PaletteEditor>();
     PaletteEditors           = new ReadOnlyCollection <PaletteEditor>(
         PaletteEditorsInternal);
     RebuildCollections();
 }