本文整理汇总了C#中Amazon.DynamoDBv2.AmazonDynamoDBConfig类的典型用法代码示例。如果您正苦于以下问题:C# AmazonDynamoDBConfig类的具体用法?C# AmazonDynamoDBConfig怎么用?C# AmazonDynamoDBConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AmazonDynamoDBConfig类属于Amazon.DynamoDBv2命名空间,在下文中一共展示了AmazonDynamoDBConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectAmazonDynamoDB
public AmazonDynamoDBClient ConnectAmazonDynamoDB(string ConnectionString)
{
var config = new AmazonDynamoDBConfig();
config.ServiceURL = ConnectionString;
var client = new AmazonDynamoDBClient(config);
return client;
}
示例2: DynamoDBSink
public DynamoDBSink(IFormatProvider formatProvider, string tableName) :base(1000, TimeSpan.FromSeconds(15))
{
_formatProvider = formatProvider;
_tableName = tableName;
AmazonDynamoDbConfig = new AmazonDynamoDBConfig();
OperationConfig = new DynamoDBOperationConfig {OverrideTableName = tableName};
}
示例3: Main
static void Main(string[] args)
{
var awsKey = "my-aws-key";
var awsSecret = "my-aws-secret";
var config = new AmazonDynamoDBConfig { ServiceURL = "http://localhost:8000" };
var client = new AmazonDynamoDBClient(awsKey, awsSecret, config);
var ctx = new DynamoDBContext(client);
var userId = "theburningmonk-1";
// query examples
QueryByHashKey(userId, client, ctx);
QueryWithRangeKey(userId, client, ctx);
QueryWithOrderAndLimit(userId, client, ctx);
QueryWithNoConsistentRead(userId, client, ctx);
ThrottlingWithQueryPageSize(userId, client, ctx);
SelectSpecificAttributes(userId, client, ctx);
QueryWithNoReturnedConsumedCapacity(userId, client);
QueryWithLocalSecondaryIndexAllAttributes(userId, client, ctx);
QueryWithLocalSecondaryIndexProjectedAttributes(userId, client, ctx);
QueryWithGlobalSecondaryIndexProjectedAttributes(client, ctx);
// scan examples
BasicScan(client, ctx);
ScanWithLimit(client, ctx);
ThrottlingWithScanPageSize(client, ctx);
ScanWithScanPageSizeAndSegments(client, ctx);
ScanWithNoReturnedConsumedCapacity(client);
SelectSpecificAttributes(client, ctx);
Console.WriteLine("all done...");
Console.ReadKey();
}
示例4: Load
protected override void Load(ContainerBuilder builder)
{
var config = new AmazonDynamoDBConfig();
config.RegionEndpoint = Amazon.RegionEndpoint.APSoutheast2;
var client = new AmazonDynamoDBClient(config);
builder.Register(c => client).As<IAmazonDynamoDB>();
builder.RegisterType<SessionsRepository>().As<ISessionsRepository>();
}
示例5: NotesDataContext
static NotesDataContext()
{
// creating a DynamoDb client in some region (AmazonDynamoDBClient is thread-safe and can be reused
var dynamoDbConfig = new AmazonDynamoDBConfig { RegionEndpoint = RegionEndpoint.APSoutheast1 };
DynamoDbClient = new AmazonDynamoDBClient(dynamoDbConfig);
// creating a MemcacheD client (it's thread-safe and can be reused)
CacheClient = new MemcachedClient();
// creating tables
CreateTablesIfTheyDoNotExist();
}
示例6: GetPinWithPinID
public Dictionary<string, object> GetPinWithPinID(string owner, double pinDate)
{
Dictionary<string, object> retval = new Dictionary<string, object>();
QueryResponse response;
var config = new AmazonDynamoDBConfig();
config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"];
client = new AmazonDynamoDBClient(config);
try
{
QueryRequest request = new QueryRequest()
{
TableName = "Pin",
KeyConditions = new Dictionary<string, Condition>()
{
{
"Owner",
new Condition()
{
ComparisonOperator = ComparisonOperator.EQ,
AttributeValueList = new List<AttributeValue> { new AttributeValue { S = owner } }
}
},
{
"PinDate",
new Condition()
{
ComparisonOperator = ComparisonOperator.EQ,
AttributeValueList = new List<AttributeValue> { new AttributeValue { N = pinDate.ToString() } }
}
}
}
};
response = client.Query(request);
retval.Add("Title", response.Items[0]["Title"].S);
retval.Add("Owner", response.Items[0]["Owner"].S);
retval.Add("OwnerName", response.Items[0]["UserName"].S);
retval.Add("OwnerHeadshot", response.Items[0]["HeadshotURL"].S);
retval.Add("Latitude", response.Items[0]["Latitude"].S);
retval.Add("Longitude", response.Items[0]["Longitude"].S);
retval.Add("PinDate", Convert.ToDouble(response.Items[0]["PinDate"].N));
retval.Add("Images", response.Items[0]["Images"].SS);
}
catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); }
catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
catch (Exception e) { Console.WriteLine(e.Message); }
return retval;
}
示例7: CheckUserIsExist
public bool CheckUserIsExist(string userID)
{
var config = new AmazonDynamoDBConfig();
GetItemResponse response;
config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"];
client = new AmazonDynamoDBClient(config);
bool retval = false;
try
{
GetItemRequest request = new GetItemRequest
{
TableName = "User",
Key = new Dictionary<string, AttributeValue>() { { "UserID", new AttributeValue { S = userID } } },
ReturnConsumedCapacity = "TOTAL"
};
response = client.GetItem(request);
retval = response.Item.Count > 0;
}
catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); }
catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
catch (Exception e) { Console.WriteLine(e.Message); }
return retval;
}
示例8: AmazonDynamoDBClient
/// <summary>
/// Constructs AmazonDynamoDBClient with AWS Credentials and an
/// AmazonDynamoDBClient Configuration object.
/// </summary>
/// <param name="credentials">AWS Credentials</param>
/// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param>
public AmazonDynamoDBClient(AWSCredentials credentials, AmazonDynamoDBConfig clientConfig)
: base(credentials, clientConfig)
{
}
示例9: AmazonDynamoDBClient
/// <summary>
/// Constructs AmazonDynamoDBClient with AWS Credentials and an
/// AmazonDynamoDBClient Configuration object.
/// </summary>
/// <param name="credentials">AWS Credentials</param>
/// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param>
public AmazonDynamoDBClient(AWSCredentials credentials, AmazonDynamoDBConfig clientConfig)
: base(credentials, clientConfig, false, AuthenticationTypes.User | AuthenticationTypes.Session)
{
}
示例10: AmazonDynamoDBClient
/// <summary>
/// Constructs AmazonDynamoDBClient with the credentials loaded from the application's
/// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
///
/// Example App.config with credentials set.
/// <code>
/// <?xml version="1.0" encoding="utf-8" ?>
/// <configuration>
/// <appSettings>
/// <add key="AWSProfileName" value="AWS Default"/>
/// </appSettings>
/// </configuration>
/// </code>
///
/// </summary>
/// <param name="config">The AmazonDynamoDBClient Configuration Object</param>
public AmazonDynamoDBClient(AmazonDynamoDBConfig config)
: base(FallbackCredentialsFactory.GetCredentials(), config) { }
示例11: GetPinWithUserID
public List<Dictionary<string, object>> GetPinWithUserID(string userID, double since, int takeCnt)
{
List<Dictionary<string, object>> retval = new List<Dictionary<string, object>>();
Dictionary<string, object> tmpObject = null;
QueryResponse response = null;
var config = new AmazonDynamoDBConfig();
config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"];
client = new AmazonDynamoDBClient(config);
try
{
QueryRequest query = new QueryRequest()
{
TableName = "Pin",
KeyConditions = new Dictionary<string, Condition>()
{
{
"Owner",
new Condition()
{
ComparisonOperator = ComparisonOperator.EQ,
AttributeValueList = new List<AttributeValue> { new AttributeValue { S = userID } }
}
},
{
"PinDate",
new Condition()
{
ComparisonOperator = ComparisonOperator.LT,
AttributeValueList = new List<AttributeValue> { new AttributeValue { N = since.ToString() } }
}
}
},
Limit = takeCnt,
ScanIndexForward = false
};
response = client.Query(query);
foreach (var item in response.Items)
{
tmpObject = new Dictionary<string, object>();
tmpObject.Add("Title", item["Title"].S);
tmpObject.Add("Owner", item["Owner"].S);
tmpObject.Add("OwnerName", item["UserName"].S);
tmpObject.Add("OwnerHeadshot", item["HeadshotURL"].S);
tmpObject.Add("Latitude", item["Latitude"].S);
tmpObject.Add("Longitude", item["Longitude"].S);
tmpObject.Add("PinDate", Convert.ToDouble(item["PinDate"].N));
tmpObject.Add("Images", item["Images"].SS);
retval.Add(tmpObject);
}
}
catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); }
catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
catch (Exception e) { Console.WriteLine(e.Message); }
return retval;
}
示例12: DynamoDBTruncateErrorTest
public async Task DynamoDBTruncateErrorTest()
{
var config = new AmazonDynamoDBConfig
{
RegionEndpoint = RegionEndpoint.USEast1,
LogResponse = true
};
AmazonDynamoDBClient client = new AmazonDynamoDBClient(config);
var tableName= await SetupTable(client);
try
{
var table = Table.LoadTable(client, tableName);
await InsertData(table, "445", _body);
var body = await ReadData(table, "445");
Assert.Equal(_body, body);
}
finally
{
await DeleteTable(client, tableName);
}
}
示例13: TestLargeRetryCount
public void TestLargeRetryCount()
{
var maxRetries = 1000;
var maxMilliseconds = 1;
ClientConfig config = new AmazonDynamoDBConfig();
config.MaxErrorRetry = 100;
var coreRetryPolicy = new DefaultRetryPolicy(config)
{
MaxBackoffInMilliseconds = maxMilliseconds
};
var ddbRetryPolicy = new DynamoDBRetryPolicy(config)
{
MaxBackoffInMilliseconds = maxMilliseconds
};
var context = new ExecutionContext(new RequestContext(false), null);
for (int i = 0; i < maxRetries; i++)
{
context.RequestContext.Retries = i;
coreRetryPolicy.WaitBeforeRetry(context);
ddbRetryPolicy.WaitBeforeRetry(context);
}
}
示例14: CreateAmazonDynamoDBClient
/// <summary>
/// Create a client for the Amazon DynamoDB Service with the credentials loaded from the application's
/// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
///
/// Example App.config with credentials set.
/// <code>
/// <?xml version="1.0" encoding="utf-8" ?>
/// <configuration>
/// <appSettings>
/// <add key="AWSAccessKey" value="********************"/>
/// <add key="AWSSecretKey" value="****************************************"/>
/// </appSettings>
/// </configuration>
/// </code>
/// </summary>
/// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc</param>
/// <returns>An Amazon DynamoDB client</returns>
public static IAmazonDynamoDB CreateAmazonDynamoDBClient(AmazonDynamoDBConfig config)
{
return new AmazonDynamoDBClient(config);
}
示例15: CreateAmazonDynamoDBClient
/// <summary>
/// Create a client for the Amazon DynamoDB Service with the specified configuration
/// </summary>
/// <param name="awsAccessKey">The AWS Access Key associated with the account</param>
/// <param name="awsSecretAccessKey">The AWS Secret Access Key associated with the account</param>
/// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc
/// </param>
/// <returns>An Amazon DynamoDB client</returns>
/// <remarks>
/// </remarks>
public static IAmazonDynamoDB CreateAmazonDynamoDBClient(
string awsAccessKey,
string awsSecretAccessKey, AmazonDynamoDBConfig config
)
{
return new AmazonDynamoDBClient(awsAccessKey, awsSecretAccessKey, config);
}