This repository has been archived by the owner on Sep 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#27 Add Project for grabbing free iamge from Pexels
- Loading branch information
Showing
6 changed files
with
79 additions
and
0 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
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; | ||
} | ||
} | ||
} |
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,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> |
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,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(); | ||
} | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"dependencies": { | ||
"secrets1": { | ||
"type": "secrets" | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
ImageBase.GrabbingImages/Properties/serviceDependencies.local.json
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,7 @@ | ||
{ | ||
"dependencies": { | ||
"secrets1": { | ||
"type": "secrets.user" | ||
} | ||
} | ||
} |
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