当前位置: 首页>>代码示例>>C#>>正文


C# ObjectId.ToString方法代码示例

本文整理汇总了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());
        }
开发者ID:KindDragon,项目名称:libgit2sharp,代码行数:7,代码来源:ObjectIdFixture.cs

示例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
            };
        }
开发者ID:xoperator,项目名称:GoKapara,代码行数:30,代码来源:AddMessageProvider.cs

示例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")
            };
        }
开发者ID:xoperator,项目名称:GoKapara,代码行数:32,代码来源:GetContactsProvider.cs

示例4: ConvertObjectIdToBoRef

 public static BoRef ConvertObjectIdToBoRef(ObjectId id)
 {
     if (id == ObjectId.Empty)
     {
         return new BoRef();
     }
     return new BoRef(id.ToString());
 }
开发者ID:marcelopuppin,项目名称:MicropostMVC,代码行数:8,代码来源:ObjectIdConverter.cs

示例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);
        }
开发者ID:kcomkar,项目名称:libgit2sharp,代码行数:9,代码来源:ObjectIdFixture.cs

示例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");
        }
开发者ID:henon,项目名称:libgit2sharp,代码行数:9,代码来源:ObjectIdFixture.cs

示例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]));
         }
     }
 }
开发者ID:xoperator,项目名称:GoKapara,代码行数:12,代码来源:AddMessageProvider.cs

示例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()));
 }
开发者ID:abolibibelot,项目名称:mongo-csharp-driver,代码行数:13,代码来源:ObjectIdTests.cs

示例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));
     }
 }
开发者ID:wook815,项目名称:Hermes,代码行数:17,代码来源:IdentitySerializer.cs

示例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() });
        }
开发者ID:JasonSHD,项目名称:SaveASpot,代码行数:18,代码来源:CartController.cs

示例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
     };
 }
开发者ID:xoperator,项目名称:GoKapara,代码行数:22,代码来源:AddMessageProvider.cs

示例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;
        }
开发者ID:irobledo,项目名称:dwgDecoder,代码行数:48,代码来源:exportXml.cs

示例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();
            }
        }
开发者ID:globaltrack,项目名称:globaltrack,代码行数:25,代码来源:TrackableItemsController.cs

示例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
            };
        }
开发者ID:xoperator,项目名称:GoKapara,代码行数:37,代码来源:GetContactsProvider.cs

示例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));
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:14,代码来源:JsonReaderTests.cs


注:本文中的ObjectId.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。