From a93175ec2227ac4fd146d7c4d56e6bafe687bfc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=91=D0=BE?= =?UTF-8?q?=D0=B3=D0=B4=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sat, 5 Dec 2020 18:52:39 +0300 Subject: [PATCH] #27 Add Project for grabbing free iamge from Pexels --- ImageBase.GrabbingImages/Grabber.cs | 27 +++++++++++++++++++ .../ImageBase.GrabbingImages.csproj | 14 ++++++++++ ImageBase.GrabbingImages/Program.cs | 18 +++++++++++++ .../Properties/serviceDependencies.json | 7 +++++ .../Properties/serviceDependencies.local.json | 7 +++++ imagebase.sln | 6 +++++ 6 files changed, 79 insertions(+) create mode 100644 ImageBase.GrabbingImages/Grabber.cs create mode 100644 ImageBase.GrabbingImages/ImageBase.GrabbingImages.csproj create mode 100644 ImageBase.GrabbingImages/Program.cs create mode 100644 ImageBase.GrabbingImages/Properties/serviceDependencies.json create mode 100644 ImageBase.GrabbingImages/Properties/serviceDependencies.local.json diff --git a/ImageBase.GrabbingImages/Grabber.cs b/ImageBase.GrabbingImages/Grabber.cs new file mode 100644 index 0000000..7e084ac --- /dev/null +++ b/ImageBase.GrabbingImages/Grabber.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.Configuration; +using PexelsDotNetSDK.Api; +using PexelsDotNetSDK.Models; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace ImageBase.GrabbingImages +{ + public class Grabber + { + public IConfiguration Configuration { get; } + public Grabber(IConfiguration configuration) + { + Configuration = configuration; + pexelsClient = new PexelsClient(Configuration.GetConnectionString("MyAPIKey")); + } + private PexelsClient pexelsClient; + + public async Task SearchPhotosAsync() + { + PhotoPage photoPage = await pexelsClient.SearchPhotosAsync("Nature","ru-RU",1,5); + return photoPage; + } + } +} diff --git a/ImageBase.GrabbingImages/ImageBase.GrabbingImages.csproj b/ImageBase.GrabbingImages/ImageBase.GrabbingImages.csproj new file mode 100644 index 0000000..8e97f80 --- /dev/null +++ b/ImageBase.GrabbingImages/ImageBase.GrabbingImages.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp3.1 + c986862e-528e-4391-9ff1-fbc6cc7c06aa + + + + + + + + diff --git a/ImageBase.GrabbingImages/Program.cs b/ImageBase.GrabbingImages/Program.cs new file mode 100644 index 0000000..295486b --- /dev/null +++ b/ImageBase.GrabbingImages/Program.cs @@ -0,0 +1,18 @@ +using Microsoft.Extensions.Configuration; +using PexelsDotNetSDK.Models; +using System; + +namespace ImageBase.GrabbingImages +{ + class Program + { + static async System.Threading.Tasks.Task Main(string[] args) + { + IConfiguration config = new ConfigurationBuilder() + .AddUserSecrets(typeof(Program).Assembly) + .Build(); + Grabber grabber = new Grabber(config); + PhotoPage photoPage = await grabber.SearchPhotosAsync(); + } + } +} diff --git a/ImageBase.GrabbingImages/Properties/serviceDependencies.json b/ImageBase.GrabbingImages/Properties/serviceDependencies.json new file mode 100644 index 0000000..a4e7aa3 --- /dev/null +++ b/ImageBase.GrabbingImages/Properties/serviceDependencies.json @@ -0,0 +1,7 @@ +{ + "dependencies": { + "secrets1": { + "type": "secrets" + } + } +} \ No newline at end of file diff --git a/ImageBase.GrabbingImages/Properties/serviceDependencies.local.json b/ImageBase.GrabbingImages/Properties/serviceDependencies.local.json new file mode 100644 index 0000000..09b109b --- /dev/null +++ b/ImageBase.GrabbingImages/Properties/serviceDependencies.local.json @@ -0,0 +1,7 @@ +{ + "dependencies": { + "secrets1": { + "type": "secrets.user" + } + } +} \ No newline at end of file diff --git a/imagebase.sln b/imagebase.sln index 4483588..184c3f1 100644 --- a/imagebase.sln +++ b/imagebase.sln @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageBase.ImageHash.UnitTes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageBase.HashBase.UnitTests", "ImageBase.HashBase.UnitTests\ImageBase.HashBase.UnitTests.csproj", "{34EC7522-24B2-4206-B3C1-DA33B9485F2B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageBase.GrabbingImages", "ImageBase.GrabbingImages\ImageBase.GrabbingImages.csproj", "{175BA793-13FE-4320-9A16-24FAC844C771}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -57,6 +59,10 @@ Global {34EC7522-24B2-4206-B3C1-DA33B9485F2B}.Debug|Any CPU.Build.0 = Debug|Any CPU {34EC7522-24B2-4206-B3C1-DA33B9485F2B}.Release|Any CPU.ActiveCfg = Release|Any CPU {34EC7522-24B2-4206-B3C1-DA33B9485F2B}.Release|Any CPU.Build.0 = Release|Any CPU + {175BA793-13FE-4320-9A16-24FAC844C771}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {175BA793-13FE-4320-9A16-24FAC844C771}.Debug|Any CPU.Build.0 = Debug|Any CPU + {175BA793-13FE-4320-9A16-24FAC844C771}.Release|Any CPU.ActiveCfg = Release|Any CPU + {175BA793-13FE-4320-9A16-24FAC844C771}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE