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


C# Stream.ReadAllBytes方法代码示例

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


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

示例1: Parse

        public static NameValueCollection Parse(Stream stream)
        {
            Dictionary<string, string[]> form = new Dictionary<string, string[]>();
            UTF8Encoding encoding = new UTF8Encoding(false);

            return HttpUtility.ParseQueryString(encoding.GetString(stream.ReadAllBytes()),encoding);
        }
开发者ID:sgarver,项目名称:RadMVC,代码行数:7,代码来源:FormParser.cs

示例2: Load

        /// <summary>
        /// 
        /// </summary>
        /// <param name="game"></param>
        /// <param name="stream"></param>
        /// <param name="requestedType"></param>
        /// <param name="assetPath"></param>
        /// <returns></returns>
        public override object Load( Game game, Stream stream, Type requestedType, string assetPath )
        {
            var bytes = stream.ReadAllBytes();

            if (assetPath.ToLowerInvariant().Contains("|default")) {
                return Encoding.Default.GetString( bytes );
            }

            if (assetPath.ToLowerInvariant().Contains("|utf8")) {
                return Encoding.UTF8.GetString( bytes );
            }

            if (assetPath.ToLowerInvariant().Contains("|utf7")) {
                return Encoding.UTF7.GetString( bytes );
            }

            if (assetPath.ToLowerInvariant().Contains("|utf32")) {
                return Encoding.UTF32.GetString( bytes );
            }

            if (assetPath.ToLowerInvariant().Contains("|ascii")) {
                return Encoding.ASCII.GetString( bytes );
            }

            return Encoding.Default.GetString( bytes );
        }
开发者ID:Annaero,项目名称:FusionFramework,代码行数:34,代码来源:StringLoader.cs

示例3: CreatePackage

        public void CreatePackage(string apiKey, Stream packageStream, IObserver<int> progressObserver, IPackageMetadata metadata = null)
        {
            var state = new PublishState {
                PublishKey = apiKey,
                PackageMetadata = metadata,
                ProgressObserver = progressObserver
            };

            var url = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}/nupkg", _baseGalleryServerUrl, CreatePackageService, apiKey));

            WebClient client = new WebClient();
            client.Proxy = _cachedProxy;
            client.Headers[HttpRequestHeader.ContentType] = "application/octet-stream";
            client.Headers[HttpRequestHeader.UserAgent] = _userAgent;
            client.UploadProgressChanged += OnUploadProgressChanged;
            client.UploadDataCompleted += OnCreatePackageCompleted;
            client.UploadDataAsync(url, "POST", packageStream.ReadAllBytes(), state);
        }
开发者ID:jacksonh,项目名称:nuget,代码行数:18,代码来源:GalleryServer.cs

示例4: Writefile

 public void Writefile(string filePath, Stream data)
 {
     File.WriteAllBytes(filePath, data.ReadAllBytes());
 }
开发者ID:mvbalaw,项目名称:MvbaCore,代码行数:4,代码来源:FileSystemService.cs

示例5: GetExistingPersistentCertificate

 /// <summary>
 /// Reads an X509 certificate from the given stream
 /// </summary>
 /// <returns>The retrieved certificate</returns>
 /// <param name="stream">The stream that contains the X509 certificate data.</param>
 /// <param name="password">The password to use to open the certificate.</param>
 public static X509Certificate2 GetExistingPersistentCertificate(Stream stream, string password)
 {
     return new X509Certificate2(stream.ReadAllBytes(), password);
 }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:10,代码来源:X509Manager.cs

示例6: SetDocument

 /// <summary>
 /// Initializes the document metadata with bytes fed from the supplied stream
 /// </summary>
 /// <param name="document"></param>
 public void SetDocument(Stream document)
 {
     SetDocument(document.ReadAllBytes());
 }
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:8,代码来源:DocumentMetadata.cs

示例7: Load

		public override object Load ( ContentManager content, Stream stream, Type requestedType, string assetPath )
		{
			return stream.ReadAllBytes();
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:4,代码来源:BytesLoader.cs

示例8: CalculateDerivedData

        protected virtual void CalculateDerivedData(IPackage sourcePackage, LucenePackage package, string path, Stream stream)
        {
            byte[] fileBytes;
            using (stream)
            {
                fileBytes = stream.ReadAllBytes();
            }

            package.PackageSize = fileBytes.Length;
            package.PackageHash = System.Convert.ToBase64String(HashProvider.CalculateHash(fileBytes));
            package.PackageHashAlgorithm = HashAlgorithm;
            package.LastUpdated = FileSystem.GetLastModified(path);
            package.Published = package.LastUpdated;
            package.Created = GetZipArchiveCreateDate(new MemoryStream(fileBytes));
            package.Path = path;

            package.SupportedFrameworks = sourcePackage.GetSupportedFrameworks().Select(VersionUtility.GetShortFrameworkName);

            var localPackage = sourcePackage as LocalPackage;
            if (localPackage != null)
            {
                package.Files = localPackage.GetFiles().Select(f => f.Path);
            }
        }
开发者ID:modulexcite,项目名称:NuGet.Lucene,代码行数:24,代码来源:LucenePackageRepository.cs

示例9: CalculateDerivedDataSlowlyConsumingLotsOfMemory

        private void CalculateDerivedDataSlowlyConsumingLotsOfMemory(LucenePackage package, Stream stream)
        {
            byte[] fileBytes;
            using (stream)
            {
                fileBytes = stream.ReadAllBytes();
            }

            package.PackageSize = fileBytes.Length;
            package.PackageHash = System.Convert.ToBase64String(HashProvider.CalculateHash(fileBytes));
            package.Created = GetZipArchiveCreateDate(new MemoryStream(fileBytes));
        }
开发者ID:Tallmaris,项目名称:NuGet.Lucene,代码行数:12,代码来源:LucenePackageRepository.cs

示例10: DeserializeFeatureGen

 private static object DeserializeFeatureGen(Stream inputStream) {
     return inputStream.ReadAllBytes();
 }
开发者ID:knuppe,项目名称:SharpNL,代码行数:3,代码来源:TokenNameFinderModel.cs

示例11: SpriteFont

		/// <summary>
		/// Constrcutor
		/// </summary>
		/// <param name="device"></param>
		/// <param name="fileName"></param>
		public SpriteFont ( GraphicsDevice rs, Stream stream )
		{
			this.rs	=	rs;

			using (var br = new BinaryReader(stream)) {

				var xml = br.ReadString();
				FontFile input = FontLoader.LoadFromString( xml );

				int numGlyphs	=	input.Chars.Max( ch => ch.ID );

				//	create charInfo and kernings :
				fontInfo.kernings = new Dictionary<Tuple<char,char>, float>();
				fontInfo.charInfo = new SpriteFontInfo.CharInfo[numGlyphs+1];

				//	check one-page bitmap fonts :
				if (input.Pages.Count!=1) {
					throw new GraphicsException("Only one page of font image is supported");
				}

				//	create path for font-image :
				string fontImagePath	=	input.Pages[0].File;

				//	skip two bytes :
				var texData				=	stream.ReadAllBytes();
				fontTexture				=	new UserTexture( rs.Game.RenderSystem, texData, false );
			
				//	Fill structure :
				fontInfo.fontFace		=	input.Info.Face;
				fontInfo.baseLine		=	input.Common.Base;
				fontInfo.lineHeight		=	input.Common.LineHeight;
				fontInfo.scaleWidth		=	input.Common.ScaleW;
				fontInfo.scaleHeight	=	input.Common.ScaleH;

				float scaleWidth = fontInfo.scaleWidth;
				float scaleHeight = fontInfo.scaleHeight;

				//	process character info :
				for ( int i=0; i<input.Chars.Count; i++) {
					FontChar ch = input.Chars[i];

					int id = ch.ID;

					if (id<0) continue;

					int x = ch.X;
					int y = ch.Y;
					int xoffs = ch.XOffset;
					int yoffs = ch.YOffset;
					int w = ch.Width;
					int h = ch.Height;

					fontInfo.charInfo[ ch.ID ].validChar	=	true;
					fontInfo.charInfo[ ch.ID ].xAdvance		=	ch.XAdvance;
					fontInfo.charInfo[ ch.ID ].srcRect		=	new RectangleF(x, y, w, h);
					fontInfo.charInfo[ ch.ID ].dstRect		=	new RectangleF(xoffs, yoffs, w, h);
				}


				var letterHeights = input.Chars
						.Where( ch1 => char.IsUpper( (char)(ch1.ID) ) )
						.Select( ch2 => ch2.Height )
						.OrderBy( h => h )
						.ToList();
				CapHeight	=	letterHeights[ letterHeights.Count/2 ];



				//	process kerning info :
				for ( int i=0; i<input.Kernings.Count; i++) {
					var pair	=	new Tuple<char,char>( (char)input.Kernings[i].First, (char)input.Kernings[i].Second);
					int kerning =	input.Kernings[i].Amount;
					fontInfo.kernings.Add( pair, kerning );
				}

				SpaceWidth	=	MeasureString(" ").Width;
				LineHeight	=	MeasureString(" ").Height;
			}
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:84,代码来源:SpriteFont.cs


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