-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#762 NullReferenceException в Document.Type
- Loading branch information
1 parent
777c7ea
commit 8b2d84f
Showing
5 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace VkNet.Enums | ||
{ | ||
public enum DocumentTypeEnum | ||
{ | ||
/// <summary> | ||
/// Текстовые документы | ||
/// </summary> | ||
Text = 1, | ||
/// <summary> | ||
/// Архивы | ||
/// </summary> | ||
Archive, | ||
/// <summary> | ||
/// gif | ||
/// </summary> | ||
Gif, | ||
/// <summary> | ||
/// Изображения | ||
/// </summary> | ||
Image, | ||
/// <summary> | ||
/// Аудио | ||
/// </summary> | ||
Audio, | ||
/// <summary> | ||
/// Видео | ||
/// </summary> | ||
Video, | ||
/// <summary> | ||
/// Электронные книги | ||
/// </summary> | ||
EBook, | ||
/// <summary> | ||
/// Неизвестно | ||
/// </summary> | ||
Unknown | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using VkNet.Utils; | ||
|
||
namespace VkNet.Model.Attachments | ||
{ | ||
/// <summary> | ||
/// Информация для предварительного просмотра документа | ||
/// </summary> | ||
[Serializable] | ||
public class DocumentPreview | ||
{ | ||
/// <summary> | ||
/// Изображения для предпросмотра. | ||
/// </summary> | ||
[JsonProperty("photo")] | ||
public Photo Photo { get; set; } | ||
|
||
/// <summary> | ||
/// Данные о граффити | ||
/// </summary> | ||
[JsonProperty("graffiti")] | ||
public Graffiti Graffiti { get; set; } | ||
|
||
/// <summary> | ||
/// Данные об аудиосообщении. | ||
/// </summary> | ||
[JsonProperty("audio_message")] | ||
public AudioMessage AudioMessage { get; set; } | ||
|
||
/// <summary> | ||
/// Разобрать из json. | ||
/// </summary> | ||
/// <param name="response"> Ответ сервера. </param> | ||
/// <returns> </returns> | ||
public static DocumentPreview FromJson(VkResponse response) | ||
{ | ||
return new DocumentPreview | ||
{ | ||
Photo = response["photo"], | ||
Graffiti = response["graffiti"], | ||
AudioMessage = response["audio_message"] | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Преобразование класса <see cref="Document" /> в <see cref="VkParameters" /> | ||
/// </summary> | ||
/// <param name="response"> Ответ сервера. </param> | ||
/// <returns>Результат преобразования в <see cref="Document" /></returns> | ||
public static implicit operator DocumentPreview(VkResponse response) | ||
{ | ||
if (response == null) | ||
{ | ||
return null; | ||
} | ||
|
||
return response.HasToken() | ||
? FromJson(response) | ||
: null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters