本文整理汇总了C#中Dictionary.String方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.String方法的具体用法?C# Dictionary.String怎么用?C# Dictionary.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dictionary
的用法示例。
在下文中一共展示了Dictionary.String方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrySetHeaderParameter
internal void TrySetHeaderParameter(string parameterName, Dictionary<string, object> parameters)
{
if (parameters.ContainsKey(parameterName))
{
Headers.Add(parameterName, parameters.String(parameterName));
}
}
示例2: Should_replace_edge_with_waitForSync
public void Should_replace_edge_with_waitForSync()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some string")
.Int("bar", 12345);
var createResult = db.Edge
.Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document);
var newDocument = new Dictionary<string, object>()
.String("foo", "some other new string")
.Int("baz", 54321);
var replaceResult = db.Edge
.WaitForSync(true)
.Replace(createResult.Value.String("_id"), newDocument);
Assert.AreEqual(201, replaceResult.StatusCode);
Assert.IsTrue(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.AreEqual(replaceResult.Value.String("_id"), createResult.Value.String("_id"));
Assert.AreEqual(replaceResult.Value.String("_key"), createResult.Value.String("_key"));
Assert.AreNotEqual(replaceResult.Value.String("_rev"), createResult.Value.String("_rev"));
var getResult = db.Edge
.Get(replaceResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_id"), replaceResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_key"), replaceResult.Value.String("_key"));
Assert.AreEqual(getResult.Value.String("_rev"), replaceResult.Value.String("_rev"));
Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), newDocument.String("foo"));
Assert.AreEqual(getResult.Value.Int("baz"), newDocument.Int("baz"));
Assert.IsFalse(getResult.Value.Has("bar"));
}
示例3: Should_replace_edge_with_ifMatch_and_return_412
public void Should_replace_edge_with_ifMatch_and_return_412()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some string")
.Int("bar", 12345);
var createResult = db.Edge
.Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document);
document.Merge(createResult.Value);
var newDocument = new Dictionary<string, object>()
.String("foo", "some other new string")
.Int("baz", 54321);
var replaceResult = db.Edge
.IfMatch("123456789")
.Replace(createResult.Value.String("_id"), newDocument);
Assert.AreEqual(412, replaceResult.StatusCode);
Assert.IsFalse(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.AreEqual(replaceResult.Value.String("_id"), document.String("_id"));
Assert.AreEqual(replaceResult.Value.String("_key"), document.String("_key"));
Assert.AreEqual(replaceResult.Value.String("_rev"), document.String("_rev"));
}
示例4: Should_get_edge_as_generic_object
public void Should_get_edge_as_generic_object()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "foo string value")
.Int("bar", 12345);
var createResult = db.Edge
.Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document);
var getResult = db.Edge
.Get<Dummy>(createResult.Value.String("_id"));
Assert.AreEqual(200, getResult.StatusCode);
Assert.IsTrue(getResult.Success);
Assert.IsTrue(getResult.HasValue);
Assert.AreEqual(document.String("foo"), getResult.Value.Foo);
Assert.AreEqual(document.Int("bar"), getResult.Value.Bar);
Assert.AreEqual(0, getResult.Value.Baz);
}
示例5: Should_create_edge
public void Should_create_edge()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "foo string value")
.Int("bar", 12345);
var createResult = db.Edge
.Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document);
Assert.AreEqual(202, createResult.StatusCode);
Assert.IsTrue(createResult.Success);
Assert.IsTrue(createResult.HasValue);
Assert.IsTrue(createResult.Value.IsString("_id"));
Assert.IsTrue(createResult.Value.IsString("_key"));
Assert.IsTrue(createResult.Value.IsString("_rev"));
var getResult = db.Edge
.Get(createResult.Value.String("_id"));
Assert.AreEqual(200, getResult.StatusCode);
Assert.IsTrue(getResult.Success);
Assert.IsTrue(getResult.HasValue);
Assert.AreEqual(getResult.Value.String("_id"), createResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_key"), createResult.Value.String("_key"));
Assert.AreEqual(getResult.Value.String("_rev"), createResult.Value.String("_rev"));
Assert.IsTrue(getResult.Value.IsString("_from"));
Assert.IsTrue(getResult.Value.IsString("_to"));
Assert.AreEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.AreEqual(getResult.Value.Int("bar"), document.Int("bar"));
}
示例6: Should_update_document_with_keepNull
public void Should_update_document_with_keepNull()
{
var db = new ADatabase(Database.Alias);
var newDocument = new Dictionary<string, object>()
.String("foo", "some string")
.Object("bar", null);
var createResult = db.Document
.Create(Database.TestDocumentCollectionName, newDocument);
newDocument.Merge(createResult.Value);
var document = new Dictionary<string, object>()
.String("foo", "some other new string")
.Object("baz", null);
var updateResult = db.Document
.KeepNull(false)
.Update(newDocument.ID(), document);
Assert.AreEqual(202, updateResult.StatusCode);
Assert.IsTrue(updateResult.Success);
Assert.IsTrue(updateResult.HasValue);
Assert.AreEqual(updateResult.Value.ID(), newDocument.ID());
Assert.AreEqual(updateResult.Value.Key(), newDocument.Key());
Assert.AreNotEqual(updateResult.Value.Rev(), newDocument.Rev());
var getResult = db.Document
.Get(updateResult.Value.ID());
Assert.AreEqual(getResult.Value.ID(), updateResult.Value.ID());
Assert.AreEqual(getResult.Value.Key(), updateResult.Value.Key());
Assert.AreEqual(getResult.Value.Rev(), updateResult.Value.Rev());
Assert.AreNotEqual(getResult.Value.String("foo"), newDocument.String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.IsTrue(getResult.Value.Has("bar"));
Assert.IsFalse(getResult.Value.Has("baz"));
}
示例7: Create
/// <summary>
/// Creates index within specified collection in current database context.
/// </summary>
public AResult<Dictionary<string, object>> Create(string collectionName)
{
var request = new Request(HttpMethod.POST, ApiBaseUri.Index, "");
var bodyDocument = new Dictionary<string, object>();
// required
request.QueryString.Add(ParameterName.Collection, collectionName);
// required
bodyDocument.String(ParameterName.Type, _parameters.String(ParameterName.Type));
switch (_parameters.Enum<AIndexType>(ParameterName.Type))
{
case AIndexType.Cap:
Request.TrySetBodyParameter(ParameterName.ByteSize, _parameters, bodyDocument);
Request.TrySetBodyParameter(ParameterName.Size, _parameters, bodyDocument);
break;
case AIndexType.Fulltext:
Request.TrySetBodyParameter(ParameterName.Fields, _parameters, bodyDocument);
Request.TrySetBodyParameter(ParameterName.MinLength, _parameters, bodyDocument);
break;
case AIndexType.Geo:
Request.TrySetBodyParameter(ParameterName.Fields, _parameters, bodyDocument);
Request.TrySetBodyParameter(ParameterName.GeoJson, _parameters, bodyDocument);
break;
case AIndexType.Hash:
Request.TrySetBodyParameter(ParameterName.Fields, _parameters, bodyDocument);
Request.TrySetBodyParameter(ParameterName.Sparse, _parameters, bodyDocument);
Request.TrySetBodyParameter(ParameterName.Unique, _parameters, bodyDocument);
break;
case AIndexType.Skiplist:
Request.TrySetBodyParameter(ParameterName.Fields, _parameters, bodyDocument);
Request.TrySetBodyParameter(ParameterName.Sparse, _parameters, bodyDocument);
Request.TrySetBodyParameter(ParameterName.Unique, _parameters, bodyDocument);
break;
default:
break;
}
request.Body = JSON.ToJSON(bodyDocument, ASettings.JsonParameters);
var response = _connection.Send(request);
var result = new AResult<Dictionary<string, object>>(response);
switch (response.StatusCode)
{
case 200:
case 201:
if (response.DataType == DataType.Document)
{
result.Value = (response.Data as Dictionary<string, object>);
result.Success = (result.Value != null);
}
break;
case 400:
case 404:
default:
// Arango error
break;
}
_parameters.Clear();
return result;
}
示例8: Should_update_document_with_mergeArrays_set_to_false
public void Should_update_document_with_mergeArrays_set_to_false()
{
var db = new ADatabase(Database.Alias);
var newDocument = new Dictionary<string, object>()
.String("foo", "some string")
.Document("bar", new Dictionary<string, object>().String("foo", "string value"));
var createResult = db.Document
.Create(Database.TestDocumentCollectionName, newDocument);
newDocument.Merge(createResult.Value);
var document = new Dictionary<string, object>()
.String("foo", "some other new string")
.Document("bar", new Dictionary<string, object>().String("bar", "other string value"));
var updateResult = db.Document
.MergeObjects(false)
.Update(newDocument.String("_id"), document);
Assert.AreEqual(202, updateResult.StatusCode);
Assert.IsTrue(updateResult.Success);
Assert.IsTrue(updateResult.HasValue);
Assert.AreEqual(updateResult.Value.String("_id"), newDocument.String("_id"));
Assert.AreEqual(updateResult.Value.String("_key"), newDocument.String("_key"));
Assert.AreNotEqual(updateResult.Value.String("_rev"), newDocument.String("_rev"));
var getResult = db.Document
.Get(updateResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_id"), updateResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_key"), updateResult.Value.String("_key"));
Assert.AreEqual(getResult.Value.String("_rev"), updateResult.Value.String("_rev"));
Assert.AreNotEqual(getResult.Value.String("foo"), newDocument.String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.IsFalse(getResult.Value.Has("bar.foo"));
Assert.IsTrue(getResult.Value.Has("bar.bar"));
}
示例9: Should_create_document_with_custom_ID
public void Should_create_document_with_custom_ID()
{
Database.ClearTestCollection(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("_key", "1234-5678")
.String("foo", "foo string value")
.Int("bar", 12345);
var createResult = db.Document
.Create(Database.TestDocumentCollectionName, document);
Assert.AreEqual(202, createResult.StatusCode);
Assert.IsTrue(createResult.Success);
Assert.IsTrue(createResult.HasValue);
Assert.AreEqual(Database.TestDocumentCollectionName + "/" + document.String("_key"), createResult.Value.String("_id"));
Assert.AreEqual(document.String("_key"), createResult.Value.String("_key"));
Assert.IsTrue(createResult.Value.IsString("_rev"));
}
示例10: Should_replace_document_with_ifMatch_and_lastUpdatePolicy
public void Should_replace_document_with_ifMatch_and_lastUpdatePolicy()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some other new string")
.Int("baz", 54321);
var replaceResult = db.Document
.IfMatch("123456789", AUpdatePolicy.Last)
.Replace(documents[0].String("_id"), document);
Assert.AreEqual(202, replaceResult.StatusCode);
Assert.IsTrue(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.AreEqual(replaceResult.Value.String("_id"), documents[0].String("_id"));
Assert.AreEqual(replaceResult.Value.String("_key"), documents[0].String("_key"));
Assert.AreNotEqual(replaceResult.Value.String("_rev"), documents[0].String("_rev"));
var getResult = db.Document
.Get(replaceResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_id"), replaceResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_key"), replaceResult.Value.String("_key"));
Assert.AreEqual(getResult.Value.String("_rev"), replaceResult.Value.String("_rev"));
Assert.AreNotEqual(getResult.Value.String("foo"), documents[0].String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.AreEqual(getResult.Value.Int("baz"), document.Int("baz"));
Assert.IsFalse(getResult.Value.Has("bar"));
}
示例11: Should_replace_edge_with_ifMatch
public void Should_replace_edge_with_ifMatch()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some string")
.Int("bar", 12345);
var createResult = db
.Document
.CreateEdge(Database.TestEdgeCollectionName, _documents[0].ID(), _documents[1].ID(), document);
document.Merge(createResult.Value);
var newDocument = new Dictionary<string, object>()
.From(_documents[0].ID())
.To(_documents[1].ID())
.String("foo", "some other new string")
.Int("baz", 54321);
var replaceResult = db
.Document
.IfMatch(document.Rev())
.Replace(createResult.Value.ID(), newDocument);
Assert.AreEqual(202, replaceResult.StatusCode);
Assert.IsTrue(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.AreEqual(replaceResult.Value.ID(), document.ID());
Assert.AreEqual(replaceResult.Value.Key(), document.Key());
Assert.AreNotEqual(replaceResult.Value.Rev(), document.Rev());
var getResult = db
.Document
.Get(replaceResult.Value.ID());
Assert.AreEqual(getResult.Value.ID(), replaceResult.Value.ID());
Assert.AreEqual(getResult.Value.Key(), replaceResult.Value.Key());
Assert.AreEqual(getResult.Value.Rev(), replaceResult.Value.Rev());
Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), newDocument.String("foo"));
Assert.AreEqual(getResult.Value.Int("baz"), newDocument.Int("baz"));
Assert.IsFalse(getResult.Value.Has("bar"));
}
示例12: Should_replace_edge_with_generic_object
public void Should_replace_edge_with_generic_object()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some string")
.Int("bar", 12345);
var createResult = db
.Document
.CreateEdge(Database.TestEdgeCollectionName, _documents[0].ID(), _documents[1].ID(), document);
var dummy = new Dummy();
dummy.Foo = "some other new string";
dummy.Baz = 54321;
var replaceResult = db
.Document
.ReplaceEdge(createResult.Value.ID(), _documents[0].ID(), _documents[1].ID(), dummy);
Assert.AreEqual(202, replaceResult.StatusCode);
Assert.IsTrue(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.AreEqual(replaceResult.Value.ID(), createResult.Value.ID());
Assert.AreEqual(replaceResult.Value.Key(), createResult.Value.Key());
Assert.AreNotEqual(replaceResult.Value.Rev(), createResult.Value.Rev());
var getResult = db
.Document
.Get(replaceResult.Value.ID());
Assert.AreEqual(getResult.Value.ID(), replaceResult.Value.ID());
Assert.AreEqual(getResult.Value.Key(), replaceResult.Value.Key());
Assert.AreEqual(getResult.Value.Rev(), replaceResult.Value.Rev());
Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), dummy.Foo);
Assert.AreEqual(getResult.Value.Int("baz"), dummy.Baz);
Assert.AreEqual(0, getResult.Value.Int("bar"));
}
示例13: Should_create_edge_with_returnNew_parameter
public void Should_create_edge_with_returnNew_parameter()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.From(_documents[0].ID())
.To(_documents[1].ID())
.String("foo", "foo string value")
.Int("bar", 12345);
var createResult = db
.Document
.ReturnNew()
.CreateEdge(Database.TestEdgeCollectionName, document);
Assert.AreEqual(202, createResult.StatusCode);
Assert.IsTrue(createResult.Success);
Assert.IsTrue(createResult.HasValue);
Assert.IsTrue(createResult.Value.IsString("_id"));
Assert.IsTrue(createResult.Value.IsString("_key"));
Assert.IsTrue(createResult.Value.IsString("_rev"));
Assert.IsTrue(createResult.Value.Has("new"));
Assert.AreEqual(createResult.Value.ID(), createResult.Value.String("new._id"));
Assert.AreEqual(createResult.Value.Key(), createResult.Value.String("new._key"));
Assert.AreEqual(createResult.Value.Rev(), createResult.Value.String("new._rev"));
Assert.AreEqual(document.String("_from"), createResult.Value.String("new._from"));
Assert.AreEqual(document.String("_to"), createResult.Value.String("new._to"));
Assert.AreEqual(document.String("foo"), createResult.Value.String("new.foo"));
Assert.AreEqual(document.Int("bar"), createResult.Value.Int("new.bar"));
}
示例14: Should_update_edge_with_generic_object
public void Should_update_edge_with_generic_object()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some string")
.Int("bar", 12345);
var createResult = db.Edge
.Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document);
var dummy = new Dummy();
dummy.Foo = "some other new string";
dummy.Bar = 54321;
dummy.Baz = 12345;
var updateResult = db.Edge
.Update(createResult.Value.String("_id"), dummy);
Assert.AreEqual(202, updateResult.StatusCode);
Assert.IsTrue(updateResult.Success);
Assert.IsTrue(updateResult.HasValue);
Assert.AreEqual(updateResult.Value.String("_id"), createResult.Value.String("_id"));
Assert.AreEqual(updateResult.Value.String("_key"), createResult.Value.String("_key"));
Assert.AreNotEqual(updateResult.Value.String("_rev"), createResult.Value.String("_rev"));
var getResult = db.Edge
.Get(updateResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_id"), updateResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_key"), updateResult.Value.String("_key"));
Assert.AreEqual(getResult.Value.String("_rev"), updateResult.Value.String("_rev"));
Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), dummy.Foo);
Assert.AreNotEqual(getResult.Value.Int("bar"), document.Int("bar"));
Assert.AreEqual(getResult.Value.Int("bar"), dummy.Bar);
Assert.AreEqual(getResult.Value.Int("baz"), dummy.Baz);
}
示例15: Should_update_document_with_waitForSync
public void Should_update_document_with_waitForSync()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some other new string")
.Int("bar", 54321)
.Int("baz", 12345);
var updateResult = db.Document
.WaitForSync(true)
.Update(documents[0].String("_id"), document);
Assert.AreEqual(201, updateResult.StatusCode);
Assert.IsTrue(updateResult.Success);
Assert.IsTrue(updateResult.HasValue);
Assert.AreEqual(updateResult.Value.String("_id"), documents[0].String("_id"));
Assert.AreEqual(updateResult.Value.String("_key"), documents[0].String("_key"));
Assert.AreNotEqual(updateResult.Value.String("_rev"), documents[0].String("_rev"));
var getResult = db.Document
.Get(updateResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_id"), updateResult.Value.String("_id"));
Assert.AreEqual(getResult.Value.String("_key"), updateResult.Value.String("_key"));
Assert.AreEqual(getResult.Value.String("_rev"), updateResult.Value.String("_rev"));
Assert.AreNotEqual(getResult.Value.String("foo"), documents[0].String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.AreNotEqual(getResult.Value.Int("bar"), documents[0].Int("bar"));
Assert.AreEqual(getResult.Value.Int("bar"), document.Int("bar"));
Assert.AreEqual(getResult.Value.Int("baz"), document.Int("baz"));
}