本文整理汇总了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;
}
示例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));
}
示例3: User
public User(string partitionKey, Guid id)
{
this.PartitionKey = partitionKey;
this.RowKey = id.ToString();
this.Id = id.ToString();
}
示例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());
}
示例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);
}
示例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;
}
示例7: SaveData
public void SaveData(Guid networkId, string profileToSwitch, string profileFolder)
{
Settings[networkId.ToString() + "_ProfileToSwitch"] = profileToSwitch;
Settings[networkId.ToString() + "_ProfileFolder"] = profileFolder;
OnSettingsChanged();
}
示例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);
}
示例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");
}
}
}
示例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;
}
示例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);
}
示例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();
}
示例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());
}
示例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;
}
示例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;
}
}
}