mirror of
https://github.com/Rast1234/VkNet.TokenMagic.git
synced 2026-05-06 16:31:12 +00:00
refactor as vknet extension
This commit is contained in:
commit
cc36c930ec
18 changed files with 1285 additions and 0 deletions
58
Example/Program.cs
Normal file
58
Example/Program.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using VkNet;
|
||||
using VkNet.Enums.Filters;
|
||||
using VkNet.Model;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.NLog.Extensions.Logging;
|
||||
using VkNet.NLog.Extensions.Logging.Extensions;
|
||||
using VkNet.TokenMagic;
|
||||
|
||||
namespace Example
|
||||
{
|
||||
class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddVkTokenMagic();
|
||||
services.AddSingleton<ILoggerFactory, LoggerFactory>();
|
||||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
|
||||
services.AddLogging(builder =>
|
||||
{
|
||||
builder.ClearProviders();
|
||||
builder.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.AddNLog(new NLogProviderOptions
|
||||
{
|
||||
CaptureMessageProperties = true,
|
||||
CaptureMessageTemplates = true
|
||||
});
|
||||
});
|
||||
NLog.LogManager.LoadConfiguration("nlog.config");
|
||||
|
||||
var vkNet = new VkApi(services);
|
||||
vkNet.Authorize(new ApiAuthParams
|
||||
{
|
||||
Login = "LOGIN",
|
||||
Password = "PASSWORD",
|
||||
Settings = Settings.Audio
|
||||
|
||||
});
|
||||
|
||||
var audios = vkNet.Audio.Get(new AudioGetParams
|
||||
{
|
||||
Count = 10
|
||||
});
|
||||
|
||||
foreach (var audio in audios)
|
||||
{
|
||||
Console.WriteLine($"{audio.Artist} - {audio.Title} {audio.Url}");
|
||||
}
|
||||
Console.ReadLine();
|
||||
NLog.LogManager.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue