diff --git a/src/BirdsiteLive.Cryptography/RsaGenerator.cs b/src/BirdsiteLive.Cryptography/RsaGenerator.cs index 1be77ce..5763c54 100644 --- a/src/BirdsiteLive.Cryptography/RsaGenerator.cs +++ b/src/BirdsiteLive.Cryptography/RsaGenerator.cs @@ -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); diff --git a/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj b/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/src/BirdsiteLive.Twitter/Settings/TwitterSettings.cs b/src/BirdsiteLive.Twitter/Settings/TwitterSettings.cs new file mode 100644 index 0000000..3725746 --- /dev/null +++ b/src/BirdsiteLive.Twitter/Settings/TwitterSettings.cs @@ -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; } + } +} \ No newline at end of file diff --git a/src/BirdsiteLive.Twitter/TwitterService.cs b/src/BirdsiteLive.Twitter/TwitterService.cs new file mode 100644 index 0000000..1f11c6a --- /dev/null +++ b/src/BirdsiteLive.Twitter/TwitterService.cs @@ -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 + } +} diff --git a/src/BirdsiteLive.sln b/src/BirdsiteLive.sln index 32db4a4..d6a9101 100644 --- a/src/BirdsiteLive.sln +++ b/src/BirdsiteLive.sln @@ -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} diff --git a/src/BirdsiteLive/BirdsiteLive.csproj b/src/BirdsiteLive/BirdsiteLive.csproj index fd0c830..64c23e5 100644 --- a/src/BirdsiteLive/BirdsiteLive.csproj +++ b/src/BirdsiteLive/BirdsiteLive.csproj @@ -7,10 +7,16 @@ + + + + + + diff --git a/src/BirdsiteLive/Controllers/WellKnownController.cs b/src/BirdsiteLive/Controllers/WellKnownController.cs index 1dc58ce..247b450 100644 --- a/src/BirdsiteLive/Controllers/WellKnownController.cs +++ b/src/BirdsiteLive/Controllers/WellKnownController.cs @@ -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 settings) + public WellKnownController(IOptions settings, ITwitterService twitterService) { + _twitterService = twitterService; _settings = settings.Value; } #endregion diff --git a/src/BirdsiteLive/Program.cs b/src/BirdsiteLive/Program.cs index a90dede..c109ad2 100644 --- a/src/BirdsiteLive/Program.cs +++ b/src/BirdsiteLive/Program.cs @@ -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(); diff --git a/src/BirdsiteLive/Startup.cs b/src/BirdsiteLive/Startup.cs index b0841a6..c5aa247 100644 --- a/src/BirdsiteLive/Startup.cs +++ b/src/BirdsiteLive/Startup.cs @@ -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(Configuration.GetSection("Instance")); + //services.Configure(Configuration.GetSection("Twitter")); services.AddControllersWithViews(); } + public void ConfigureContainer(ServiceRegistry services) + { + var twitterSettings = Configuration.GetSection("Twitter").Get(); + + services.For().Use() + .Ctor("apiKey").Is(twitterSettings.ApiKey); + + services.Scan(_ => + { + _.Assembly("BirdsiteLive.Twitter"); + _.TheCallingAssembly(); + + //_.AssemblyContainingType(); + //_.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) { diff --git a/src/BirdsiteLive/appsettings.Development.json b/src/BirdsiteLive/appsettings.Development.json index bbe791a..559669d 100644 --- a/src/BirdsiteLive/appsettings.Development.json +++ b/src/BirdsiteLive/appsettings.Development.json @@ -8,5 +8,8 @@ }, "Instance": { "Domain": "domain.name" + }, + "Twitter": { + "ApiKey": "twitter.api.key" } } diff --git a/src/BirdsiteLive/appsettings.json b/src/BirdsiteLive/appsettings.json index c75a72b..b5f881b 100644 --- a/src/BirdsiteLive/appsettings.json +++ b/src/BirdsiteLive/appsettings.json @@ -8,6 +8,9 @@ }, "AllowedHosts": "*", "Instance": { - "Domain": "domain.name" + "Domain": "domain.name" + }, + "Twitter": { + "ApiKey": "twitter.api.key" } }