Пример #1
0
 public override object ReadJson(
     JsonReader reader, Type objectType, object existingValue,
     JsonSerializer serializer)
 {
     return(new ByteString(HexConvert.ToBytes(
                               serializer.Deserialize <string>(reader) ?? "")));
 }
Пример #2
0
        public IEnumerable <(ByteString, byte[])> LoadAll()
        {
            var regex = new Regex("^[0-9a-fA-F]{64}$", RegexOptions.Singleline);

            foreach (var file in directory.GetFiles())
            {
                var name = file.Name;
                if (!regex.IsMatch(name))
                {
                    continue;
                }

                var id    = ByteString.CopyFrom(HexConvert.ToBytes(name));
                var bytes = File.ReadAllBytes(file.FullName);

                yield return(id, bytes);
            }
        }