Skip to content

Commit

Permalink
Use more succinct pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
commonsensesoftware committed Apr 14, 2024
1 parent 4bd1c2d commit 8eec498
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions examples/AspNet/OData/OpenApiODataWebApiExample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public void Configuration( IAppBuilder builder )
description.Append( " This API version has been deprecated." );
}
if ( group.SunsetPolicy is SunsetPolicy policy )
if ( group.SunsetPolicy is { } policy )
{
if ( policy.Date is DateTimeOffset when )
if ( policy.Date is { } when )
{
description.Append( " The API will be sunset on " )
.Append( when.Date.ToShortDateString() )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace ApiVersioning.Examples;

using Asp.Versioning;
using Asp.Versioning.Conventions;
using Microsoft.AspNet.OData.Extensions;
using Microsoft.Extensions.Primitives;
Expand Down Expand Up @@ -93,9 +92,9 @@ public void Configuration( IAppBuilder builder )
description.Append( " This API version has been deprecated." );
}
if ( group.SunsetPolicy is SunsetPolicy policy )
if ( group.SunsetPolicy is { } policy )
{
if ( policy.Date is DateTimeOffset when )
if ( policy.Date is { } when )
{
description.Append( " The API will be sunset on " )
.Append( when.Date.ToShortDateString() )
Expand Down
5 changes: 2 additions & 3 deletions examples/AspNet/WebApi/OpenApiWebApiExample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using System.Web.Http;
using System.Web.Http.Description;
using System.Web.Http.Routing;
using static System.Net.Mime.MediaTypeNames;

/// <summary>
/// Represents the startup process for the application.
Expand Down Expand Up @@ -77,9 +76,9 @@ public void Configuration( IAppBuilder builder )
description.Append( " This API version has been deprecated." );
}
if ( group.SunsetPolicy is SunsetPolicy policy )
if ( group.SunsetPolicy is { } policy )
{
if ( policy.Date is DateTimeOffset when )
if ( policy.Date is { } when )
{
description.Append( " The API will be sunset on " )
.Append( when.Date.ToShortDateString() )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace ApiVersioning.Examples;

using Asp.Versioning;
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -51,9 +50,9 @@ private static OpenApiInfo CreateInfoForApiVersion( ApiVersionDescription descri
text.Append( " This API version has been deprecated." );
}

if ( description.SunsetPolicy is SunsetPolicy policy )
if ( description.SunsetPolicy is { } policy )
{
if ( policy.Date is DateTimeOffset when )
if ( policy.Date is { } when )
{
text.Append( " The API will be sunset on " )
.Append( when.Date.ToShortDateString() )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace ApiVersioning.Examples;

using Asp.Versioning;
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -51,9 +50,9 @@ private static OpenApiInfo CreateInfoForApiVersion( ApiVersionDescription descri
text.Append( " This API version has been deprecated." );
}

if ( description.SunsetPolicy is SunsetPolicy policy )
if ( description.SunsetPolicy is { } policy )
{
if ( policy.Date is DateTimeOffset when )
if ( policy.Date is { } when )
{
text.Append( " The API will be sunset on " )
.Append( when.Date.ToShortDateString() )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace ApiVersioning.Examples;

using Asp.Versioning;
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -51,9 +50,9 @@ private static OpenApiInfo CreateInfoForApiVersion( ApiVersionDescription descri
text.Append( " This API version has been deprecated." );
}

if ( description.SunsetPolicy is SunsetPolicy policy )
if ( description.SunsetPolicy is { } policy )
{
if ( policy.Date is DateTimeOffset when )
if ( policy.Date is { } when )
{
text.Append( " The API will be sunset on " )
.Append( when.Date.ToShortDateString() )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace ApiVersioning.Examples;

using Asp.Versioning;
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -51,9 +50,9 @@ private static OpenApiInfo CreateInfoForApiVersion( ApiVersionDescription descri
text.Append( " This API version has been deprecated." );
}

if ( description.SunsetPolicy is SunsetPolicy policy )
if ( description.SunsetPolicy is { } policy )
{
if ( policy.Date is DateTimeOffset when )
if ( policy.Date is { } when )
{
text.Append( " The API will be sunset on " )
.Append( when.Date.ToShortDateString() )
Expand Down

0 comments on commit 8eec498

Please sign in to comment.