Skip to content

Commit ed925c3

Browse files
committed
Various updates
1 parent 75e862b commit ed925c3

File tree

44 files changed

+349
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+349
-87
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,5 @@ UpgradeLog*.XML
141141
/Snek2015AngularWebApiSample/WebClient/fonts
142142
/Snek2015AngularWebApiSample/WebClient/scripts
143143
*.backup
144+
145+
nupkg

AngularSvgServer/simple-server.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as WebSocket from 'ws';
2+
3+
// Create WebSockets server listening on port 3000
4+
const wss = new WebSocket.Server({port: 3000});
5+
6+
wss.on('connection', ws => {
7+
// Called whenever a new client connects
8+
9+
// Add handler for incoming messages
10+
ws.on('message', message => console.log('received: %s', message));
11+
12+
// Send text message to new client
13+
ws.send('Welcome!');
14+
});

AspNetCoreWorkshop/80-webapi/DataModel/DataModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public Customer()
2424
[Required(AllowEmptyStrings = false)]
2525
public string CompanyName { get; set; }
2626

27+
public string CompanyRegNumber { get; set; }
28+
2729
[MaxLength(2)]
2830
[Required(AllowEmptyStrings = false)]
2931
public string CountryIsoCode { get; set; }

AspNetCoreWorkshop/80-webapi/DataModel/DataModel.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
<ItemGroup>
88
<Reference Include="System.ComponentModel.Annotations">
9-
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2\System.ComponentModel.Annotations.dll</HintPath>
109
</Reference>
1110
</ItemGroup>
1211

AspNetCoreWorkshop/80-webapi/WebApi/Controllers/CustomersController.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.AspNetCore.Mvc;
77
using Microsoft.EntityFrameworkCore;
88
using DataModel;
9+
using WebApiDemo;
910

1011
namespace WebApiDemo.Controllers
1112
{
@@ -20,24 +21,15 @@ public CustomersController(OrderManagementContext context)
2021
_context = context;
2122
}
2223

23-
/// <summary>
24-
/// Gets a list of all customers
25-
/// </summary>
26-
/// <returns>List of customers</returns>
24+
// GET: api/Customers
2725
[HttpGet]
2826
public async Task<ActionResult<IEnumerable<Customer>>> GetCustomers()
2927
{
3028
return await _context.Customers.ToListAsync();
3129
}
3230

33-
/// <summary>
34-
/// Gets a customer by ID
35-
/// </summary>
36-
/// <param name="id">ID of the customer to return</param>
37-
/// <returns>Customer with the given ID</returns>
31+
// GET: api/Customers/5
3832
[HttpGet("{id}")]
39-
[ProducesResponseType(typeof(Customer), StatusCodes.Status200OK)]
40-
[ProducesResponseType(StatusCodes.Status404NotFound)]
4133
public async Task<ActionResult<Customer>> GetCustomer(Guid id)
4234
{
4335
var customer = await _context.Customers.FindAsync(id);

AspNetCoreWorkshop/80-webapi/WebApi/Migrations/20190721073541_Initial.Designer.cs renamed to AspNetCoreWorkshop/80-webapi/WebApi/Migrations/20190723113840_Initial.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AspNetCoreWorkshop/80-webapi/WebApi/Migrations/20190723114103_Add Company reg. number.Designer.cs

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
namespace WebApiDemo.Migrations
4+
{
5+
public partial class AddCompanyregnumber : Migration
6+
{
7+
protected override void Up(MigrationBuilder migrationBuilder)
8+
{
9+
migrationBuilder.AddColumn<string>(
10+
name: "CompanyRegNumber",
11+
table: "Customers",
12+
nullable: true);
13+
}
14+
15+
protected override void Down(MigrationBuilder migrationBuilder)
16+
{
17+
migrationBuilder.DropColumn(
18+
name: "CompanyRegNumber",
19+
table: "Customers");
20+
}
21+
}
22+
}

AspNetCoreWorkshop/80-webapi/WebApi/Migrations/OrderManagementContextModelSnapshot.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
2828
.IsRequired()
2929
.HasMaxLength(200);
3030

31+
b.Property<string>("CompanyRegNumber");
32+
3133
b.Property<string>("CountryIsoCode")
3234
.IsRequired()
3335
.HasMaxLength(2);

AspNetCoreWorkshop/80-webapi/WebApi/OrderManagementContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.Extensions.Logging.Console;
55
using System;
66
using System.Threading.Tasks;
7+
using System.Linq;
78

89
namespace WebApiDemo
910
{

AspNetCoreWorkshop/80-webapi/WebApi/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public static int Main(string[] args)
1515
// (see https://github.com/serilog/serilog-aspnetcore/blob/dev/samples/EarlyInitializationSample/Program.cs)
1616

1717
Log.Logger = new LoggerConfiguration()
18-
.MinimumLevel.Debug()
19-
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
20-
.Enrich.FromLogContext()
21-
.WriteTo.Console()
22-
.WriteTo.Seq("http://localhost:5341")
23-
.CreateLogger();
18+
.MinimumLevel.Debug()
19+
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
20+
.Enrich.FromLogContext()
21+
.WriteTo.Console()
22+
.WriteTo.Seq("http://localhost:5341")
23+
.CreateLogger();
2424

2525
try
2626
{

AspNetCoreWorkshop/80-webapi/WebApi/Startup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public void ConfigureServices(IServiceCollection services)
2424
// Update database with: dotnet ef database update
2525
services.AddDbContext<OrderManagementContext>(options => options.UseSqlServer(
2626
Configuration["ConnectionStrings:DefaultConnection"]));
27+
System.Console.WriteLine(Configuration["ConnectionStrings:DefaultConnection"]);
2728

2829
// Add Open API generation using NSwag
2930
// See also https://github.com/RicoSuter/NSwag/wiki/AspNetCore-Middleware

AspNetCoreWorkshop/80-webapi/WebApi/WebApiDemo.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@
2424
<ProjectReference Include="..\DataModel\DataModel.csproj" />
2525
</ItemGroup>
2626

27+
<ItemGroup>
28+
<WCFMetadata Include="Connected Services" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<Folder Include="Connected Services\Application Insights\" />
33+
</ItemGroup>
34+
2735
</Project>

AzureFunctions/Serverless.pptx

1.35 KB
Binary file not shown.

AzureFunctions/TrafficMonitor/TrafficMonitorFunctionApp/TrafficMonitorFunctionApp/TrafficMonitorFunctionApp.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.1</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageReference Include="Microsoft.Azure.DocumentDB" Version="2.6.0" />
8-
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.6.0" />
7+
<PackageReference Include="Microsoft.Azure.DocumentDB" Version="2.9.3" />
8+
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.9.3" />
99
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
10-
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.3" />
11-
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.6" />
12-
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.8" />
13-
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
14-
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
10+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.1.1" />
11+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.0" />
12+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
13+
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.2" />
14+
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
1515
</ItemGroup>
1616
<ItemGroup>
1717
<None Update="host.json">

AzureFunctions/TrafficMonitor/requests.http

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ GET {{ localhost }}/api/SayHello?name=Tom
2222
POST http://localhost:7071/api/generate-demo-data
2323

2424
###
25-
POST https://srvlstrafficmonitor.azurewebsites.net/api/generate-demo-data
25+
POST https://srvlstrafficmonitor.azurewebsites.net/api/generate-demo-data
26+
27+
###
28+
POST https://62d61df3.ngrok.io/api/slackapproval

AzureKeyVault/NetCoreDemo/NetCoreDemo/NetCoreDemo.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<UserSecretsId>37c639ca-777a-4f3c-b133-6e64efaa7d7d</UserSecretsId>
56
</PropertyGroup>
67

78
<ItemGroup>
@@ -11,7 +12,7 @@
1112
<ItemGroup>
1213
<PackageReference Include="Microsoft.AspNetCore.App" />
1314
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.1.0-preview" />
14-
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.0-rc1-final" />
15+
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.1" />
1516
</ItemGroup>
1617

1718
</Project>

AzureKeyVault/demo-x5c.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDBTCCAe2gAwI...
3+
-----END CERTIFICATE-----

BeyondREST/BeyondREST/SignalRIntroduction/SignalRIntroduction.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8+
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.2.2" />
89
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.0.96" />
910
</ItemGroup>
1011

546 KB
Binary file not shown.
156 KB
Binary file not shown.

CSharp7/Span/Program.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ static void Main()
1414
//SpanBasics();
1515
//UnmanagedBasics();
1616

17+
//MemoryBasics();
18+
1719
//BadIdeas();
1820

1921
// Learning: With Span<T>, you can write methods supporting any kind of memory
@@ -194,6 +196,31 @@ static void UnmanagedBasics()
194196
}
195197
}
196198

199+
static void MemoryBasics()
200+
{
201+
static void DoSomethingWithSpan(Span<byte> bytes)
202+
{
203+
bytes[^1] = (byte)(bytes[^2] + bytes[^3]);
204+
foreach (var number in bytes) Console.WriteLine(number);
205+
}
206+
207+
Memory<byte> bytes = new byte[] { 1, 2, 3, 0 };
208+
DoSomethingWithSpan(bytes.Span);
209+
210+
IntPtr ptr = Marshal.AllocHGlobal(1024);
211+
try
212+
{
213+
using var memMgr = new UnmanagedMemoryManager<byte>(ptr, bytes.Length + 1);
214+
Memory<byte> unmanagedBytes = memMgr.Memory;
215+
bytes.CopyTo(unmanagedBytes);
216+
DoSomethingWithSpan(unmanagedBytes.Span);
217+
}
218+
finally
219+
{
220+
Marshal.FreeHGlobal(ptr);
221+
}
222+
}
223+
197224
// Note that Color is a mutable(!) struct
198225
private struct Color
199226
{

0 commit comments

Comments
 (0)