本文整理汇总了C#中System.Guid.Substring方法的典型用法代码示例。如果您正苦于以下问题:C# Guid.Substring方法的具体用法?C# Guid.Substring怎么用?C# Guid.Substring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Guid
的用法示例。
在下文中一共展示了Guid.Substring方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveToDisk
public static void SaveToDisk(this XpsFont font, string path)
{
using (Stream stm = font.GetStream())
{
using (FileStream fs = new FileStream(path, FileMode.Create))
{
byte[] dta = new byte[stm.Length];
stm.Read(dta, 0, dta.Length);
if (font.IsObfuscated)
{
string guid = new Guid(font.Uri.GetFileName().Split('.')[0]).ToString("N");
byte[] guidBytes = new byte[16];
for (int i = 0; i < guidBytes.Length; i++)
{
guidBytes[i] = Convert.ToByte(guid.Substring(i * 2, 2), 16);
}
for (int i = 0; i < 32; i++)
{
int gi = guidBytes.Length - (i % guidBytes.Length) - 1;
dta[i] ^= guidBytes[gi];
}
}
fs.Write(dta, 0, dta.Length);
}
}
}
示例2: GenerateKey
public static string GenerateKey()
{
string timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");
string key = null;
using (MD5 md5 = MD5.Create())
{
byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(timestamp));
key = new Guid(hash).ToString();
}
return key.Substring(0,18);
}
示例3: CreateWorkspaceItemToRegister
private void CreateWorkspaceItemToRegister(string id, string parentId, bool folder, string text)
{
string title = FormatTitle(text);
var props = new WorkspaceItemProperty[CAmountProps];
var descs = new WorkspaceItemDescription[CAmountDesc];
int subIndex;
string idHex;
string idGuid;
subIndex = (_index * 10) + 1;
for (int i = 0; i < CAmountProps; i++)
{
idGuid = new Guid(subIndex, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString();
idHex = idGuid.Substring(6, 2);
props[i] = new WorkspaceItemProperty
{
Id = idGuid,
ItemId = id,
PropertyName = String.Format("Property({0}) - {1} of {2}", idHex, i + 1, CAmountProps),
PropertyValue = String.Format("Property value({0}) - {1} of {2}", idHex, i + 1, CAmountProps),
PropertyTypeId = _itemPropertyTypeId,
PropertyTypeDescription = String.Format("Property description({0}) - {1} of {2}", subIndex, i + 1, CAmountProps)
};
subIndex++;
}
subIndex = (_index * 10) + 1;
for (int i = 0; i < CAmountDesc; i++)
{
idGuid = new Guid(subIndex, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString();
idHex = idGuid.Substring(6, 2);
descs[i] = new WorkspaceItemDescription
{
CultureId = CultureInfo.CurrentCulture.Name,
Id = idGuid,
ItemId = id,
Title = String.Format("Description({0}) - {1} of {2}", idHex, i + 1, CAmountDesc),
TypeId = _itemDescriptionTypeId
};
subIndex++;
}
_items[_index++] = new WorkspaceItem { Id = id, ParentId = parentId, ItemId = id, TypeId = (folder ? _treeViewFolderTypeId : _treeViewLeafTypeId), ItemTitle = title, Descriptions = descs, Properties = props, DateModified = DateTime.Now };
}
示例4: DeobfuscateFont
static byte[] DeobfuscateFont(XpsFont font)
{
using (var stm = font.GetStream())
{
byte[] dta = new byte[stm.Length];
stm.Read(dta, 0, dta.Length);
if (font.IsObfuscated)
{
string guid = new Guid(System.IO.Path.GetFileNameWithoutExtension(font.Uri.ToString())).ToString("N");
byte[] guidBytes = new byte[16];
for (int i = 0; i < guidBytes.Length; i++)
guidBytes[i] = Convert.ToByte(guid.Substring(i * 2, 2), 16);
for (int i = 0; i < 32; i++)
{
int gi = guidBytes.Length - (i % guidBytes.Length) - 1;
dta[i] ^= guidBytes[gi];
}
}
return dta;
}
}