public void Set(CommentConfig target)
        {
            target.Styles.Clear();
            target.Classifications.Clear();

            DefaultsDto.Set(target.Defaults);

            foreach (var styleDto in StyleDtos)
            {
                target.Styles.Add(styleDto.ToStyle());
            }

            foreach (var clsDto in ClassificationDtos)
            {
                var style = target.Styles.SingleOrDefault(s => s.Name == clsDto.Style);

                target.Classifications.Add(
                    new Classification
                {
                    Key            = clsDto.Key,
                    Name           = clsDto.Name,
                    Token          = clsDto.Token,
                    Style          = style,
                    Capitalization = clsDto.Capitalization,
                    Application    = clsDto.Application,
                    RaiseWarning   = clsDto.RaiseWarning
                });
            }
        }
Exemple #2
0
        public async Task TestCommentAsync()
        {
            var url    = "https://dealer.devnet.lyra.live:7070";
            var dealer = new DealerClient(new Uri(new Uri(url), "/api/dealer/"));

            var(pvt, pub) = Signatures.GenerateWallet();

            var tradid = "L8FufT33KuUrAsHYgCC1zo4gVRdZA8WBS7SMM8Tevq74B4N4wemz5mBh8CqCmgS3vKa4TiTsVH5kMi49Gn4962hfn8JcT7";

            var cfg = new CommentConfig();

            cfg.TradeId = tradid;
            cfg.Content = "hahaha";
            cfg.Title   = "title";

            cfg.ByAccountId = pub;
            cfg.Created     = DateTime.UtcNow;

            cfg.EncContent = Convert.ToBase64String(Encoding.UTF8.GetBytes(cfg.Content));
            cfg.EncTitle   = Convert.ToBase64String(Encoding.UTF8.GetBytes(cfg.Title));

            cfg.Sign(pvt, pub);

            //var result = await dealer.CommentTradeAsync(cfg);
            //Assert.IsTrue(result.Successful(), $"comment failed: {result.ResultCode}");

            //var cmnts = await dealer.GetCommentsForTradeAsync(tradid);
            //Assert.IsTrue(cmnts.Count == 1, $"no comment found.");
            //Assert.IsTrue(cmnts.First().Content == cfg.Content);
        }
        public CommentConfigDTO(CommentConfig source)
        {
            DefaultsDto = new DefaultStyleDTO(source.Defaults);

            foreach (var style in source.Styles)
            {
                StyleDtos.Add(new StyleDTO(style));
            }

            foreach (var cls in source.Classifications)
            {
                ClassificationDtos.Add(new ClassificationDTO(cls));
            }
        }