本文整理汇总了C#中ObjectId类的典型用法代码示例。如果您正苦于以下问题:C# ObjectId类的具体用法?C# ObjectId怎么用?C# ObjectId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectId类属于命名空间,在下文中一共展示了ObjectId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecrementUnreadMessages
public void DecrementUnreadMessages(string appName, ObjectId userId, int decrementBy)
{
var dataBase = _serverWrapper.ServerConnection.GetDatabase(appName);
var collection = dataBase.GetCollection<DatingBookUserInfo>(DATING_BOOK_USERS_COLLECTION_NAME);
var selectQuery = Query.EQ("_id", userId);
collection.Update(selectQuery, Update.Inc("new_messages", -decrementBy));
}
示例2: UserInRole
/// <summary>
/// 查询角色下面所有用户
/// </summary>
/// <param name="UserRoleId"></param>
/// <returns>返回所有用户</returns>
public BsonArray UserInRole(ObjectId UserRoleId)
{
BsonDocument Query = new BsonDocument {
{ "UserRole", UserRoleId}
};
return GetUsersToArray(Query);
}
示例3: GetDatingBookUserInfo
public DatingBookUserInfo GetDatingBookUserInfo(string appName, ObjectId userId)
{
var datingBookUserInfo = _userDataProvider.GetDatingBookUserInfoByFacebookId(appName, userId);
if (datingBookUserInfo == null)
return null;
if (!CheckIfUserPictureExist(appName, datingBookUserInfo))
DownloadUserPicture(appName, datingBookUserInfo);
datingBookUserInfo.LastVisit = DateTime.Now;
ObjectId visitId = ObjectId.Empty;
var whiteList = _userDataProvider.GetUsersWhitelist(appName);
if (!whiteList.Exists((usr) => usr == datingBookUserInfo.FacebookId))
{
BsonDocument visit = new BsonDocument();
visit.Add("dating_book_id", datingBookUserInfo.ObjectId);
visit.Add("entered_at", datingBookUserInfo.LastVisit);
visitId = _userDataProvider.InsertVisit(appName, visit);
}
datingBookUserInfo = _userDataProvider.UpdateDatingBookLastVisit(appName, datingBookUserInfo, visitId);
var userEventInfo = new UserEventInfo
{
UserId = datingBookUserInfo.ObjectId,
EventType = 1,
DateCreated = DateTime.Now
};
_userDataProvider.InsertUserEvent(appName, userEventInfo);
return datingBookUserInfo;
}
示例4: ObjectIdWithDifferentValuesAreNotEqual
public void ObjectIdWithDifferentValuesAreNotEqual()
{
var a = new ObjectId("4b883faad657000000002665");
var b = new ObjectId("4b883faad657000000002666");
Assert.NotEqual(a, b);
Assert.True(a != b);
}
示例5: GetSessionDetails
public dynamic GetSessionDetails(string appName, ObjectId from, string to)
{
MessageSessionInfo session = _userMessagesDataProvider.GetSession(appName, CalculateSessionId(from.ToString(), to));
ObjectId fromWho = ObjectId.Empty;
if (from == session.User1)
{
fromWho = session.User1;
}
else if (from == session.User2)
{
fromWho = session.User2;
}
if (fromWho == ObjectId.Empty)
{
return new
{
error = "1"
};
}
var toUser = _userDataProvider.GetDatingBookUserInfo(appName, session.User1 == from ? session.User2 : session.User1, "facebook_user_id", "user_id", "picture", "location", "fname", "real_birthday");
return new
{
from = from.ToString(),
to = toUser.Id.ToString(),
to_picture = GenerateUserProfilePictureUrl(appName, toUser, 45, 55),
to_location = toUser.Location,
to_name = toUser.FirstName,
to_age = (int)(Math.Round((DateTime.Now.Subtract(toUser.RealBirthday).TotalDays) / 365)),
session_updated = session.LastUpdated.ToString("dd/MM/yyyy dddd hh:mm")
};
}
示例6: TestFromRqlIds
public void TestFromRqlIds()
{
var rqlIds = new RqlId[]
{
new RqlId("$0"),
new RqlId("$0"),
new RqlId("$1F2mgA9gNyZtkTIf6"),
new RqlId("$1Ad4Xro7A6yeAl77J") // This one caused problems
};
var objIds = new ObjectId[]
{
ObjectId.Empty,
new ObjectId(0, 0, 0, 0),
new ObjectId("8000000000006400c800ffff"),
new ObjectId("53d5244dec98e866c0d800f4")
};
for (int i = 0; i < rqlIds.Length; i++)
{
var objId = rqlIds[i].ToObjectId();
var rqlId = objId.ToRqlId();
var objId2 = rqlId.ToObjectId();
Assert.AreEqual(rqlIds[i], rqlId, "ObjectId value {0}", i);
Assert.AreEqual(objIds[i], objId2, "RqlId value {0}", i);
}
}
示例7: Delete
public ActionResult Delete(ObjectId id)
{
var collection = Database.GetCollection<ProfileProperty>("ProfileProperty");
collection.Remove(Query.EQ("_id", id));
return RedirectToAction("Index");
}
示例8: GivenAMongoMessageDataRepository_WhenPuttingMessageDataWithExpiration
public void GivenAMongoMessageDataRepository_WhenPuttingMessageDataWithExpiration()
{
var db = new MongoClient().GetDatabase("messagedatastoretests");
_bucket = new GridFSBucket(db);
_now = DateTime.UtcNow;
SystemDateTime.Set(_now);
var fixture = new Fixture();
var resolver = new Mock<IMongoMessageUriResolver>();
resolver.Setup(x => x.Resolve(It.IsAny<ObjectId>()))
.Callback((ObjectId id) => _id = id);
var nameCreator = new Mock<IFileNameCreator>();
nameCreator.Setup(x => x.CreateFileName())
.Returns(fixture.Create<string>());
var sut = new MongoMessageDataRepository(resolver.Object, _bucket, nameCreator.Object);
_expectedTtl = TimeSpan.FromHours(1);
using (var stream = new MemoryStream(fixture.Create<byte[]>()))
{
sut.Put(stream, _expectedTtl).GetAwaiter().GetResult();
}
}
开发者ID:LiberisLabs,项目名称:MassTransit.MessageData.MongoDb,代码行数:26,代码来源:MongoMessageDataRepositoryTestsForPuttingMessageDataWithExpiration.cs
示例9: UpsertDatingBookUserInfo
public DatingBookUserInfo UpsertDatingBookUserInfo(string appName, ObjectId userId, DatingBookUserInfo datingBookUserInfo)
{
datingBookUserInfo = _userDataProvider.UpsertDatingbookUserInfo(appName, userId, datingBookUserInfo);
if (datingBookUserInfo.IsNew)
{
if (!CheckIfUserPictureExist(appName, datingBookUserInfo))
DownloadUserPicture(appName, datingBookUserInfo);
var userEventInfo = new UserEventInfo
{
UserId = datingBookUserInfo.ObjectId,
EventType = 0,
DateCreated = DateTime.Now
};
_userDataProvider.InsertUserEvent(appName, userEventInfo);
datingBookUserInfo.IsNew = false;
}
datingBookUserInfo.LastVisit = DateTime.Now;
datingBookUserInfo = _userDataProvider.UpdateDatingBookLastVisit(appName, datingBookUserInfo);
return datingBookUserInfo;
}
示例10: FetchHeadRecord
public FetchHeadRecord(ObjectId newValue, bool notForMerge, string sourceName, URIish sourceUri)
{
NewValue = newValue;
NotForMerge = notForMerge;
SourceName = sourceName;
SourceURI = sourceUri;
}
示例11: ReadRangeRequest
public ReadRangeRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, Option<RangeType> range)
{
this.ObjectIdentifier = objectIdentifier;
this.PropertyIdentifier = propertyIdentifier;
this.PropertyArrayIndex = propertyArrayIndex;
this.Range = range;
}
示例12: Main
static void Main(string[] args)
{
var client = new MongoClient();
var db = client.GetDatabase("CustomerDb");
var CustColl = db.GetCollection<Customer>("Customer");
// query customer
var customerID = new ObjectId("xxx");
var customers = CustColl
.Find(c => c.Id == customerID)
.SortBy(c => c.fullName)
.Limit(3)
.ToListAsync()
.Result;
foreach (var customer in customers)
{
Console.WriteLine(customer.fullName);
}
//Update Customer
var cust = customers.First();
cust.fullName = cust.fullName.ToUpper();
}
示例13: MockCommit
public MockCommit(ObjectId id = null)
{
idEx = id ?? new ObjectId(Guid.NewGuid().ToString().Replace("-", "")+ "00000000");
MessageEx = "";
ParentsEx = new List<Commit> { null };
CommitterEx = new Signature("Joe", "[email protected]", DateTimeOffset.Now);
}
示例14: IAmRequest
public IAmRequest(ObjectId iAmDeviceIdentifier, uint maxAPDULengthAccepted, Segmentation segmentationSupported, uint vendorID)
{
this.IAmDeviceIdentifier = iAmDeviceIdentifier;
this.MaxAPDULengthAccepted = maxAPDULengthAccepted;
this.SegmentationSupported = segmentationSupported;
this.VendorID = vendorID;
}
示例15: Details
//
// GET: /Project/Details/5
public ActionResult Details(ObjectId id)
{
var project = session.GetById<Project>(id);
ViewBag.ProjectConfigurations =
session.GetAll<Configuration>().Where(c => c.ProjectId == project.Id).ToArray();
return View(project);
}