private void LoadTableInfo()
{
ClearTableData();
bool staleCacheData;
TableDescription table = TableInfoCache.GetValue(TableName, this.DescribeTable, out staleCacheData);
this.ContainsCachedData = staleCacheData;
if (this.ContainsCachedData)
LoggerInstance.InfoFormat("Description for table [{0}] loaded from SDK Cache", TableName);
foreach (var key in table.KeySchema)
{
string keyName = key.AttributeName;
AttributeDefinition attributeDefinition = table.AttributeDefinitions
.FirstOrDefault(a => string.Equals(a.AttributeName, keyName, StringComparison.Ordinal));
if (attributeDefinition == null) throw new InvalidOperationException("No attribute definition found for key " + key.AttributeName);
KeyDescription keyDescription = new KeyDescription
{
IsHash = string.Equals(key.KeyType, "HASH", StringComparison.OrdinalIgnoreCase),
Type = GetType(attributeDefinition.AttributeType)
};
if (keyDescription.IsHash)
HashKeys.Add(keyName);
else
RangeKeys.Add(keyName);
Keys[keyName] = keyDescription;
}
if (table.LocalSecondaryIndexes != null)
{
foreach (var index in table.LocalSecondaryIndexes)
{
LocalSecondaryIndexes[index.IndexName] = index;
LocalSecondaryIndexNames.Add(index.IndexName);
}
}
if (table.GlobalSecondaryIndexes != null)
{
foreach (var index in table.GlobalSecondaryIndexes)
{
GlobalSecondaryIndexes[index.IndexName] = index;
GlobalSecondaryIndexNames.Add(index.IndexName);
}
}
foreach (var attribute in table.AttributeDefinitions)
{
Attributes.Add(attribute);
}
KeyNames = Keys.Keys.ToArray();
}