当前位置: 首页>>代码示例>>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;未经允许,请勿转载。