Skip to content

Commit

Permalink
Add constraint to TryGetBindingAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
liliankasem committed Jun 28, 2023
1 parent 0d47daa commit b6598dd
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;

namespace Microsoft.Azure.Functions.Worker.Converters
{
/// <summary>
Expand All @@ -14,16 +16,7 @@ public static class ConverterContextExtensions
/// <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;
}
public static bool TryGetBindingAttribute<T>(this ConverterContext context, out object? bindingAttribute) where T : Attribute
=> context.Properties.TryGetValue(PropertyBagKeys.BindingAttribute, out bindingAttribute);
}
}

0 comments on commit b6598dd

Please sign in to comment.