Ejemplo n.º 1
0
        public List <PhotoComment> VisitPhotoGetComments(GetComments method, JToken data)
        {
            var result     = new List <PhotoComment>();
            var commentors = new List <VkPrincipal>();

            foreach (var item in data["response"]["profiles"])
            {
                var profile = new User();
                profile.Accept(this.ObjectParser, item);
                commentors.Add(profile);
            }
            foreach (var item in data["response"]["groups"])
            {
                var group = new Group();
                group.Accept(this.ObjectParser, item);
                commentors.Add(group);
            }
            foreach (var item in data["response"]["items"])
            {
                var comment = new PhotoComment();
                comment.Accept(this.ObjectParser, item);
                comment.Creator = commentors.SingleOrDefault(x => x.Id == comment.FromId);
                result.Add(comment);
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 访问者模式
        /// </summary>
        public static void VistorPattern()
        {
            IVistor     printVistor = new PrintVisit();
            IDataStruct group       = new Group(new List <string> {
                "张三", "李四", "王五"
            });
            IDataStruct single = new VistorPattern.Single("赵六", "10");

            group.Accept(printVistor);
            single.Accept(printVistor);
        }
Ejemplo n.º 3
0
        public void IngestIntoRepository(Group group)
        {
            // Register every DDI item in the repository.
            var client  = new LocalRepositoryClient();
            var options = new CommitOptions();

            var gatherer = new DirtyItemGatherer(true);

            group.Accept(gatherer);

            options.NamedOptions.Add("RegisterOrReplace");
            client.RegisterItems(gatherer.DirtyItems, options);
        }
Ejemplo n.º 4
0
        public List <Group> VisitGroupsGet(Get method, JToken data)
        {
            var result = new List <Group>(data["response"].SafeGetValue <Int32>("count"));

            foreach (var groupItem in data["response"]["items"])
            {
                var group = new Group();
                group.Accept(this.ObjectParser, groupItem);
                result.Add(group);
            }

            return(result);
        }