public Task <IBinding> TryCreateAsync(BindingProviderContext context) { if (context == null) { throw new ArgumentNullException("context"); } // Determine whether we should bind to the current parameter ParameterInfo parameter = context.Parameter; ProjectionAttribute attribute = parameter.GetCustomAttribute <ProjectionAttribute>(inherit: false); if (attribute == null) { return(Task.FromResult <IBinding>(null)); } // What data type(s) can this attribute be attached to? IEnumerable <Type> supportedTypes = new Type[] { typeof(Projection) }; if (!(parameter.ParameterType == typeof(Projection))) { throw new InvalidOperationException( $"Can't bind ProjectionAttribute to type '{parameter.ParameterType}'."); } return(Task.FromResult <IBinding>(new ProjectionAttributeBinding(parameter, _eventStreamSettings))); }
public async Task <object> GetValueAsync() { object item = null; await ValidateParameter(_parameter); if (null != _parameter) { ProjectionAttribute attribute = _parameter.GetCustomAttribute <ProjectionAttribute>(inherit: false); if (null != attribute) { item = new Projection(attribute, settings: _eventStreamSettings); } } return(item); }