當前位置: 首頁>>代碼示例>>C#>>正文


C# Guid.Substring方法代碼示例

本文整理匯總了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);
                }
            }
        }
開發者ID:goutkannan,項目名稱:ironlab,代碼行數:27,代碼來源:Helper.cs

示例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);
    }
開發者ID:cocoon,項目名稱:crucibleWDS,代碼行數:12,代碼來源:Utility.cs

示例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 };
        }
開發者ID:rlefever68,項目名稱:Broobu.HamRadio,代碼行數:43,代碼來源:WorkspaceBrowserTestFixture.cs

示例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;
			}
		}
開發者ID:xbadcode,項目名稱:Rubezh,代碼行數:22,代碼來源:WMFConverter.cs


注:本文中的System.Guid.Substring方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。