-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recreate function, move from newtonsoft, add some tests
- Loading branch information
1 parent
8614683
commit c8f3a9a
Showing
27 changed files
with
276 additions
and
128 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
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
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
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 @@ | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
var host = new HostBuilder() | ||
.ConfigureFunctionsWebApplication() | ||
.ConfigureServices(services => | ||
{ | ||
services.AddApplicationInsightsTelemetryWorkerService(); | ||
services.ConfigureFunctionsApplicationInsights(); | ||
}) | ||
.Build(); | ||
|
||
host.Run(); |
18 changes: 0 additions & 18 deletions
18
LuasAPI.AzureFunction/Properties/PublishProfiles/LuasAPIFunction - Zip Deploy.pubxml
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
{ | ||
"dependencies": { | ||
"appInsights1": { | ||
"type": "appInsights" | ||
}, | ||
"storage1": { | ||
"type": "storage", | ||
"connectionId": "AzureWebJobsStorage" | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
LuasAPI.AzureFunction/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,11 @@ | ||
{ | ||
"dependencies": { | ||
"appInsights1": { | ||
"type": "appInsights.sdk" | ||
}, | ||
"storage1": { | ||
"type": "storage.emulator", | ||
"connectionId": "AzureWebJobsStorage" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
{ | ||
"version": "2.0" | ||
} | ||
"version": "2.0", | ||
"logging": { | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
}, | ||
"enableLiveMetricsFilters": true | ||
} | ||
} | ||
} |
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
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
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
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,74 @@ | ||
// Code below from https://khalidabuhakmeh.com/systemtextjson-jsonconverter-test-helpers. Thanks! | ||
|
||
namespace LuasAPI.NET.Tests | ||
{ | ||
using System.IO; | ||
using System; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
public static class JsonConverterTestExtensions | ||
{ | ||
public static TResult? Read<TResult>( | ||
this JsonConverter<TResult> converter, | ||
string token, | ||
JsonSerializerOptions? options = null) | ||
{ | ||
options ??= JsonSerializerOptions.Default; | ||
var bytes = Encoding.UTF8.GetBytes(token); | ||
var reader = new Utf8JsonReader(bytes); | ||
// advance to token | ||
reader.Read(); | ||
var result = converter.Read(ref reader, typeof(TResult), options); | ||
// did we get the result? | ||
return result; | ||
} | ||
|
||
public static (bool IsSuccessful, TResult? Result) TryRead<TResult>( | ||
this JsonConverter<TResult> converter, | ||
string token, | ||
JsonSerializerOptions? options = null) | ||
{ | ||
try | ||
{ | ||
var result = Read(converter, token, options); | ||
return (true, result); | ||
} | ||
catch (Exception) | ||
{ | ||
return (IsSuccessful: false, Result: default); | ||
} | ||
} | ||
|
||
public static string Write<T>( | ||
this JsonConverter<T> converter, | ||
T value, | ||
JsonSerializerOptions? options = null) | ||
{ | ||
options ??= JsonSerializerOptions.Default; | ||
using var ms = new MemoryStream(); | ||
using var writer = new Utf8JsonWriter(ms); | ||
converter.Write(writer, value, options); | ||
writer.Flush(); | ||
var result = Encoding.UTF8.GetString(ms.ToArray()); | ||
return result; | ||
} | ||
|
||
public static (bool IsSuccessful, string? Result) TryWrite<T>( | ||
this JsonConverter<T> converter, | ||
T value, | ||
JsonSerializerOptions? options = null) | ||
{ | ||
try | ||
{ | ||
var result = Write(converter, value, options); | ||
return (true, result); | ||
} | ||
catch | ||
{ | ||
return (false, null); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.