本文整理汇总了C#中RiakObject.ToRiakObjectId方法的典型用法代码示例。如果您正苦于以下问题:C# RiakObject.ToRiakObjectId方法的具体用法?C# RiakObject.ToRiakObjectId怎么用?C# RiakObject.ToRiakObjectId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RiakObject
的用法示例。
在下文中一共展示了RiakObject.ToRiakObjectId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestKVOperations
public void TestKVOperations()
{
const string key = "bucket_type_test_key";
var id = new RiakObjectId(TestBucketType, TestBucket, key);
var obj = new RiakObject(id, Value);
// put
var putResult = Client.Put(obj, new RiakPutOptions().SetReturnBody(true).SetDw(3));
putResult.IsSuccess.ShouldBeTrue();
putResult.Value.BucketType.ShouldEqual(TestBucketType);
// get
var getResult = Client.Get(id);
getResult.IsSuccess.ShouldBeTrue();
getResult.Value.BucketType.ShouldEqual(TestBucketType);
// delete
var deleteResult = Client.Delete(id, new RiakDeleteOptions().SetDw(3));
deleteResult.IsSuccess.ShouldBeTrue();
// multiget
var ids = new List<RiakObjectId>();
for (int i = 0; i < 3; i++)
{
obj = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key + i), Value);
Client.Put(obj, new RiakPutOptions().SetReturnBody(true).SetDw(3));
ids.Add(obj.ToRiakObjectId());
}
var multiGetResult = Client.Get(ids).ToList();
multiGetResult.All(r => r.IsSuccess).ShouldBeTrue();
multiGetResult.All(r => r.Value.BucketType == TestBucketType).ShouldBeTrue();
}
示例2: AsyncDeleteMultipleIsSuccessful
public void AsyncDeleteMultipleIsSuccessful()
{
var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);
Client.Put(one);
Client.Put(two);
var oneObjectId = one.ToRiakObjectId();
var twoObjectId = two.ToRiakObjectId();
var list = new List<RiakObjectId> { oneObjectId, twoObjectId };
var results = Client.Async.Delete(list).Result;
foreach (var riakResult in results)
{
riakResult.IsSuccess.ShouldBeTrue(riakResult.ErrorMessage);
}
var oneResult = Client.Get(oneObjectId);
oneResult.IsSuccess.ShouldBeFalse();
oneResult.ResultCode.ShouldEqual(ResultCode.NotFound);
oneResult.Value.ShouldBeNull();
var twoResult = Client.Get(twoObjectId);
twoResult.IsSuccess.ShouldBeFalse();
twoResult.ResultCode.ShouldEqual(ResultCode.NotFound);
twoResult.Value.ShouldBeNull();
}
示例3: AsyncDeleteIsSuccessful
public void AsyncDeleteIsSuccessful()
{
var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
var riakObjectId = riakObject.ToRiakObjectId();
var putResult = Client.Put(riakObject);
putResult.IsSuccess.ShouldBeTrue();
RiakResult theResult = null;
var resetEvent = new AutoResetEvent(false);
Client.Async.Delete(riakObjectId, result =>
{
theResult = result;
resetEvent.Set();
});
resetEvent.WaitOne();
theResult.IsSuccess.ShouldBeTrue();
var getResult = Client.Get(riakObjectId);
getResult.IsSuccess.ShouldBeFalse();
getResult.ResultCode.ShouldEqual(ResultCode.NotFound);
getResult.Value.ShouldBeNull();
}
示例4: ToRiakObjectIdProducesAValidRiakObjectId
public void ToRiakObjectIdProducesAValidRiakObjectId()
{
var riakObject = new RiakObject(Bucket, Key, "value");
var riakObjectId = riakObject.ToRiakObjectId();
riakObjectId.Bucket.ShouldEqual(Bucket);
riakObjectId.Key.ShouldEqual(Key);
}
示例5: AsyncDeleteIsSuccessful
public void AsyncDeleteIsSuccessful()
{
var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
var riakObjectId = riakObject.ToRiakObjectId();
var putResult = Client.Put(riakObject);
putResult.ShouldNotBeNull();
var deletedObjectId = Client.Async.Delete(riakObjectId).ConfigureAwait(false).GetAwaiter().GetResult();
var getResult = Client.Get(riakObjectId);
getResult.ShouldBeNull();
}
示例6: DeleteIsSuccessful
public void DeleteIsSuccessful()
{
var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
var riakObjectId = riakObject.ToRiakObjectId();
var putResult = Client.Put(riakObject);
putResult.IsSuccess.ShouldBeTrue(putResult.ErrorMessage);
var delResult = Client.Delete(riakObjectId);
delResult.IsSuccess.ShouldBeTrue(delResult.ErrorMessage);
var getResult = Client.Get(riakObjectId);
getResult.IsSuccess.ShouldBeFalse(getResult.ErrorMessage);
getResult.ResultCode.ShouldEqual(ResultCode.NotFound);
getResult.Value.ShouldBeNull();
}
示例7: IndexesAreSavedWithAnObject
public void IndexesAreSavedWithAnObject()
{
var o = new RiakObject(Bucket, "the_object", "{ value: \"this is an object\" }");
o.AddIndex("tacos", "are great!");
o.AddIndex("age", 12);
Client.Put(o);
var result = Client.Get(o.ToRiakObjectId());
result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
var ro = result.Value;
ro.BinIndexes.Count.ShouldEqual(1);
ro.IntIndexes.Count.ShouldEqual(1);
}
示例8: TestKVOperations
public void TestKVOperations()
{
string key = Guid.NewGuid().ToString();
var id = new RiakObjectId(TestBucketType, TestBucket, key);
var obj = new RiakObject(id, Value);
// put
var putOptions = new RiakPutOptions();
putOptions.SetReturnBody(true);
putOptions.SetDw(3);
putOptions.SetTimeout(new Timeout(TimeSpan.FromSeconds(60)));
var putResult = Client.Put(obj, putOptions);
Assert.True(putResult.IsSuccess, putResult.ErrorMessage);
Assert.AreEqual(TestBucketType, putResult.Value.BucketType);
// get
var getResult = Client.Get(id);
Assert.True(getResult.IsSuccess);
Assert.AreEqual(TestBucketType, getResult.Value.BucketType);
// delete
var deleteOptions = new RiakDeleteOptions();
deleteOptions.Vclock = getResult.Value.VectorClock;
deleteOptions.SetDw(3);
var deleteResult = Client.Delete(id, new RiakDeleteOptions().SetDw(3));
Assert.True(deleteResult.IsSuccess);
// multiget
var ids = new List<RiakObjectId>();
for (int i = 0; i < 3; i++)
{
obj = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key + i), Value);
Client.Put(obj, new RiakPutOptions().SetReturnBody(false).SetDw(3));
ids.Add(obj.ToRiakObjectId());
}
var multiGetResult = Client.Get(ids).ToList();
Assert.True(multiGetResult.All(r => r.IsSuccess));
Assert.True(multiGetResult.All(r => r.Value.BucketType == TestBucketType));
}
示例9: AsyncDeleteMultipleIsSuccessful
public void AsyncDeleteMultipleIsSuccessful()
{
var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);
Client.Put(one);
Client.Put(two);
var oneObjectId = one.ToRiakObjectId();
var twoObjectId = two.ToRiakObjectId();
IEnumerable<RiakResult> theResults = null;
var list = new List<RiakObjectId> { oneObjectId, twoObjectId };
var resetEvent = new AutoResetEvent(false);
Client.Async.Delete(list, results =>
{
theResults = results;
resetEvent.Set();
});
resetEvent.WaitOne();
foreach (var riakResult in theResults)
{
riakResult.IsSuccess.ShouldBeTrue();
}
var oneResult = Client.Get(oneObjectId);
oneResult.IsSuccess.ShouldBeFalse();
oneResult.ResultCode.ShouldEqual(ResultCode.NotFound);
oneResult.Value.ShouldBeNull();
var twoResult = Client.Get(twoObjectId);
twoResult.IsSuccess.ShouldBeFalse();
twoResult.ResultCode.ShouldEqual(ResultCode.NotFound);
twoResult.Value.ShouldBeNull();
}
示例10: AsyncDeleteMultipleIsSuccessful
public void AsyncDeleteMultipleIsSuccessful()
{
var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);
Client.Put(one).ShouldNotBeNull();
Client.Put(two).ShouldNotBeNull();
var oneObjectId = one.ToRiakObjectId();
var twoObjectId = two.ToRiakObjectId();
var list = new List<RiakObjectId> { oneObjectId, twoObjectId };
var deletedObjectIds = Client.Async.Delete(list)
.ToEnumerable()
.ToList();
deletedObjectIds.Count().ShouldEqual(2);
var oneResult = Client.Get(oneObjectId);
oneResult.ShouldBeNull();
var twoResult = Client.Get(twoObjectId);
twoResult.ShouldBeNull();
}
示例11: AsyncGetWithRiakObjectIdReturnsData
public void AsyncGetWithRiakObjectIdReturnsData()
{
var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
var riakObjectId = riakObject.ToRiakObjectId();
Client.Put(riakObject);
var result = Client.Async.Get(riakObjectId).ConfigureAwait(false).GetAwaiter().GetResult();
result.IsLeft.ShouldBeFalse();
var updatedRiakObject = result.Right;
updatedRiakObject.Bucket.ShouldEqual(TestBucket);
updatedRiakObject.Key.ShouldEqual(TestKey);
updatedRiakObject.Value.FromRiakString().ShouldEqual(TestJson);
}
示例12: AsyncGetWithRiakObjectIdReturnsData
public void AsyncGetWithRiakObjectIdReturnsData()
{
var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
var riakObjectId = riakObject.ToRiakObjectId();
Client.Put(riakObject);
var result = Client.Async.Get(riakObjectId).Result;
result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
result.Value.ShouldNotBeNull();
result.Value.Bucket.ShouldEqual(TestBucket);
result.Value.Key.ShouldEqual(TestKey);
result.Value.Value.FromRiakString().ShouldEqual(TestJson);
}
示例13: DeleteIsSuccessful
public void DeleteIsSuccessful()
{
var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
var riakObjectId = riakObject.ToRiakObjectId();
var putResult = Client.Put(riakObject);
putResult.ShouldNotBeNull();
Client.Delete(riakObjectId).ShouldNotBeNull();
var getResult = Client.Get(riakObjectId);
getResult.ShouldBeNull();
}
示例14: DeleteIsSuccessfulInBatch
public void DeleteIsSuccessfulInBatch()
{
Client.Batch(batch =>
{
var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
var riakObjectId = riakObject.ToRiakObjectId();
var putResult = batch.Put(riakObject);
putResult.ShouldNotBeNull();
var delResult = batch.Delete(riakObjectId);
delResult.ShouldNotBeNull();
var getResult = batch.Get(riakObjectId);
getResult.ShouldBeNull();
});
}
示例15: IndexesAreSavedWithAnObject
public void IndexesAreSavedWithAnObject()
{
var o = new RiakObject(Bucket, "the_object", "{ value: \"this is an object\" }");
o.BinIndex("tacos").Set("are great!");
o.IntIndex("age").Set(12);
Client.Put(o);
var result = Client.Get(o.ToRiakObjectId());
result.BinIndexes.Count.ShouldEqual(1);
result.IntIndexes.Count.ShouldEqual(1);
result.BinIndex("tacos").Values[0].ShouldEqual("are great!");
result.IntIndex("age").Values[0].ShouldEqual(12);
}