Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
messages.getHistory, newsfeed.getBanned, ContentId, stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kasthack committed Nov 3, 2015
1 parent 2b8c407 commit 8a90ff8
Show file tree
Hide file tree
Showing 29 changed files with 468 additions and 104 deletions.
22 changes: 0 additions & 22 deletions Sources/kasthack.vksharp/DataTypes/ContentId.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/kasthack.vksharp/DataTypes/Date.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static Date Parse(string innerText) {
};
}
public override string ToString() {
return String.Format(
return string.Format(
Year != null ? "{0:D2}.{1:D2}.{2:D4}" : "{0:D2}.{1:D2}",
Day,
Month,
Expand All @@ -38,7 +38,7 @@ public override string ToString() {
}

public string ToString( string format, IFormatProvider formatProvider ) {
return String.Format(
return string.Format(
formatProvider,
Year != null ? "{0:D2}.{1:D2}.{2:D4}" : "{0:D2}.{1:D2}",
Day,
Expand Down
60 changes: 30 additions & 30 deletions Sources/kasthack.vksharp/DataTypes/Entities/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace kasthack.vksharp.DataTypes.Entities {
public class Attachment {
public AttachmentType? Type { get; set; }
public ContentType? Type { get; set; }
public Photo Photo { get; set; }
public PostedPhoto PostedPhoto { get; set; }
public Video Video { get; set; }
Expand All @@ -11,46 +11,46 @@ public class Attachment {
public Document Doc { get; set; }
public Link Link { get; set; }
public Note Note { get; set; }

public Comment WallReply { get; set; }
public Poll Poll { get; set; }
public Page Page { get; set; }
public PhotoAlbum Album { get; set; }

public Post Wall { get; set; }

public override string ToString() {
switch ( Type ) {
case AttachmentType.Photo:
return $"photo{Photo.OwnerId}_{Photo.Id}";
case AttachmentType.PostedPhoto:
return $"photo{PostedPhoto.OwnerId}_{PostedPhoto.Id}";
case AttachmentType.Video:
return $"video{Video.OwnerId}_{Video.Id}";
case AttachmentType.Audio:
return $"audio{Audio.OwnerId}_{Audio.Id}";
case AttachmentType.Doc:
return $"doc{Doc.OwnerId}_{Doc.Id}";
case AttachmentType.Link:
return Link.Url;
case ContentType.Photo:
return ((ContentId)Photo).ToAttachmentString();
case ContentType.PostedPhoto:
return ((ContentId)PostedPhoto).ToAttachmentString();
case ContentType.Video:
return ((ContentId)Video).ToAttachmentString();
case ContentType.Audio:
return ((ContentId)Audio).ToAttachmentString();
case ContentType.Doc:
return ((ContentId)Doc).ToAttachmentString();
case ContentType.Link:
return ((ContentId)Link).ToAttachmentString();
//case AttachmentType.Graffiti:
//break;
case AttachmentType.Note:
return $"note{Note.OwnerId}_{Note.Id}";
//break;
case ContentType.Note:
return ((ContentId)Note).ToAttachmentString();
//case AttachmentType.App:
// break;
case AttachmentType.Poll:
return $"poll{Poll.OwnerId}_{Poll.Id}";
case AttachmentType.Page:
return $"page{-Page.GroupId}_{Page.Id}";
case AttachmentType.Album:
return $"album{Album.OwnerId}_{Album.Id}";
case ContentType.Poll:
return ((ContentId)Poll).ToAttachmentString();
case ContentType.Page:
return ((ContentId)Page).ToAttachmentString();
case ContentType.Album:
return ((ContentId)Album).ToAttachmentString();
//case AttachmentType.PhotosList:
//break;
//case AttachmentType.Wall:
//return $"wall{Album.OwnerId}_{Album.Id}";
//case AttachmentType.WallReply:
//break;
//break;
case ContentType.Wall:
return ((ContentId)Wall).ToAttachmentString();
case ContentType.WallReply:
return ((ContentId) WallReply).ToAttachmentString();
//case null:
//break;
//break;
default:
return $"Attached {Type}";
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/kasthack.vksharp/DataTypes/Entities/Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ public class Audio : OwnedEntity {
public int Duration { get; set; }

public override string ToString() => Artist + " - " + Title;
public static explicit operator ObjectContentId(Audio audio) => new ObjectContentId( ContentType.Audio, audio.Id, audio.OwnerId );
public static implicit operator ContentId(Audio audio) => (ObjectContentId)audio;
}
}
12 changes: 8 additions & 4 deletions Sources/kasthack.vksharp/DataTypes/Entities/Comment.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
using System;
using kasthack.vksharp.DataTypes.EntityFragments;
using kasthack.vksharp.DataTypes.Enums;
using kasthack.vksharp.DataTypes.Interfaces;

namespace kasthack.vksharp.DataTypes.Entities {
public class Comment {
public long Id{ get; set; }
public class Comment : OwnedEntity {
public int PostId { get; set; }
public int FromId{ get; set; }

public DateTimeOffset Date { get; set; }
public string Text { get; set; }
public int ReplyToUser{ get; set; }
public long ReplyToComment { get; set; }
public Attachment[] Attachments { get; set; }
public CommentLikes Likes { get; set; }
public int ReplyToUser { get; set; }
public long ReplyToComment { get; set; }
public static implicit operator ContentId(Comment comment)=>new ObjectContentId( ContentType.WallReply, comment.Id, comment.OwnerId );
}
}
4 changes: 3 additions & 1 deletion Sources/kasthack.vksharp/DataTypes/Entities/Document.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using kasthack.vksharp.DataTypes.Interfaces;
using kasthack.vksharp.DataTypes.Enums;
using kasthack.vksharp.DataTypes.Interfaces;

namespace kasthack.vksharp.DataTypes.Entities {
public class Document : OwnedEntity {
Expand All @@ -9,5 +10,6 @@ public class Document : OwnedEntity {
public string Photo130 { get; set; }

public string Ext { get; set; }
public static implicit operator ContentId(Document doc)=> new ObjectContentId( ContentType.Doc, doc.Id, doc.OwnerId );
}
}
1 change: 1 addition & 0 deletions Sources/kasthack.vksharp/DataTypes/Entities/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Link {
public string ImageSrc { get; set; }
public string PreviewPage { get; set; }
public string PreviewUrl { get; set; }
public static implicit operator ContentId(Link link) => new StringContentId( link.Url );
}
}

1 change: 1 addition & 0 deletions Sources/kasthack.vksharp/DataTypes/Entities/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Message {
public MessageType? Type { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public bool Out { get; set; }
public Attachment[] Attachments { get; set; }
public Message[] ForwardedMessages { get; set; }
public bool ContainsEmojiSmiles { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions Sources/kasthack.vksharp/DataTypes/Entities/Note.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using kasthack.vksharp.DataTypes.Enums;
using kasthack.vksharp.DataTypes.Interfaces;

namespace kasthack.vksharp.DataTypes.Entities {
Expand All @@ -10,5 +11,7 @@ public class Note : OwnedEntity {
public int? ReadCommentCount { get; set; }
public string Text { get; set; }
public string Title { get; set; }

public static implicit operator ContentId(Note note) => new ObjectContentId( ContentType.Note, note.Id, note.OwnerId );
}
}
3 changes: 2 additions & 1 deletion Sources/kasthack.vksharp/DataTypes/Entities/Page.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using kasthack.vksharp.DataTypes.Enums;

namespace kasthack.vksharp.DataTypes.Entities {

Expand All @@ -17,7 +18,7 @@ public class Page {
public int? EditorId { get; set; }
public int CreatorId { get; set; }
public string ViewUrl { get; set; }

public static implicit operator ContentId(Page page) => new ObjectContentId( ContentType.Page, page.Id, -page.GroupId );
}

}
4 changes: 3 additions & 1 deletion Sources/kasthack.vksharp/DataTypes/Entities/Photo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class Photo : OwnedEntity {
//public Counter Tags { get; set; }
public Counter Comments { get; set; }
public PhotoSize[] Sizes { get; set; }
public static implicit operator Attachment( Photo photo ) => new Attachment { Photo = photo, Type = AttachmentType.Photo };

public static implicit operator Attachment( Photo photo ) => new Attachment { Photo = photo, Type = ContentType.Photo };
public static implicit operator ObjectContentId(Photo photo) => new ObjectContentId( ContentType.Photo, photo.Id, photo.OwnerId, photo.AccessKey );
}
}
4 changes: 3 additions & 1 deletion Sources/kasthack.vksharp/DataTypes/Entities/PhotoAlbum.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using kasthack.vksharp.DataTypes.Interfaces;
using kasthack.vksharp.DataTypes.Enums;
using kasthack.vksharp.DataTypes.Interfaces;

namespace kasthack.vksharp.DataTypes.Entities {

Expand All @@ -13,5 +14,6 @@ public class PhotoAlbum : OwnedEntity {
public bool CanUpload { get; set; }
public Privacy PrivacyView { get; set; }
public Privacy PrivacyComment { get; set; }
public static implicit operator ContentId(PhotoAlbum album)=> new ObjectContentId( ContentType.Album, album.Id, album.OwnerId );
}
}
5 changes: 4 additions & 1 deletion Sources/kasthack.vksharp/DataTypes/Entities/Poll.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using kasthack.vksharp.DataTypes.Interfaces;
using kasthack.vksharp.DataTypes.Enums;
using kasthack.vksharp.DataTypes.Interfaces;

namespace kasthack.vksharp.DataTypes.Entities {
public class Poll : OwnedEntity {
Expand All @@ -7,5 +8,7 @@ public class Poll : OwnedEntity {
public int Created { get; set; }
public int Votes { get; set; }
public int AnswerId { get; set; }

public static implicit operator ContentId(Poll poll) => new ObjectContentId( ContentType.Poll, poll.Id, poll.OwnerId );
}
}
2 changes: 2 additions & 0 deletions Sources/kasthack.vksharp/DataTypes/Entities/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class Post : OwnedEntity {
public Group[] Groups { get; set; }
public User[] Profiles { get; set; }

public static implicit operator ContentId(Post post) => new ObjectContentId( ContentType.Wall, post.Id, post.OwnerId );

public override string ToString () {
return $"Post #{Id}@{OwnerId}by{FromId}";
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/kasthack.vksharp/DataTypes/Entities/PostedPhoto.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using kasthack.vksharp.DataTypes.Interfaces;
using kasthack.vksharp.DataTypes.Enums;
using kasthack.vksharp.DataTypes.Interfaces;

namespace kasthack.vksharp.DataTypes.Entities {
public class PostedPhoto : OwnedEntity {
public string Photo130 { get; set; }
public string Photo640 { get; set; }
public static implicit operator ObjectContentId(PostedPhoto photo)=>new ObjectContentId( ContentType.PostedPhoto, photo.Id, photo.OwnerId );
}
}
2 changes: 1 addition & 1 deletion Sources/kasthack.vksharp/DataTypes/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private ushort? Graduation {
public bool? IsFavorite { get; set; }
public CropPhoto CropPhoto { get; set; }
[JsonConverter(typeof(OneTwoFUConverter))]
public bool? IsFriend { get; set; }//todo:converter
public bool? IsFriend { get; set; }
public FriendshipStatusEnum FriendStatus { get; set; }
public GroupRole? Role { get; set; }
private void CreateUniversityIfNotExists() {
Expand Down
2 changes: 2 additions & 0 deletions Sources/kasthack.vksharp/DataTypes/Entities/Video.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using kasthack.vksharp.DataTypes.Enums;
using kasthack.vksharp.DataTypes.Interfaces;

namespace kasthack.vksharp.DataTypes.Entities {
Expand All @@ -23,6 +24,7 @@ public class Video : OwnedEntity {
public bool? UserLikes { get; set; }
public int? LikesCount { get; set; }
public bool? PlaybackLooped { get; set; }
public static implicit operator ContentId(Video video) => new ObjectContentId( ContentType.Video, video.Id, video.OwnerId, video.AccessKey );
}

public class TaggedVideo : Video{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace kasthack.vksharp.DataTypes.Enums {
public enum AttachmentType:byte {
public enum ContentType:byte {
Photo,
PostedPhoto,
Video,
Expand Down
Loading

0 comments on commit 8a90ff8

Please sign in to comment.