private IBinding TryCreate(BindingProviderContext context) { ParameterInfo parameter = context.Parameter; var tableAttribute = TypeUtility.GetResolvedAttribute <TableAttribute>(context.Parameter); if (tableAttribute == null) { return(null); } // JArray is bound by the next binding if (parameter.ParameterType == typeof(JArray)) { return(null); } string tableName = Resolve(tableAttribute.TableName); var account = _accountProvider.Get(tableAttribute.Connection, _nameResolver); bool bindsToEntireTable = tableAttribute.RowKey == null; if (bindsToEntireTable) { // This should have been caught by the other rule-based binders. // We never expect this to get thrown. throw new InvalidOperationException("Can't bind Table to type '" + parameter.ParameterType + "'."); } string partitionKey = Resolve(tableAttribute.PartitionKey); string rowKey = Resolve(tableAttribute.RowKey); IBindableTableEntityPath path = BindableTableEntityPath.Create(tableName, partitionKey, rowKey); path.ValidateContractCompatibility(context.BindingDataContract); IArgumentBinding <TableEntityContext> argumentBinding = TryCreatePocoBinding(parameter, _converterManager); if (argumentBinding == null) { throw new InvalidOperationException("Can't bind Table entity to type '" + parameter.ParameterType + "'."); } return(new TableEntityBinding(parameter.Name, argumentBinding, account, path)); }
// Get the storage table from the attribute. private TableClient GetTable(TableAttribute attribute) { var account = _accountProvider.Get(attribute.Connection); return(account.GetTableClient(attribute.TableName)); }