Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
#27 Add Project for grabbing free iamge from Pexels
Browse files Browse the repository at this point in the history
  • Loading branch information
BoDmiSer committed Dec 5, 2020
1 parent 9bd1911 commit a93175e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ImageBase.GrabbingImages/Grabber.cs
Original file line number Diff line number Diff line change
@@ -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<PhotoPage> SearchPhotosAsync()
{
PhotoPage photoPage = await pexelsClient.SearchPhotosAsync("Nature","ru-RU",1,5);
return photoPage;
}
}
}
14 changes: 14 additions & 0 deletions ImageBase.GrabbingImages/ImageBase.GrabbingImages.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>c986862e-528e-4391-9ff1-fbc6cc7c06aa</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.0" />
<PackageReference Include="PexelsDotNetSDK" Version="1.0.5" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions ImageBase.GrabbingImages/Program.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
7 changes: 7 additions & 0 deletions ImageBase.GrabbingImages/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
6 changes: 6 additions & 0 deletions imagebase.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a93175e

Please sign in to comment.