本文整理汇总了C#中ObjectId.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectId.ToString方法的具体用法?C# ObjectId.ToString怎么用?C# ObjectId.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectId
的用法示例。
在下文中一共展示了ObjectId.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanConvertOidToSha
public void CanConvertOidToSha()
{
var id = new ObjectId(bytes);
Assert.Equal(validSha1, id.Sha);
Assert.Equal(validSha1, id.ToString());
}
示例2: AddMessage
public dynamic AddMessage(string appName, ObjectId from, string to, string header, string message, long appId)
{
string fromStr = from.ToString();
var toObjId = new ObjectId(to);
MessageInfo msgInfo = _userMessagesDataProvider.InsertMessage(appName, CalculateSessionId(fromStr, to),
from, toObjId, HttpUtility.HtmlEncode(header), HttpUtility.HtmlEncode(message));
var toUserInfo = _userDataProvider.GetDatingBookUserInfo(appName, toObjId);
var fromUserInfo = _userDataProvider.GetDatingBookUserInfo(appName, from);
var appInfo = _appsDataProvider.GetAppInfo(appId);
//inc the to user unread
_userMessagesDataProvider.IncrementUnreadMessages(appName, toObjId);
string msg = string.Format("You received a new message from {0} !", fromUserInfo.FirstName);
_facebookDataProvider.SendFacebookAppNotification(toUserInfo.FacebookId, msg, msg, appInfo.AppAccessToken);
return new
{
mid = msgInfo.Id.ToString(),
text = msgInfo.Body,
date = msgInfo.DateCreated,
from_id = msgInfo.From.ToString(),
picture = GenerateUserProfilePictureUrl(appName, fromUserInfo, 50, 50),
from_name = fromUserInfo.FirstName
};
}
示例3: 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")
};
}
示例4: ConvertObjectIdToBoRef
public static BoRef ConvertObjectIdToBoRef(ObjectId id)
{
if (id == ObjectId.Empty)
{
return new BoRef();
}
return new BoRef(id.ToString());
}
示例5: CanConvertOidToSha
public void CanConvertOidToSha()
{
var bytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9 };
var id = new ObjectId(bytes);
id.Sha.ShouldEqual(validSha1);
id.ToString().ShouldEqual(validSha1);
}
示例6: CanConvertOidToSha
public void CanConvertOidToSha()
{
var bytes = new byte[] {206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9};
var id = new ObjectId(bytes);
id.Sha.ShouldEqual("ce08fe4884650f067bd5703b6a59a8b3b3c99a09");
id.ToString().ShouldEqual("ce08fe4884650f067bd5703b6a59a8b3b3c99a09");
}
示例7: SetSpammers
public void SetSpammers(string appName, ObjectId userId, string[] ids)
{
ObjectId[] objIds = new ObjectId[ids.Length];
string myUserId = userId.ToString();
for (int i = 0; i < ids.Length; i++)
{
if (!string.IsNullOrEmpty(ids[i]))
{
_userMessagesDataProvider.UpdateSpammer(appName, userId, new ObjectId(ids[i]));
}
}
}
示例8: TestByteArrayConstructor
public void TestByteArrayConstructor()
{
byte[] bytes = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
var objectId = new ObjectId(bytes);
Assert.AreEqual(0x01020304, objectId.Timestamp);
Assert.AreEqual(0x050607, objectId.Machine);
Assert.AreEqual(0x0809, objectId.Pid);
Assert.AreEqual(0x0a0b0c, objectId.Increment);
Assert.AreEqual(0x05060708090a0b0c, objectId.MachinePidIncrement);
Assert.AreEqual(Bson.UnixEpoch.AddSeconds(0x01020304), objectId.CreationTime);
Assert.AreEqual("0102030405060708090a0b0c", objectId.ToString());
Assert.IsTrue(bytes.SequenceEqual(objectId.ToByteArray()));
}
示例9: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
var identity = (Identity)value;
var objectId = new ObjectId(identity.ToArray());
BsonType bsonType = options == null ? BsonType.ObjectId : ((RepresentationSerializationOptions)options).Representation;
switch (bsonType)
{
case BsonType.String:
bsonWriter.WriteString(objectId.ToString());
break;
case BsonType.ObjectId:
bsonWriter.WriteObjectId(objectId.Timestamp, objectId.Machine, objectId.Pid, objectId.Increment);
break;
default:
throw new BsonSerializationException(string.Format("'{0}' is not a valid representation for type 'Identity'", bsonType));
}
}
示例10: Remove
public JsonResult Remove(ObjectId id)
{
bool success = false;
var cart = CurrentCart;
var items = cart.Items;
foreach (var item in items)
{
if (item.SpotID == id)
{
item.Qty = 0;
Context.Carts.AddItem(ClientIP, item, ref cart);
success = true;
break;
}
}
return Json(new { success = success, id = id.ToString() });
}
示例11: DeleteSessions
public dynamic DeleteSessions(string appName, ObjectId userId, string[] ids)
{
string myUserId = userId.ToString();
int globalUnread = 0;
for (int i = 0; i < ids.Length; i++)
{
if (!string.IsNullOrEmpty(ids[i]))
{
int unread;
_userMessagesDataProvider.UpdateSessionDeleted(appName, CalculateSessionId(myUserId, ids[i]), userId, true, out unread);
globalUnread += unread;
}
}
if (globalUnread > 0)
{
_userMessagesDataProvider.DecrementUnreadMessages(appName, userId, globalUnread);
}
return new
{
unreadCount = _userDataProvider.GetDatingBookUserInfo(appName, userId, "new_messages").NewMessages
};
}
示例12: arco2xml
/**
* @brief Metodo que encapsula como debe formatearse en la salida XML un objeto del tipo dwgArco.
*
* @param a Objeto del tipo dwgArco.
* @param xmldoc Objeto de tipo XmlDocument al que se anexará la información del arco.
* @param capaId Objeto del tipo ObjectId con el identificador de la capa a la que pertenece el arco. Esta capa será usada para asociarla a todas las lineas
* que haya al descomponer el arco.
* @param dwgf Objeto del tipo dwgFile para buscar información adicional sobre lineas vinculadas al arco.
*
* @return Devuelve un tipo XmlElement con la información del arco formateada para ser añadido en el documento xmldoc.
*
**/
public static XmlElement arco2xml(dwgArco a, XmlDocument xmldoc, ObjectId capaId, dwgFile dwgf)
{
XmlElement arco = xmldoc.CreateElement("arco");
XmlAttribute xmlattribute = xmldoc.CreateAttribute("id");
xmlattribute.Value = a.objId.ToString();
arco.Attributes.Append(xmlattribute);
xmlattribute = xmldoc.CreateAttribute("radio");
xmlattribute.Value = a.radio.ToString();
arco.Attributes.Append(xmlattribute);
xmlattribute = xmldoc.CreateAttribute("angulo_inicio");
xmlattribute.Value = a.angulo_inicio.ToString();
arco.Attributes.Append(xmlattribute);
xmlattribute = xmldoc.CreateAttribute("angulo_final");
xmlattribute.Value = a.angulo_final.ToString();
arco.Attributes.Append(xmlattribute);
xmlattribute = xmldoc.CreateAttribute("center_point_id");
xmlattribute.Value = a.punto_centro.ToString();
arco.Attributes.Append(xmlattribute);
var puntolinea2 = dwgf.dwgLineas.Values.Where(x => x.capaId.ToString() == capaId.ToString() && x.parentId.ToString() == a.objId.ToString());
foreach (dwgLinea obj2 in puntolinea2)
{
XmlElement linea = exportXml.linea2xml(obj2, xmldoc);
arco.AppendChild(linea);
}
XmlElement mapa = xmldoc.CreateElement("mapa_atributos");
arco.AppendChild(mapa);
return arco;
}
示例13: EditState
public ActionResult EditState(ObjectId trackableItemId, ObjectId stateId, TrackableItemState state)
{
try
{
if (ModelState.IsValid)
{
//updating stateid - we lost it
state.Id = stateId;
var item = _trackableItemsCollection.AsQueryable().First(x => x.Id == trackableItemId);
int indexOfState = item.States.Where(s=> s.Id == stateId).Select(item.States.IndexOf).FirstOrDefault();
item.States[indexOfState] = state;
_trackableItemsCollection.Save(item);
return RedirectToAction("Details", new {id = trackableItemId.ToString()});
}
return View();
}
catch
{
return View();
}
}
示例14: GetUserMessages
public dynamic GetUserMessages(string appName, ObjectId user, ObjectId other, string last, int page)
{
string sessionId = CalculateSessionId(user.ToString(), other.ToString());
MessageSessionInfo session = _userMessagesDataProvider.GetMessages(appName, sessionId, last, page);
MessageInfo[] infos = session.Messages;
var userInfo = _userDataProvider.GetDatingBookUserInfo(appName, user);
var otherInfo = _userDataProvider.GetDatingBookUserInfo(appName, other);
List<dynamic> messages = new List<dynamic>();
bool isUser1 = session.User1 == user;
int countUnread = isUser1 ? session.UnreadMessagesUser1 : session.UnreadMessagesUser2;
if (countUnread > 0)
{
//decrement from the global unread counter
_userMessagesDataProvider.DecrementUnreadMessages(appName, user, countUnread);
//decrement from the session unread counter
_userMessagesDataProvider.ResetUnreadMessages(appName, session.Id, isUser1);
}
for (int i = (infos.Length - 1); i >= 0; i--)
{
var msg = infos[i];
DatingBookUserInfo msgSender = msg.From == user ? userInfo : otherInfo;
messages.Add(new
{
mid = msg.Id.ToString(),
text = msg.Body,
date = msg.DateCreated,
from_id = msg.From.ToString(),
picture = GenerateUserProfilePictureUrl(appName, msgSender, 50, 50),
from_name = msgSender.FirstName
});
}
return new
{
data = messages
};
}
示例15: TestObjectIdTenGen
public void TestObjectIdTenGen() {
var json = "ObjectId(\"4d0ce088e447ad08b4721a37\")";
using (bsonReader = BsonReader.Create(json)) {
Assert.AreEqual(BsonType.ObjectId, bsonReader.ReadBsonType());
int timestamp, machine, increment;
short pid;
bsonReader.ReadObjectId(out timestamp, out machine, out pid, out increment);
var objectId = new ObjectId(timestamp, machine, pid, increment);
Assert.AreEqual("4d0ce088e447ad08b4721a37", objectId.ToString());
Assert.AreEqual(BsonReaderState.Done, bsonReader.State);
}
var settings = new JsonWriterSettings { OutputMode = JsonOutputMode.TenGen };
Assert.AreEqual(json, BsonSerializer.Deserialize<ObjectId>(new StringReader(json)).ToJson(settings));
}