예제 #1
0
        private static void FlattenComment(IRecord record, ReturnedCommentDto dto)
        {
            var dynamicComment = record["Comment"];
            var commentProps   = (Dictionary <string, object>)dynamicComment.GetType().GetProperty("Properties").GetValue(dynamicComment);

            dto.Content   = (string)commentProps[nameof(dto.Content)];
            dto.CreatedOn = DateTime.Parse((string)commentProps[nameof(dto.CreatedOn)]).ToUniversalTime();
            dto.ImgUrl    = commentProps.ContainsKey(nameof(dto.ImgUrl)) ? (string)commentProps[nameof(dto.ImgUrl)] : null;
            dto.CommentId = (string)commentProps[nameof(dto.CommentId)];
        }
예제 #2
0
        private static List <ReturnedCommentDto> DeserializeComments(IEnumerable <IRecord> records)
        {
            var list = new List <ReturnedCommentDto>();

            foreach (IRecord record in records)
            {
                ReturnedCommentDto dto = new ReturnedCommentDto();
                FlattenComment(record, dto);
                dto.CreatedBy   = ExtractUser(record);
                dto.IsLiked     = (bool)record["IsLiked"];
                dto.Likes       = (int)(long)record["Likes"];
                dto.PostId      = (string)record["PostId"];
                dto.Referencing = ExtractRefences(record);
                list.Add(dto);
            }
            return(list);
        }