示例#1
0
        public ISourceParser GetParser(SourceFileFormat format)
        {
            switch (format)
            {
            case SourceFileFormat.Adblock:
                return(new AdblockParser());

            case SourceFileFormat.AdblockPlus:
                return(new AdblockPlusParser());

            case SourceFileFormat.Hosts:
                return(new HostsParser());

            default:
                throw new ArgumentOutOfRangeException(nameof(format), format, null);
            }
        }
示例#2
0
        public int LoadSourceFile(string pathByteCode, SourceFileFormat format)
        {
            BytesROM bytesROM;

            SourceCodeFormat = format;

            if (format == SourceFileFormat.JSON_HEX)
            {
                using (StreamReader file = File.OpenText(pathByteCode))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    bytesROM = (BytesROM)serializer.Deserialize(file, typeof(BytesROM));

                    for (int i = 0; i < bytesROM.Bytes.Length; i++)
                    {
                        Bytes.Add(bytesROM.Bytes[i]);
                    }
                }
            }
            //TODO: add other formats from the enum

            return(0);
        }