added DI container and twitter service
This commit is contained in:
parent
05ea140322
commit
796004fa59
11 changed files with 99 additions and 4 deletions
|
@ -40,8 +40,8 @@ namespace BirdsiteLive.Cryptography
|
|||
using (var paramsStream = new MemoryStream())
|
||||
{
|
||||
var paramsWriter = new BinaryWriter(paramsStream);
|
||||
EncodeIntegerBigEndian(paramsWriter, parameters.Modulus); // Modulus
|
||||
EncodeIntegerBigEndian(paramsWriter, parameters.Exponent); // Exponent
|
||||
//EncodeIntegerBigEndian(paramsWriter, parameters.Modulus); // Modulus
|
||||
//EncodeIntegerBigEndian(paramsWriter, parameters.Exponent); // Exponent
|
||||
var paramsLength = (int)paramsStream.Length;
|
||||
EncodeLength(bitStringWriter, paramsLength);
|
||||
bitStringWriter.Write(paramsStream.GetBuffer(), 0, paramsLength);
|
||||
|
|
7
src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj
Normal file
7
src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj
Normal file
|
@ -0,0 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
19
src/BirdsiteLive.Twitter/Settings/TwitterSettings.cs
Normal file
19
src/BirdsiteLive.Twitter/Settings/TwitterSettings.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
namespace BirdsiteLive.Twitter.Settings
|
||||
{
|
||||
public class TwitterSettings
|
||||
{
|
||||
#region Ctor
|
||||
public TwitterSettings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TwitterSettings(string apiKey)
|
||||
{
|
||||
ApiKey = apiKey;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public string ApiKey { get; set; }
|
||||
}
|
||||
}
|
21
src/BirdsiteLive.Twitter/TwitterService.cs
Normal file
21
src/BirdsiteLive.Twitter/TwitterService.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using BirdsiteLive.Twitter.Settings;
|
||||
|
||||
namespace BirdsiteLive.Twitter
|
||||
{
|
||||
public interface ITwitterService
|
||||
{
|
||||
}
|
||||
|
||||
public class TwitterService : ITwitterService
|
||||
{
|
||||
private readonly TwitterSettings _settings;
|
||||
|
||||
#region Ctor
|
||||
public TwitterService(TwitterSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BirdsiteLive.Cryptography",
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{4FEAD6BC-3C8E-451A-8CA1-FF1AF47D26CC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BirdsiteLive.Twitter", "BirdsiteLive.Twitter\BirdsiteLive.Twitter.csproj", "{77C559D1-80A2-4B1C-A566-AE2D156944A4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -23,12 +25,17 @@ Global
|
|||
{160AD138-4E29-4706-8546-9826B529E9B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{160AD138-4E29-4706-8546-9826B529E9B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{160AD138-4E29-4706-8546-9826B529E9B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{77C559D1-80A2-4B1C-A566-AE2D156944A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{77C559D1-80A2-4B1C-A566-AE2D156944A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{77C559D1-80A2-4B1C-A566-AE2D156944A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{77C559D1-80A2-4B1C-A566-AE2D156944A4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{160AD138-4E29-4706-8546-9826B529E9B2} = {4FEAD6BC-3C8E-451A-8CA1-FF1AF47D26CC}
|
||||
{77C559D1-80A2-4B1C-A566-AE2D156944A4} = {4FEAD6BC-3C8E-451A-8CA1-FF1AF47D26CC}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {69E8DCAD-4C37-4010-858F-5F94E6FBABCE}
|
||||
|
|
|
@ -7,10 +7,16 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="4.1.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BirdsiteLive.Cryptography\BirdsiteLive.Cryptography.csproj" />
|
||||
<ProjectReference Include="..\BirdsiteLive.Twitter\BirdsiteLive.Twitter.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BirdsiteLive.Models;
|
||||
using BirdsiteLive.Twitter;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
@ -11,11 +12,13 @@ namespace BirdsiteLive.Controllers
|
|||
[ApiController]
|
||||
public class WellKnownController : ControllerBase
|
||||
{
|
||||
private readonly ITwitterService _twitterService;
|
||||
private readonly InstanceSettings _settings;
|
||||
|
||||
#region Ctor
|
||||
public WellKnownController(IOptions<InstanceSettings> settings)
|
||||
public WellKnownController(IOptions<InstanceSettings> settings, ITwitterService twitterService)
|
||||
{
|
||||
_twitterService = twitterService;
|
||||
_settings = settings.Value;
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Lamar.Microsoft.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
@ -18,6 +19,7 @@ namespace BirdsiteLive
|
|||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.UseLamar()
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BirdsiteLive.Models;
|
||||
using BirdsiteLive.Twitter.Settings;
|
||||
using Lamar;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
|
@ -33,10 +35,32 @@ namespace BirdsiteLive
|
|||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.Configure<InstanceSettings>(Configuration.GetSection("Instance"));
|
||||
//services.Configure<TwitterSettings>(Configuration.GetSection("Twitter"));
|
||||
|
||||
services.AddControllersWithViews();
|
||||
}
|
||||
|
||||
public void ConfigureContainer(ServiceRegistry services)
|
||||
{
|
||||
var twitterSettings = Configuration.GetSection("Twitter").Get<TwitterSettings>();
|
||||
|
||||
services.For<TwitterSettings>().Use<TwitterSettings>()
|
||||
.Ctor<string>("apiKey").Is(twitterSettings.ApiKey);
|
||||
|
||||
services.Scan(_ =>
|
||||
{
|
||||
_.Assembly("BirdsiteLive.Twitter");
|
||||
_.TheCallingAssembly();
|
||||
|
||||
//_.AssemblyContainingType<IDal>();
|
||||
//_.Exclude(type => type.Name.Contains("Settings"));
|
||||
|
||||
_.WithDefaultConventions();
|
||||
|
||||
_.LookForRegistries();
|
||||
});
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
|
|
|
@ -8,5 +8,8 @@
|
|||
},
|
||||
"Instance": {
|
||||
"Domain": "domain.name"
|
||||
},
|
||||
"Twitter": {
|
||||
"ApiKey": "twitter.api.key"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
},
|
||||
"AllowedHosts": "*",
|
||||
"Instance": {
|
||||
"Domain": "domain.name"
|
||||
"Domain": "domain.name"
|
||||
},
|
||||
"Twitter": {
|
||||
"ApiKey": "twitter.api.key"
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue