public TableEntityToPocoConverter()
 {
     TableClientHelpers.VerifyDefaultConstructor(typeof(TOutput));
     ValidateSetter("PartitionKey", PocoTypeBinder.PartitionKeyTypes);
     ValidateSetter("RowKey", PocoTypeBinder.RowKeyTypes);
     ValidateSetter("Timestamp", PocoTypeBinder.TimestampTypes);
     ValidateSetter("ETag", PocoTypeBinder.ETagTypes);
 }
            public ObjectToITableEntityConverter()
            {
                // JObject case should have been claimed by another converter.
                // So we can statically enforce an ITableEntity compatible contract
                var t = typeof(TElement);

                TableClientHelpers.VerifyContainsProperty(t, "RowKey");
                TableClientHelpers.VerifyContainsProperty(t, "PartitionKey");
            }
 public TableEntityBinding(string parameterName, IArgumentBinding <TableEntityContext> argumentBinding,
                           TableServiceClient client, IBindableTableEntityPath path)
 {
     _parameterName   = parameterName;
     _argumentBinding = argumentBinding;
     _client          = client;
     _accountName     = TableClientHelpers.GetAccountName(client);
     _path            = path;
     _converter       = CreateConverter(client, path);
 }
        public TableEntityPath Bind(IReadOnlyDictionary <string, object> bindingData)
        {
            string tableName    = _tableNameTemplate.Bind(bindingData);
            string partitionKey = _partitionKeyTemplate.Bind(bindingData);
            string rowKey       = _rowKeyTemplate.Bind(bindingData);

            TableClientHelpers.ValidateAzureTableName(tableName);
            TableClientHelpers.ValidateAzureTableKeyValue(partitionKey);
            TableClientHelpers.ValidateAzureTableKeyValue(rowKey);
            return(new TableEntityPath(tableName, partitionKey, rowKey));
        }
        public Task <IValueProvider> BindAsync(object value, ValueBindingContext context)
        {
            TableEntityContext entityContext = null;

            if (!_converter.TryConvert(value, out entityContext))
            {
                throw new InvalidOperationException("Unable to convert value to TableEntityContext.");
            }

            TableClientHelpers.ValidateAzureTableKeyValue(entityContext.PartitionKey);
            TableClientHelpers.ValidateAzureTableKeyValue(entityContext.RowKey);
            return(BindEntityAsync(entityContext, context));
        }
Exemplo n.º 6
0
        public IArgumentBinding <TableEntityContext> TryCreate(ParameterInfo parameter)
        {
            if (parameter.ParameterType.IsByRef)
            {
                return(null);
            }

            if (parameter.ParameterType.ContainsGenericParameters)
            {
                return(null);
            }

            TableClientHelpers.VerifyDefaultConstructor(parameter.ParameterType);
            return(CreateBinding(parameter.ParameterType));
        }
        public static IBindableTableEntityPath Create(string tableNamePattern, string partitionKeyPattern,
                                                      string rowKeyPattern)
        {
            BindingTemplate tableNameTemplate    = BindingTemplate.FromString(tableNamePattern);
            BindingTemplate partitionKeyTemplate = BindingTemplate.FromString(partitionKeyPattern);
            BindingTemplate rowKeyTemplate       = BindingTemplate.FromString(rowKeyPattern);

            if (tableNameTemplate.HasParameters ||
                partitionKeyTemplate.HasParameters ||
                rowKeyTemplate.HasParameters)
            {
                return(new ParameterizedTableEntityPath(tableNameTemplate, partitionKeyTemplate, rowKeyTemplate));
            }

            TableClientHelpers.ValidateAzureTableName(tableNamePattern);
            TableClientHelpers.ValidateAzureTableKeyValue(partitionKeyPattern);
            TableClientHelpers.ValidateAzureTableKeyValue(rowKeyPattern);
            TableEntityPath innerPath = new TableEntityPath(tableNamePattern, partitionKeyPattern, rowKeyPattern);

            return(new BoundTableEntityPath(innerPath));
        }
Exemplo n.º 8
0
        public static bool TryParseAndValidate(string value, out TableEntityPath path)
        {
            if (value == null)
            {
                path = null;
                return(false);
            }

            string[] components = value.Split(new char[] { '/' });
            if (components.Length != 3)
            {
                path = null;
                return(false);
            }

            string tableName    = components[0];
            string partitionKey = components[1];
            string rowKey       = components[2];

            if (!TableClientHelpers.IsValidAzureTableName(tableName))
            {
                path = null;
                return(false);
            }

            if (!TableClientHelpers.IsValidAzureTableKeyValue(partitionKey))
            {
                path = null;
                return(false);
            }

            if (!TableClientHelpers.IsValidAzureTableKeyValue(rowKey))
            {
                path = null;
                return(false);
            }

            path = new TableEntityPath(tableName, partitionKey, rowKey);
            return(true);
        }