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


C# Guid.ToString方法代码示例

本文整理汇总了C#中System.Guid.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Guid.ToString方法的具体用法?C# Guid.ToString怎么用?C# Guid.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Guid的用法示例。


在下文中一共展示了Guid.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateBuffer

        public static SharedBuffer CreateBuffer(Guid id, Type elementType, long bufferSize)
        {
            var sb = new SharedBuffer();
            sb.Id = id;
            sb.ElementTypeString = elementType.FullName;
            sb.ElementSize = Marshal.SizeOf(elementType);
            sb.ElementCount = bufferSize;

            if (_blockPath != string.Empty)
            {
                var fileStream = System.IO.File.Create(string.Format(@"{0}\{1}", _blockPath, id.ToString()), 
                    (int)(bufferSize * sb.ElementSize), System.IO.FileOptions.DeleteOnClose);

                var mmf = MemoryMappedFile.CreateFromFile(fileStream, id.ToString(), 
                    (int)(bufferSize * sb.ElementSize),
                    MemoryMappedFileAccess.ReadWrite, null, System.IO.HandleInheritability.None, false);

                _cacheBuffers.TryAdd(id, sb);
                _cacheMmfs.TryAdd(id, mmf);
                _cacheFileStreams.TryAdd(id, fileStream);
            }
            else
            { 
                var mmf = MemoryMappedFile.CreateNew(id.ToString(), 
                    bufferSize * sb.ElementSize);
                _cacheBuffers.TryAdd(id, sb);
                _cacheMmfs.TryAdd(id, mmf);
            }

            return sb;
        }
开发者ID:dg1an3,项目名称:PheonixRt.Mvvm,代码行数:31,代码来源:BufferRepository.cs

示例2: GetLinkByGuid

        private string GetLinkByGuid(Guid id)
        {
            string pageRelUrl = CommonLinkUtility.GetEmployees(_productID) + "&";

            string pageUrl = string.Empty;
            if (Request["deplist"] == null)
            {
                pageUrl = string.Format("{0}depID={1}&search=&page=1&sort={2}{3}", pageRelUrl,
                    id == Guid.Empty ? string.Empty : id.ToString(),
                    Request["sort"], Request["list"] == null ? string.Empty : "&list=" + Request["list"]);
            }
            else
            {
                if (id == Guid.Empty)
                {
                    pageUrl = string.Format("{0}deplist={1}", pageRelUrl, Request["list"] == null ? string.Empty : "&list=" + Request["list"]);
                }
                else
                {
                    pageUrl = string.Format("{0}deplist={1}&search=&page=1&sort={2}{3}", pageRelUrl, id.ToString(),
                        Request["sort"], Request["list"] == null ? string.Empty : "&list=" + Request["list"]);
                }

            }

            return ResolveUrl(UrlQueryManager.AddDefaultParameters(Request, pageUrl));
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:27,代码来源:CompanyNavigation.ascx.cs

示例3: User

        public User(string partitionKey, Guid id)
        {
            this.PartitionKey = partitionKey;
            this.RowKey = id.ToString();

            this.Id = id.ToString();
        }
开发者ID:mtusk,项目名称:lunch-bus,代码行数:7,代码来源:User.cs

示例4: Guid_to_Etag_conversion

		public void Guid_to_Etag_conversion()
		{
			var guid = new Guid("01234567-8901-2345-6789-012345678901");
			var nullableGuid = (Guid?)guid;
			Assert.Equal(guid.ToString(), ((Raven.Abstractions.Data.Etag)guid).ToString());
			Assert.Equal(guid.ToString(), ((Raven.Abstractions.Data.Etag)nullableGuid).ToString());
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:7,代码来源:RavenDB_1470.cs

示例5: GetByIdShouldReturnTheSameUser

        public void GetByIdShouldReturnTheSameUser()
        {
            Guid guid = new Guid("50d3ebaa-eea3-453f-8e8b-b835605b3e85");
            ApplicationUser user = new ApplicationUser()
            {
                UserName = "Pesho",
                Id = guid.ToString(),
                FirstName = "Ivan",
                LastName = "jorkov"
            };

           // 
            var usersRepoMock = new Mock<IRepository<ApplicationUser>>();

            usersRepoMock.Setup(x => x.GetById(guid.ToString())).Returns(user);


            var uofMock = new Mock<IUnitOfWorkData>();
            uofMock.Setup(x => x.Users).Returns(usersRepoMock.Object);
           
            var controller = new UserController(uofMock.Object);

            var viewResult = controller.Details(guid.ToString()) as ViewResult;
            Assert.IsNotNull(viewResult, "Index action returns null.");

            var model = viewResult.Model as UserViewModel;
            Assert.IsNotNull(model, "The model is null.");
            Assert.AreEqual(user.LastName, model.LastName);
            Assert.AreEqual(user.FirstName, model.FirstName);
            Assert.AreEqual(user.Id, model.Id);            
        }
开发者ID:nnaidenov,项目名称:TelerikAcademy,代码行数:31,代码来源:UsersControllerTests.cs

示例6: MakeListId

        public static WorkflowSubscription MakeListId(this WorkflowSubscription workflowSubscription, Guid listId)
        {
            workflowSubscription.SetProperty("ListId", listId.ToString());
            workflowSubscription.SetProperty("Microsoft.SharePoint.ActivationProperties.ListId", listId.ToString());

            return workflowSubscription;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:7,代码来源:WorkflowSubscriptionBehaviours.cs

示例7: SaveData

        public void SaveData(Guid networkId, string profileToSwitch, string profileFolder)
        {
            Settings[networkId.ToString() + "_ProfileToSwitch"] = profileToSwitch;
            Settings[networkId.ToString() + "_ProfileFolder"] = profileFolder;

            OnSettingsChanged();
        }
开发者ID:Saldash,项目名称:ProxySwitcher,代码行数:7,代码来源:DisableFirefoxProxyAction.cs

示例8: CRITERIA02_CompoundExpressionSerializeTest

        public void CRITERIA02_CompoundExpressionSerializeTest()
        {
            // Arrange
            Guid typeGuid = new Guid("{2bc63f3a-a7a1-4ded-a727-b14f7b2cef69}");
            string poNumber = "Testing123";
            string knownGood = "{\"Id\":\"f27daae2-280c-dd8b-24e7-9bdb5120d6d2\",\"Criteria\":{\"Base\":{\"Expression\":{\"And\":{\"Expression\":[{\"SimpleExpression\":{\"ValueExpressionLeft\":{\"Property\":\"$Context/Property[Type='2afe355c-24a7-b20f-36e3-253b7249818d']/PurchaseOrderType$\"},\"Operator\":\"Equal\",\"ValueExpressionRight\":{\"Value\":\"" + typeGuid.ToString("B") + "\"}}},{\"SimpleExpression\":{\"ValueExpressionLeft\":{\"Property\":\"$Context/Property[Type='2afe355c-24a7-b20f-36e3-253b7249818d']/PurchaseOrderNumber$\"},\"Operator\":\"Equal\",\"ValueExpressionRight\":{\"Value\":\"" + poNumber + "\"}}}]}}}}}";

            QueryCriteriaExpression expr1 = new QueryCriteriaExpression
            {
                PropertyName = (new PropertyPathHelper(ClassConstants.PurchaseOrder.Id, "PurchaseOrderType")).ToString(),
                PropertyType = QueryCriteriaPropertyType.Property,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = typeGuid.ToString("B")
            };

            QueryCriteriaExpression expr2 = new QueryCriteriaExpression
            {
                PropertyName = (new PropertyPathHelper(ClassConstants.PurchaseOrder.Id, "PurchaseOrderNumber")).ToString(),
                PropertyType = QueryCriteriaPropertyType.Property,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = poNumber
            };

            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.PurchaseOrder.Id);
            criteria.GroupingOperator = QueryCriteriaGroupingOperator.And;
            criteria.Expressions.Add(expr1);
            criteria.Expressions.Add(expr2);

            // Act
            string testSerialize = criteria.ToString();

            // Assert
            Assert.AreEqual(knownGood, testSerialize);
        }
开发者ID:JohnCardenas,项目名称:CiresonPortalAPI,代码行数:34,代码来源:QueryCriteriaTests.cs

示例9: ConfirmUser

        public ActionResult ConfirmUser(Guid confirmationId)
        {
            if (string.IsNullOrEmpty(confirmationId.ToString()) || (!Regex.IsMatch(confirmationId.ToString(),
                   @"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}")))
            {
                TempData["EpostaOnayMesaj"] = "Hesap geçerli değil. Lütfen e-posta adresinizdeki linke tekrar tıklayınız.";

                return View();
            }
            else
            {
                var user = _userService.FindByConfirmationId(confirmationId);

                if (!user.IsConfirmed)
                {
                    user.IsConfirmed = true;
                    _userService.Update(user);
                    _uow.SaveChanges();

                    FormsAuthentication.SetAuthCookie(user.UserName, true);
                    TempData["EpostaOnayMesaj"] = "E-posta adresinizi onayladığınız için teşekkürler. Artık sitemize üyesiniz.";

                    return RedirectToAction("Wellcome");
                }
                else
                {
                    TempData["EpostaOnayMesaj"] = "E-posta adresiniz zaten onaylı. Giriş yapabilirsiniz.";

                    return RedirectToAction("GirisYap");
                }
            }
        }
开发者ID:hakanmanavoglu,项目名称:eCommerce,代码行数:32,代码来源:AccountController.cs

示例10: SignIn

        public virtual void SignIn(Guid userId, bool createPersistentCookie)
        {
            var now = DateTime.Now;

            var ticket = new FormsAuthenticationTicket(
                1,
                userId.ToString("N"),
                now,
                now.Add(this.expirationTimeSpan),
                createPersistentCookie,
                userId.ToString("N"),
                FormsAuthentication.FormsCookiePath);

            var encryptedTicket = FormsAuthentication.Encrypt(ticket);

            var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
            cookie.HttpOnly = true;
            if (ticket.IsPersistent)
            {
                cookie.Expires = ticket.Expiration;
            }
            cookie.Secure = FormsAuthentication.RequireSSL;
            cookie.Path = FormsAuthentication.FormsCookiePath;
            if (FormsAuthentication.CookieDomain != null)
            {
                cookie.Domain = FormsAuthentication.CookieDomain;
            }

            this.httpContext.Response.Cookies.Add(cookie);
            this.cachedAccountId = userId;
        }
开发者ID:J-W-Chan,项目名称:Zrd_0001_AuthorityManagement,代码行数:31,代码来源:FormsAuthenticationService.cs

示例11: CRITERIA01_SimpleExpressionSerializeTest

        public void CRITERIA01_SimpleExpressionSerializeTest()
        {
            // Arrange
            Guid baseId = new Guid("{b3e98851-27ab-4d70-bb10-3cf71c80d838}");
            string knownGood = "{\"Id\":\"" + TypeProjectionConstants.User.Id.ToString("D") + "\",\"Criteria\":{\"Base\":{\"Expression\":{\"SimpleExpression\":{\"ValueExpressionLeft\":{\"GenericProperty\":\"Id\"},\"Operator\":\"Equal\",\"ValueExpressionRight\":{\"Value\":\"" + baseId.ToString("D") + "\"}}}}}}";

            QueryCriteriaExpression expr = new QueryCriteriaExpression
            {
                PropertyName = "Id",
                PropertyType = QueryCriteriaPropertyType.GenericProperty,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = baseId.ToString("D")
            };

            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.User.Id)
            {
                GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression
            };

            criteria.Expressions.Add(expr);

            // Act
            string testSerialize = criteria.ToString();

            // Assert
            Assert.AreEqual(knownGood, testSerialize);
        }
开发者ID:JohnCardenas,项目名称:CiresonPortalAPI,代码行数:27,代码来源:QueryCriteriaTests.cs

示例12: AddPremiumPlayerAsync

        public async void AddPremiumPlayerAsync(string ip, Guid guid)
        {
            await Connection.OpenAsync();

            // Check if the player already has an entry
            SQLiteCommand command = new SQLiteCommand("SELECT COUNT(*) FROM premium WHERE GUID = $guid");
            command.Parameters.AddWithValue("$guid", guid.ToString("N"));

            long count = (long)await ExecuteScalarAsync(command);

            if (count == 1)
            {
                command = new SQLiteCommand("UPDATE premium SET ip = $ip, timestamp = datetime('now') WHERE GUID = $guid");
                command.Parameters.AddWithValue("$guid", guid.ToString("N"));
                command.Parameters.AddWithValue("$ip", ip);
                command.Connection = Connection;
                await command.ExecuteNonQueryAsync();
            }
            else
            {
                command = new SQLiteCommand("INSERT INTO premium(IP, GUID) VALUES ($ip, $guid)");
                command.Parameters.AddWithValue("$guid", guid.ToString("N"));
                command.Parameters.AddWithValue("$ip", ip);
                command.Connection = Connection;
                await command.ExecuteNonQueryAsync();
            }

            Connection.Close();
        }
开发者ID:ChrisK91,项目名称:CWSRestart,代码行数:29,代码来源:PremiumPlayers.cs

示例13: AddComment

        public ActionResult AddComment(string text, string userId, Guid photoId)
        {
            var user = Session.Query<User>().Where(x => x.Id == SecurityManager.AuthenticatedUser.Id).FirstOrDefault();
            if (user == null)
            {
                throw new InvalidOperationException();
            }

            var photo = Session.Query<Photo>().Where(x => x.Id == photoId).FirstOrDefault();
            if (photo == null)
            {
                throw new InvalidOperationException();
            }
            var model = new PreviewViewModel();
            model.Photo = photo;
            model.CanLike = !model.Photo.Likes.Any(x => x.Liker.Id == SecurityManager.AuthenticatedUser.Id);
            if (string.IsNullOrEmpty(text.Trim()))
            {
                return Redirect("/Preview/?id=" + photoId.ToString());
            }

            var comment = new Comment(Guid.NewGuid(), text.Trim(), DateTime.Now, user, photo);
            Session.Save(comment);
            photo.Comments.Add(comment);
            return Redirect("/Preview/?id=" + photoId.ToString());
        }
开发者ID:sdluxeon,项目名称:MyPhoto,代码行数:26,代码来源:PreviewController.cs

示例14: SyncOpenId

        public static string SyncOpenId(Guid sid)
        {
            WxOpenIds openIds = ElegantWM.WeiXin.Common.GetFanList(sid.ToString(), "");
            string fails = "ErrorList:";
            foreach (string oid in openIds.data.openid)
            {
                if (WMFactory.WXFans.GetCount(f => f.AccountId == sid && f.OpenId == oid) <= 0)
                {
                    WxFans wf = ElegantWM.WeiXin.Common.GetFanInfo(sid.ToString(), oid);
                    WX_Fans fan = new WX_Fans();
                    fan.OpenId = oid;
                    fan.AccountId = sid;
                    fan.NickName = wf.nickname;
                    fan.Sex = wf.sex;
                    fan.City = wf.city;
                    fan.Province = wf.province;
                    fan.Avatar = wf.headimgurl;
                    fan.CreateUser = "SYNC";
                    if (!WMFactory.WXFans.Insert(fan))
                    {
                        fails += oid + ",";
                    }
                }
            }

            if (openIds.total <= openIds.count)
            {
                //说明没有更多了
            }

            return fails;
        }
开发者ID:huaminglee,项目名称:Code,代码行数:32,代码来源:WXFansController.cs

示例15: SearchVipScore

        public string SearchVipScore(Guid sid, string oid)
        {
            string vipname = "";
            string centum = "";
            string viptel = "";

            //查找这个微信号是否绑定会员
            //var list = WMFactory.WXLKRegMemberFans.FindByConditions(o => o.OrderByDescending(x => x.Id), f => f.AccountId == sid);

            IEnumerable<WX_LK_RegMemberFans> fans = WMFactory.WXLKRegMemberFans.FindByConditions(null, f => f.AccountId == sid && f.OpenId == oid && f.IsUsing == 0);
            if (fans == null || fans.Count() <= 0)
            {
                return "请您先绑定,<a href='http://it.hwafashion.com/NPaia/VIP/CreateVip?sid=" + sid.ToString() + "&oid=" + oid + "'>点击绑定</a>";
            }
            else
            {
                viptel = fans.First().Telphone;
                DataTable dtpCentum = WMFactory.Wsrr.GetUserCentumInfo(viptel);

                if (dtpCentum.Rows[0]["mobtel"].ToString() == "")
                {
                    return "异常,请重新绑定,<a href='http://it.hwafashion.com/NPaia/VIP/CreateVip?sid=" + sid.ToString() + "&oid=" + oid + "'>点击绑定</a>";
                }
                else
                {
                    vipname = dtpCentum.Rows[0]["vipname"].ToString();
                    viptel = dtpCentum.Rows[0]["mobtel"].ToString();
                    centum = dtpCentum.Rows[0]["centum"].ToString();
                    return "会员姓名:" + vipname + "\r\n" + "注册手机:" + viptel + "\r\n" + "当前积分:" + centum;
                }
            }
        }
开发者ID:huaminglee,项目名称:Code,代码行数:32,代码来源:VIPController.cs


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