Ejemplo n.º 1
0
 public static CommunitiesEntity FromRPCModel(this AFEntityReference source)
 {
     return(new CommunitiesEntity
     {
         Type = (CommunitiesEntityType)source.Id.EntityType,
         Id = source.Id.Id,
         Title = source.Title.FirstValue(),
         AvatarUrl = source.AvatarUrl,
         FollowersCount = source.FollowersCount,
         IsFollower = source.IsFollower,
         AvailableActions = ConvertAllowableActions(source.AllowedActions)
     });
 }
Ejemplo n.º 2
0
        private static AFEntityReference FindSource(List <AFEntityReference> list, AFEntityReference source)
        {
            if (source == null || source.Id == null)
            {
                return(null);
            }

            foreach (var reference in list)
            {
                if (source.Id.Id.Equals(reference.Id.Id) && source.Id.EntityType == reference.Id.EntityType)
                {
                    return(reference);
                }
            }

            return(source);
        }
Ejemplo n.º 3
0
        public static Activity FromRPCModel(this AFActivity activity, THPublicUser user = null, AFEntityReference source = null)
        {
            var content = activity.Content.FirstValue(new AFContent());

            return(new Activity
            {
                Id = activity.Id,
                Type = activity.ContentType,
                Announcement = activity.IsAnnouncement,
                Button = content.Button.FromRPCModel(),
                Author = activity.Author.FromRPCModel(user),
                Properties = activity.Properties ?? new Dictionary <string, string>(),
                CreatedAt = activity.CreatedAt,
                ViewCount = activity.Reactions.ViewCount,
                CommentsCount = activity.Reactions.CommentCount,
                MediaAttachments = (content.Attachments ?? new List <AFAttachment>()).ConvertAll(FromRpc),
                Text = content.Text,
                ReactionsCount = activity.Reactions.ReactionCount,
                MyReactionsList = activity.Reactions.MyReactions ?? new List <string>(),
                Mentions = activity.Mentions.FirstValue(new List <AFMention>()).ConvertAll(FromRPCModel),
                Source = (source ?? activity.Source).FromRPCModel(),
                Status = activity.Status ?? ""
            });
        }
Ejemplo n.º 4
0
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.String)
                        {
                            Id = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.Map)
                        {
                            {
                                Content = new Dictionary <string, AFContent>();
                                TMap _map29 = iprot.ReadMapBegin();
                                for (int _i30 = 0; _i30 < _map29.Count; ++_i30)
                                {
                                    string    _key31;
                                    AFContent _val32;
                                    _key31 = iprot.ReadString();
                                    _val32 = new AFContent();
                                    _val32.Read(iprot);
                                    Content[_key31] = _val32;
                                }
                                iprot.ReadMapEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.String)
                        {
                            ContentType = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.Struct)
                        {
                            Reactions = new AFUserReactions();
                            Reactions.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 6:
                        if (field.Type == TType.Map)
                        {
                            {
                                Properties = new Dictionary <string, string>();
                                TMap _map33 = iprot.ReadMapBegin();
                                for (int _i34 = 0; _i34 < _map33.Count; ++_i34)
                                {
                                    string _key35;
                                    string _val36;
                                    _key35             = iprot.ReadString();
                                    _val36             = iprot.ReadString();
                                    Properties[_key35] = _val36;
                                }
                                iprot.ReadMapEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 7:
                        if (field.Type == TType.Struct)
                        {
                            Author = new THCreator();
                            Author.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 8:
                        if (field.Type == TType.I64)
                        {
                            CreatedAt = iprot.ReadI64();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 9:
                        if (field.Type == TType.Bool)
                        {
                            IsAnnouncement = iprot.ReadBool();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 10:
                        if (field.Type == TType.Map)
                        {
                            {
                                Mentions = new Dictionary <string, List <AFMention> >();
                                TMap _map37 = iprot.ReadMapBegin();
                                for (int _i38 = 0; _i38 < _map37.Count; ++_i38)
                                {
                                    string           _key39;
                                    List <AFMention> _val40;
                                    _key39 = iprot.ReadString();
                                    {
                                        _val40 = new List <AFMention>();
                                        TList _list41 = iprot.ReadListBegin();
                                        for (int _i42 = 0; _i42 < _list41.Count; ++_i42)
                                        {
                                            AFMention _elem43;
                                            _elem43 = new AFMention();
                                            _elem43.Read(iprot);
                                            _val40.Add(_elem43);
                                        }
                                        iprot.ReadListEnd();
                                    }
                                    Mentions[_key39] = _val40;
                                }
                                iprot.ReadMapEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 11:
                        if (field.Type == TType.Struct)
                        {
                            Source = new AFEntityReference();
                            Source.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 12:
                        if (field.Type == TType.String)
                        {
                            Status = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 13:
                        if (field.Type == TType.I64)
                        {
                            StatusUpdatedAt = iprot.ReadI64();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.List)
                        {
                            {
                                Data = new List <AFActivity>();
                                TList _list71 = iprot.ReadListBegin();
                                for (int _i72 = 0; _i72 < _list71.Count; ++_i72)
                                {
                                    AFActivity _elem73;
                                    _elem73 = new AFActivity();
                                    _elem73.Read(iprot);
                                    Data.Add(_elem73);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.List)
                        {
                            {
                                EntityDetails = new List <AFEntityReference>();
                                TList _list74 = iprot.ReadListBegin();
                                for (int _i75 = 0; _i75 < _list74.Count; ++_i75)
                                {
                                    AFEntityReference _elem76;
                                    _elem76 = new AFEntityReference();
                                    _elem76.Read(iprot);
                                    EntityDetails.Add(_elem76);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.Map)
                        {
                            {
                                Authors = new Dictionary <string, THPublicUser>();
                                TMap _map77 = iprot.ReadMapBegin();
                                for (int _i78 = 0; _i78 < _map77.Count; ++_i78)
                                {
                                    string       _key79;
                                    THPublicUser _val80;
                                    _key79 = iprot.ReadString();
                                    _val80 = new THPublicUser();
                                    _val80.Read(iprot);
                                    Authors[_key79] = _val80;
                                }
                                iprot.ReadMapEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.String)
                        {
                            NextCursor = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.List)
                        {
                            {
                                Data = new List <AFAnnouncement>();
                                TList _list122 = iprot.ReadListBegin();
                                for (int _i123 = 0; _i123 < _list122.Count; ++_i123)
                                {
                                    AFAnnouncement _elem124;
                                    _elem124 = new AFAnnouncement();
                                    _elem124.Read(iprot);
                                    Data.Add(_elem124);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.List)
                        {
                            {
                                EntityDetails = new List <AFEntityReference>();
                                TList _list125 = iprot.ReadListBegin();
                                for (int _i126 = 0; _i126 < _list125.Count; ++_i126)
                                {
                                    AFEntityReference _elem127;
                                    _elem127 = new AFEntityReference();
                                    _elem127.Read(iprot);
                                    EntityDetails.Add(_elem127);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.String)
                        {
                            NextCursor = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.List)
                        {
                            {
                                Data = new List <AFActivity>();
                                TList _list105 = iprot.ReadListBegin();
                                for (int _i106 = 0; _i106 < _list105.Count; ++_i106)
                                {
                                    AFActivity _elem107;
                                    _elem107 = new AFActivity();
                                    _elem107.Read(iprot);
                                    Data.Add(_elem107);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.List)
                        {
                            {
                                EntityDetails = new List <AFEntityReference>();
                                TList _list108 = iprot.ReadListBegin();
                                for (int _i109 = 0; _i109 < _list108.Count; ++_i109)
                                {
                                    AFEntityReference _elem110;
                                    _elem110 = new AFEntityReference();
                                    _elem110.Read(iprot);
                                    EntityDetails.Add(_elem110);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.Map)
                        {
                            {
                                Authors = new Dictionary <string, THPublicUser>();
                                TMap _map111 = iprot.ReadMapBegin();
                                for (int _i112 = 0; _i112 < _map111.Count; ++_i112)
                                {
                                    string       _key113;
                                    THPublicUser _val114;
                                    _key113 = iprot.ReadString();
                                    _val114 = new THPublicUser();
                                    _val114.Read(iprot);
                                    Authors[_key113] = _val114;
                                }
                                iprot.ReadMapEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.String)
                        {
                            NextCursor = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.List)
                        {
                            {
                                Data = new List <AFAnnouncement>();
                                TList _list88 = iprot.ReadListBegin();
                                for (int _i89 = 0; _i89 < _list88.Count; ++_i89)
                                {
                                    AFAnnouncement _elem90;
                                    _elem90 = new AFAnnouncement();
                                    _elem90.Read(iprot);
                                    Data.Add(_elem90);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.List)
                        {
                            {
                                EntityDetails = new List <AFEntityReference>();
                                TList _list91 = iprot.ReadListBegin();
                                for (int _i92 = 0; _i92 < _list91.Count; ++_i92)
                                {
                                    AFEntityReference _elem93;
                                    _elem93 = new AFEntityReference();
                                    _elem93.Read(iprot);
                                    EntityDetails.Add(_elem93);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.Map)
                        {
                            {
                                Authors = new Dictionary <string, THPublicUser>();
                                TMap _map94 = iprot.ReadMapBegin();
                                for (int _i95 = 0; _i95 < _map94.Count; ++_i95)
                                {
                                    string       _key96;
                                    THPublicUser _val97;
                                    _key96 = iprot.ReadString();
                                    _val97 = new THPublicUser();
                                    _val97.Read(iprot);
                                    Authors[_key96] = _val97;
                                }
                                iprot.ReadMapEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.String)
                        {
                            NextCursor = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.List)
                        {
                            {
                                Data = new List <AFActivityForModeration>();
                                TList _list234 = iprot.ReadListBegin();
                                for (int _i235 = 0; _i235 < _list234.Count; ++_i235)
                                {
                                    AFActivityForModeration _elem236;
                                    _elem236 = new AFActivityForModeration();
                                    _elem236.Read(iprot);
                                    Data.Add(_elem236);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.List)
                        {
                            {
                                EntityDetails = new List <AFEntityReference>();
                                TList _list237 = iprot.ReadListBegin();
                                for (int _i238 = 0; _i238 < _list237.Count; ++_i238)
                                {
                                    AFEntityReference _elem239;
                                    _elem239 = new AFEntityReference();
                                    _elem239.Read(iprot);
                                    EntityDetails.Add(_elem239);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.Map)
                        {
                            {
                                Authors = new Dictionary <string, THPublicUser>();
                                TMap _map240 = iprot.ReadMapBegin();
                                for (int _i241 = 0; _i241 < _map240.Count; ++_i241)
                                {
                                    string       _key242;
                                    THPublicUser _val243;
                                    _key242 = iprot.ReadString();
                                    _val243 = new THPublicUser();
                                    _val243.Read(iprot);
                                    Authors[_key242] = _val243;
                                }
                                iprot.ReadMapEnd();
                            }
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.String)
                        {
                            NextCursor = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }