-
Notifications
You must be signed in to change notification settings - Fork 754
/
BindingSourceAttribute.cs
29 lines (24 loc) · 1.04 KB
/
BindingSourceAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.Collections.Generic;
using TechTalk.SpecFlow.Bindings.Reflection;
namespace TechTalk.SpecFlow.IdeIntegration.Bindings
{
public class BindingSourceAttribute
{
public IBindingType AttributeType { get; set; }
public IBindingSourceAttributeValueProvider[] AttributeValues { get; set; }
public IDictionary<string, IBindingSourceAttributeValueProvider> NamedAttributeValues { get; set; }
public TValue TryGetAttributeValue<TValue>(int index, TValue defaultValue = default(TValue))
{
if (AttributeValues.Length >= index)
return AttributeValues[index].GetValue<TValue>();
return defaultValue;
}
public TValue TryGetAttributeValue<TValue>(string name, TValue defaultValue = default(TValue))
{
IBindingSourceAttributeValueProvider valueProvider;
if (NamedAttributeValues.TryGetValue(name, out valueProvider))
return valueProvider.GetValue<TValue>();
return defaultValue;
}
}
}