-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fbaf92
commit a867b61
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/DotNetWorker.Core/Converters/Converter/ConverterContextExtensions.cs
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,29 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.Azure.Functions.Worker.Converters | ||
{ | ||
/// <summary> | ||
/// Provides extension methods to work with an <see cref="ConverterContext"/> instance. | ||
/// </summary> | ||
public static class ConverterContextExtensions | ||
{ | ||
/// <summary> | ||
/// Tries to retrieve the binding attribute from the <see cref="ConverterContext"/>. | ||
/// </summary> | ||
/// <param name="context">The converter context.</param> | ||
/// <param name="bindingAttribute">When this method returns, contains the binding attribute if found; otherwise, <c>null</c>.</param> | ||
/// <returns><c>true</c> if the binding attribute is found in the converter context; otherwise, <c>false</c>.</returns> | ||
public static bool TryGetBindingAttribute(this ConverterContext context, out object? bindingAttribute) | ||
{ | ||
if (context.Properties.TryGetValue(PropertyBagKeys.BindingAttribute, out object? value)) | ||
{ | ||
bindingAttribute = value; | ||
return true; | ||
} | ||
|
||
bindingAttribute = null; | ||
return false; | ||
} | ||
} | ||
} |