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


C# Byte.Sha1Hash方法代码示例

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


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

示例1: LoadOrCreate

		public MaterialJPG LoadOrCreate(Byte[] pictureToHandle,
			String fullFileName, String extension, bool duplicateAllowed = false)
			{
			String sha1Hash = pictureToHandle.Sha1Hash().ConvertTo_Hex();
			extension = extension.ToLower();
			String pictureName = Path.GetFileNameWithoutExtension(fullFileName);
			MaterialJPG materialJpg = null;
			if (duplicateAllowed)
				{
				MaterialJPG[] materialJpgs = FindOrLoad_via_HashCode_MultipleAllowed(sha1Hash);
				if (materialJpgs.Length > 0)
					{
					foreach (MaterialJPG matJpg in materialJpgs)
						{
						if (matJpg.NameId == pictureName)
							return matJpg;
						}
					}
				}
			else
				{
				materialJpg = FindOrLoad_via_HashCode(sha1Hash);
				if (materialJpg != null)
					{
					return materialJpg;
					}
				}
			materialJpg = NewRow();
			materialJpg.Id = Guid.NewGuid();
			materialJpg.HashCode = sha1Hash;
			materialJpg.FullFileNameToLoadFrom = fullFileName;
			materialJpg.NameId = pictureName;
			materialJpg.Value = pictureToHandle;
			Rows.Add(materialJpg);
			SaveChanges(new Object());
			AcceptChanges();
			return materialJpg;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:38,代码来源:MaterialienJPGTable.cs

示例2: LoadOrCreate

		public MMPicture LoadOrCreate(Byte[] pictureToHandle, 
			String pictureName, String extension, bool DuplicateAllowed = false, Guid? pictureSourceId = null)
			{
			String sha1Hash = pictureToHandle.Sha1Hash().ConvertTo_Hex();
			extension = extension.ToLower();
			//if ((sha1Hash == "AADD0FE8A153C1EB7AC17741E779E8E85C085065")
			//	|| (sha1Hash == "1494495D8FA25B1E01544E65B08D55FFD0823913"))	//
			//	{
			//	return DataContext.MultiMedia.MMPictures.FirstOrDefault();
			//	}
			MMPicture mmPicture = null;
			if (DuplicateAllowed)
				{
				MMPicture[] mmPictures = FindOrLoad_via_HashCode_MultipleAllowed(sha1Hash);
				if (mmPictures.Length > 0)
					{
					foreach (MMPicture picture in mmPictures)
						{
						if (picture.NameId == pictureName)
							return picture;
						}
					}
				}
			else
				{
				mmPicture = FindOrLoad_via_HashCode(sha1Hash);
				if (mmPicture != null)
					{
					return mmPicture;
					}
				}
			mmPicture = NewRow();
			mmPicture.Id = Guid.NewGuid();
			mmPicture.HashCode = sha1Hash;
			mmPicture.NameId = pictureName;
			if (extension == "jpg")
				{
				mmPicture.TypId = Guid.Parse("9D5E28CC-BBC4-4F3B-B236-ECC9C2BB756F");
				mmPicture.ValueThumb = pictureToHandle.ConvertTo_Image().ResizeToMaximum(300, 200).ConvertTo_JpgByteArray();
				}
			else if (extension == "png")
				{
				mmPicture.TypId = Guid.Parse("AC48A5BA-EFC5-41C8-825A-E6BC6660EB73");
				mmPicture.ValueThumb = pictureToHandle.ConvertTo_Image().ResizeToMaximum(300, 200).ConvertTo_PngByteArray();

				}
			else if (extension == "bmp")
				{
				mmPicture.TypId = Guid.Parse("44D0A3D2-F95A-4E44-81DB-A8A8B8A8DF71");
				mmPicture.ValueThumb = pictureToHandle.ConvertTo_Image().ResizeToMaximum(300, 200).ConvertTo_JpgByteArray();
				}
			else
				{
				Debug.WriteLine($"Fehler, der Typ wurde nicht erkannt --- > Hash= {sha1Hash}");
				return null;
				}
			mmPicture.Value = pictureToHandle;
			if (pictureSourceId != null)
				mmPicture.PictureSourceId = pictureSourceId;
			Rows.Add(mmPicture);
			SaveChanges(new Object());
			AcceptChanges();
			return mmPicture;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:64,代码来源:MMPicturesTable.cs


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