private TableItem( Dictionary<string, Tuple<object, Type>> properties, bool throwOnReservedProperties )
{
Properties = new Dictionary<string, Tuple<object, Type>>();
foreach ( string propertyName in properties.Keys )
{
if ( !TableConstants.ReservedPropertyNames.Contains( propertyName ) )
{
Properties[propertyName] = properties[propertyName];
}
else if ( throwOnReservedProperties )
{
throw new InvalidEntityException( string.Format( "Reserved property name {0}", propertyName ) );
}
else if ( propertyName == TableConstants.PartitionKey )
{
var partitionKeyProperty = properties[propertyName];
if ( partitionKeyProperty.Item2 != typeof( string ) )
{
throw new InvalidEntityException( string.Format( "PartitionKey property must be a string but was a {0}", partitionKeyProperty.Item2 ) );
}
PartitionKey = (string) partitionKeyProperty.Item1;
}
else if ( propertyName == TableConstants.RowKey )
{
var rowKeyProperty = properties[propertyName];
if ( rowKeyProperty.Item2 != typeof( string ) )
{
throw new InvalidEntityException( string.Format( "RowKey property must be a string but was a {0}", rowKeyProperty.Item2 ) );
}
RowKey = (string) rowKeyProperty.Item1;
}
else if ( propertyName == TableConstants.ETag )
{
var eTagProperty = properties[propertyName];
ETag = eTagProperty.Item1;
}
}
}