Skip to content

Commit

Permalink
Fix sample projects and exclude those from pack
Browse files Browse the repository at this point in the history
  • Loading branch information
Ting-Yu Lin committed Jan 30, 2020
1 parent f3cf783 commit 6257a53
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 209 deletions.
2 changes: 2 additions & 0 deletions Agoda.LoadBalancing.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ Global
{1C23FCB4-EC50-4CD2-8823-C0413E29E580}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C23FCB4-EC50-4CD2-8823-C0413E29E580}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C23FCB4-EC50-4CD2-8823-C0413E29E580}.Release|Any CPU.Build.0 = Release|Any CPU
{1C23FCB4-EC50-4CD2-8823-C0413E29E580}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33B2E81D-34AE-405F-BFDC-66E0FD2C0813}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33B2E81D-34AE-405F-BFDC-66E0FD2C0813}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33B2E81D-34AE-405F-BFDC-66E0FD2C0813}.Release|Any CPU.Build.0 = Release|Any CPU
{33B2E81D-34AE-405F-BFDC-66E0FD2C0813}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E89EAFEC-814F-4B11-8719-3A0889F6D551}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E89EAFEC-814F-4B11-8719-3A0889F6D551}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E89EAFEC-814F-4B11-8719-3A0889F6D551}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
17 changes: 0 additions & 17 deletions samples/Benchmark/Benchmark.csproj

This file was deleted.

75 changes: 0 additions & 75 deletions samples/Benchmark/Program.cs

This file was deleted.

31 changes: 0 additions & 31 deletions samples/Benchmark/RR1.cs

This file was deleted.

22 changes: 0 additions & 22 deletions samples/Benchmark/echo.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down
39 changes: 39 additions & 0 deletions samples/MultiTypedClient/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace MultiTypedClient.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}
12 changes: 2 additions & 10 deletions samples/MultiTypedClient/MultiTypedClient.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0"><PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Agoda.Frameworks.Http\Agoda.Frameworks.Http.csproj" />
</ItemGroup>

</Project>
16 changes: 9 additions & 7 deletions samples/MultiTypedClient/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace MultiTypedClient
Expand All @@ -14,11 +13,14 @@ public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
CreateHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
67 changes: 35 additions & 32 deletions samples/MultiTypedClient/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace MultiTypedClient
{
Expand All @@ -28,44 +28,47 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddControllers();
services.AddHttpClient<IStackExchangeClient, StackExchangeClient>("stackexchange", c =>
{
c.DefaultRequestHeaders.Add("Accept", "application/json");
c.DefaultRequestHeaders.Add("User-Agent", "agoda.frameworks.http.sample");
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler()
{
// Compression is required by StackExchange
// https://api.stackexchange.com/docs/compression
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
});

services.AddHttpClient<IGitHubClient, GitHubClient>("github", c =>
{
c.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3+json");
c.DefaultRequestHeaders.Add("User-Agent", "agoda.frameworks.http.sample");
c.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("token", "f762b2e8137a0b4979c4f20410ed82f32c167336");
});

services.AddHttpClient<IStackExchangeClient, StackExchangeClient>("stackexchange", c =>
{
c.DefaultRequestHeaders.Add("Accept", "application/json");
c.DefaultRequestHeaders.Add("User-Agent", "agoda.frameworks.http.sample");
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler()
{
// Compression is required by StackExchange
// https://api.stackexchange.com/docs/compression
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
});

services.AddHttpClient<IGitHubClient, GitHubClient>("github", c =>
{
c.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3+json");
c.DefaultRequestHeaders.Add("User-Agent", "agoda.frameworks.http.sample");
c.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("token", "f762b2e8137a0b4979c4f20410ed82f32c167336");
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseMvc();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
15 changes: 15 additions & 0 deletions samples/MultiTypedClient/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace MultiTypedClient
{
public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string Summary { get; set; }
}
}
18 changes: 9 additions & 9 deletions samples/MultiTypedClient/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
Loading

0 comments on commit 6257a53

Please sign in to comment.