本文整理汇总了C#中BsonArray类的典型用法代码示例。如果您正苦于以下问题:C# BsonArray类的具体用法?C# BsonArray怎么用?C# BsonArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BsonArray类属于命名空间,在下文中一共展示了BsonArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public void Load(BulkLoad load)
{
var tasks = new Task[load.Collections.Count];
int i = 0;
foreach (var pair in load.Collections)
{
var bulkCollection = pair.Value;
var collectionName = pair.Key;
var keys = bulkCollection.Documents.Keys;
var bsonIdArray = new BsonArray(keys);
var collection = _mongoDatabase.GetCollection(bulkCollection.CollectionType, collectionName);
tasks[i] = Task.Factory.StartNew(() =>
{
MongoCursor cursor = collection.FindAs(bulkCollection.CollectionType, Query.In("_id", bsonIdArray));
foreach (var doc in cursor)
{
var id = _metadata.GetDocumentId(doc);
bulkCollection.Documents[id] = doc;
}
});
i++;
}
Task.WaitAll(tasks);
}
示例2: Build
public override void Build(MongoDB.Bson.BsonDocument bsonPanelSetOrder, int panelSetId)
{
base.Build(bsonPanelSetOrder, panelSetId);
string reportNo = bsonPanelSetOrder.GetValue("ReportNo").ToString();
MongoCollection surgicalSpecimenTable = this.m_SQLTransferDatabase.GetCollection<BsonDocument>("tblSurgicalSpecimen");
MongoCursor mongoCursor = surgicalSpecimenTable.FindAs<BsonDocument>(Query.EQ("ReportNo", reportNo));
BsonArray bsonArray = new BsonArray();
foreach (BsonDocument bsonSurgicalSpecimen in mongoCursor)
{
string surgicalSpecimenId = bsonSurgicalSpecimen.GetValue("SurgicalSpecimenId").AsString;
this.BuildIC(bsonSurgicalSpecimen, surgicalSpecimenId);
this.BuildStainResult(bsonSurgicalSpecimen, surgicalSpecimenId);
this.BuildICD9BillingCode(bsonSurgicalSpecimen, surgicalSpecimenId);
bsonArray.Add(bsonSurgicalSpecimen);
}
bsonPanelSetOrder.Add("SurgicalSpecimenCollection", bsonArray);
MongoCollection surgicalAuditTable = this.m_SQLTransferDatabase.GetCollection<BsonDocument>("tblSurgicalAudit");
MongoCursor surgicalAuditCursor = surgicalAuditTable.FindAs<BsonDocument>(Query.EQ("ReportNo", reportNo));
BsonArray surgicalAuditArray = new BsonArray();
foreach (BsonDocument bsonSurgicalAudit in surgicalAuditCursor)
{
string surgicalAuditId = bsonSurgicalAudit.GetValue("SurgicalAuditId").AsString;
this.BuildSurgicalSpecimenAudit(bsonSurgicalAudit, surgicalAuditId);
surgicalAuditArray.Add(bsonSurgicalAudit);
}
bsonPanelSetOrder.Add("SurgicalAuditCollection", surgicalAuditArray);
}
示例3: Serialize
public BsonDocument Serialize(Scope scope)
{
var doc = new BsonDocument();
doc["_id"] = scope.Name;
doc["_version"] = 1;
doc.SetIfNotNull("displayName", scope.DisplayName);
var claims = new BsonArray();
foreach (ScopeClaim scopeClaim in scope.Claims)
{
var claim = new BsonDocument();
claim["name"] = scopeClaim.Name;
claim["alwaysIncludeInIdToken"] = scopeClaim.AlwaysIncludeInIdToken;
claim.SetIfNotNull("description", scopeClaim.Description);
claims.Add(claim);
}
doc["claims"] = claims;
doc.SetIfNotNull("claimsRule", scope.ClaimsRule);
doc.SetIfNotNull("description", scope.Description);
doc["emphasize"] = scope.Emphasize;
doc["enabled"] = scope.Enabled;
doc["includeAllClaimsForUser"] = scope.IncludeAllClaimsForUser;
doc["required"] = scope.Required;
doc["showInDiscoveryDocument"] = scope.ShowInDiscoveryDocument;
doc["type"] = scope.Type.ToString();
return doc;
}
示例4: TestAllBsonArray
public void TestAllBsonArray()
{
var array = new BsonArray { 2, 4, null, 6 }; // null will be skipped due to functional construction semantics
var query = Query.All("j", array);
var expected = "{ \"j\" : { \"$all\" : [2, 4, 6] } }";
Assert.AreEqual(expected, query.ToJson());
}
示例5: TestMapBsonArray
public void TestMapBsonArray() {
var value = new BsonArray();
var bsonValue = (BsonArray) BsonTypeMapper.MapToBsonValue(value);
Assert.AreSame(value, bsonValue);
var bsonArray = (BsonArray) BsonTypeMapper.MapToBsonValue(value, BsonType.Array);
Assert.AreSame(value, bsonArray);
}
示例6: AddField
public static void AddField(this BsonDocument doc, string name, object value)
{
if (value == null) return;
var unifiedName = name.ToLower();
switch (unifiedName)
{
case "exception":
doc[name] = BuildExceptionBsonDocument((Exception)value); break;
case "properties":
var properties = (IDictionary<object, object>)value;
if (properties.Count > 0)
doc[name] = BuildPropertiesBsonDocument(properties);
break;
case "parameters":
var parameters = (object[])value;
BsonArray array = new BsonArray();
foreach (var param in parameters)
{
array.Add(SafeCreateBsonValue(param));
}
doc[name] = array;
break;
default:
doc[name] = SafeCreateBsonValue(value);
break;
}
}
示例7: GetRolesByDBName
/// <summary>
/// 获得数据库角色
/// </summary>
/// <param name="DatabaseName"></param>
/// <returns></returns>
public BsonArray GetRolesByDBName(String DatabaseName)
{
BsonArray roles = new BsonArray();
//当前DB的System.user的角色
if (UserList.ContainsKey(DatabaseName)) {
roles = UserList[DatabaseName].roles;
}
///Admin的OtherDBRoles和当前数据库角色合并
BsonArray adminRoles = GetOtherDBRoles(DatabaseName);
foreach (String item in adminRoles)
{
if (!roles.Contains(item)) {
roles.Add(item);
}
}
///ADMIN的ANY系角色的追加
if (UserList.ContainsKey(MongoDBHelper.DATABASE_NAME_ADMIN)) {
if (UserList[MongoDBHelper.DATABASE_NAME_ADMIN].roles.Contains(MongoDBHelper.UserRole_dbAdminAnyDatabase)){
roles.Add(MongoDBHelper.UserRole_dbAdminAnyDatabase);
}
if (UserList[MongoDBHelper.DATABASE_NAME_ADMIN].roles.Contains(MongoDBHelper.UserRole_readAnyDatabase))
{
roles.Add(MongoDBHelper.UserRole_readAnyDatabase);
}
if (UserList[MongoDBHelper.DATABASE_NAME_ADMIN].roles.Contains(MongoDBHelper.UserRole_readWriteAnyDatabase))
{
roles.Add(MongoDBHelper.UserRole_readWriteAnyDatabase);
}
if (UserList[MongoDBHelper.DATABASE_NAME_ADMIN].roles.Contains(MongoDBHelper.UserRole_userAdminAnyDatabase))
{
roles.Add(MongoDBHelper.UserRole_userAdminAnyDatabase);
}
}
return roles;
}
示例8: Deserialize
// public methods
/// <summary>
/// Deserializes an object from a BsonReader.
/// </summary>
/// <param name="bsonReader">The BsonReader.</param>
/// <param name="nominalType">The nominal type of the object.</param>
/// <param name="actualType">The actual type of the object.</param>
/// <param name="options">The serialization options.</param>
/// <returns>An object.</returns>
public override object Deserialize(
BsonReader bsonReader,
Type nominalType,
Type actualType,
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(BsonArray));
var bsonType = bsonReader.GetCurrentBsonType();
switch (bsonType)
{
case BsonType.Array:
bsonReader.ReadStartArray();
var array = new BsonArray();
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
var value = (BsonValue)BsonValueSerializer.Instance.Deserialize(bsonReader, typeof(BsonValue), null);
array.Add(value);
}
bsonReader.ReadEndArray();
return array;
default:
var message = string.Format("Cannot deserialize BsonArray from BsonType {0}.", bsonType);
throw new FileFormatException(message);
}
}
示例9: CreateDoc
private BsonDocument CreateDoc()
{
// create same object, but using BsonDocument
var doc = new BsonDocument();
doc["_id"] = 123;
doc["FirstString"] = "BEGIN this string \" has \" \t and this \f \n\r END";
doc["CustomerId"] = Guid.NewGuid();
doc["Date"] = DateTime.Now;
doc["MyNull"] = null;
doc["EmptyObj"] = new BsonDocument();
doc["EmptyString"] = "";
doc["maxDate"] = DateTime.MaxValue;
doc["minDate"] = DateTime.MinValue;
doc.Set("Customer.Address.Street", "Av. Caçapava, Nº 122");
doc["Items"] = new BsonArray();
doc["Items"].AsArray.Add(new BsonDocument());
doc["Items"].AsArray[0].AsDocument["Qtd"] = 3;
doc["Items"].AsArray[0].AsDocument["Description"] = "Big beer package";
doc["Items"].AsArray[0].AsDocument["Unit"] = (double)10 / (double)3;
doc["Items"].AsArray.Add("string-one");
doc["Items"].AsArray.Add(null);
doc["Items"].AsArray.Add(true);
doc["Items"].AsArray.Add(DateTime.Now);
return doc;
}
示例10: GetAllCategories
public IEnumerable<Category> GetAllCategories(string[] categoryColors)
{
var colorArray = new BsonArray(categoryColors);
var query = Query.In("Color", colorArray);
return Categories.FindAs<Category>(query).ToList();
}
示例11: ConvertTreeNodeTozTreeBsonDoc
/// <summary>
/// </summary>
/// <param name="SubNode"></param>
/// <returns></returns>
public static BsonDocument ConvertTreeNodeTozTreeBsonDoc(TreeNode SubNode)
{
var SingleNode = new BsonDocument();
SingleNode.Add("name", SubNode.Text + GetTagText(SubNode));
if (SubNode.Nodes.Count == 0)
{
SingleNode.Add("icon", "MainTreeImage" + String.Format("{0:00}", SubNode.ImageIndex) + ".png");
}
else
{
var ChildrenList = new BsonArray();
foreach (TreeNode item in SubNode.Nodes)
{
ChildrenList.Add(ConvertTreeNodeTozTreeBsonDoc(item));
}
SingleNode.Add("children", ChildrenList);
SingleNode.Add("icon", "MainTreeImage" + String.Format("{0:00}", SubNode.ImageIndex) + ".png");
}
if (SubNode.IsExpanded)
{
SingleNode.Add("open", "true");
}
if (SubNode.Tag != null)
{
SingleNode.Add("click",
"ShowData('" + SystemManager.GetTagType(SubNode.Tag.ToString()) + "','" +
SystemManager.GetTagData(SubNode.Tag.ToString()) + "')");
}
return SingleNode;
}
示例12: add_doc_array_to_node
public void add_doc_array_to_node(BsonArray array, ref TreeNode node_father)
{
for (int i = 0; i < array.Count; i++)
{
switch (array[i].BsonType)
{
case BsonType.Document:
TreeNode node_doc = new TreeNode();
node_doc.Text = i.ToString();
add_doc_to_node(array[i].AsBsonDocument, ref node_doc);
node_father.Nodes.Add(node_doc);
break;
case BsonType.Array:
TreeNode node_array = new TreeNode();
node_array.Text = i.ToString();
add_doc_array_to_node(array[i].AsBsonArray, ref node_array);
node_father.Nodes.Add(node_array);
break;
default:
TreeNode node = new TreeNode();
node.Text = array[i].ToString();
node_father.Nodes.Add(node);
break;
}
}
}
示例13: CreateDoc
private BsonDocument CreateDoc()
{
// create same object, but using BsonDocument
var doc = new BsonDocument();
doc["_id"] = 123;
doc["FirstString"] = "BEGIN this string \" has \" \t and this \f \n\r END";
doc["CustomerId"] = Guid.NewGuid();
doc["Date"] = new DateTime(2015, 1, 1);
doc["MyNull"] = null;
doc["Items"] = new BsonArray();
doc["MyObj"] = new BsonDocument();
doc["EmptyString"] = "";
var obj = new BsonDocument();
obj["Qtd"] = 3;
obj["Description"] = "Big beer package";
obj["Unit"] = 1299.995;
doc["Items"].AsArray.Add(obj);
doc["Items"].AsArray.Add("string-one");
doc["Items"].AsArray.Add(null);
doc["Items"].AsArray.Add(true);
doc["Items"].AsArray.Add(DateTime.Now);
doc.Set("MyObj.IsFirstId", true);
return doc;
}
示例14: All
/// <summary>
/// Tests that the named array element contains all of the values (see $all).
/// </summary>
/// <param name="name">The name of the element to test.</param>
/// <param name="values">The values to compare to.</param>
/// <returns>The builder (so method calls can be chained).</returns>
public static QueryConditionList All(
string name,
BsonArray values
)
{
return new QueryConditionList(name).All(values);
}
示例15: UserRole
public UserRole(ObjectId Id, String UserRoleName, BsonArray UserRolePowers, ObjectId PUserRole)
{
this.Id = Id;
this.UserRoleName = UserRoleName;
this.UserRolePowers = UserRolePowers;
this.PUserRole = PUserRole;
}