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


C# Stream.ToBytes方法代码示例

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


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

示例1: DownloadNzb

        public string DownloadNzb(Stream nzb, string title, string category, int priority, NzbgetSettings settings)
        {
            var parameters = new object[] { title, category, priority, false, Convert.ToBase64String(nzb.ToBytes()) };
            var request = BuildRequest(new JsonRequest("append", parameters));

            var response = Json.Deserialize<NzbgetResponse<Boolean>>(ProcessRequest(request, settings));
            _logger.Trace("Response: [{0}]", response.Result);

            if (!response.Result)
            {
                return null;
            }

            var queue = GetQueue(settings);
            var item = queue.FirstOrDefault(q => q.NzbName == title.Substring(0, title.Length - 4));

            if (item == null)
            {
                return null;
            }

            var droneId = Guid.NewGuid().ToString().Replace("-", "");
            var editResult = EditQueue("GroupSetParameter", 0, "drone=" + droneId, item.LastId, settings);

            if (editResult)
            {
                _logger.Debug("Nzbget download drone parameter set to: {0}", droneId);
            }

            return droneId;
        }
开发者ID:niel,项目名称:NzbDrone,代码行数:31,代码来源:NzbgetProxy.cs

示例2: AddDeferredMessage

 public void AddDeferredMessage(TransportMessage processingTransportMessage, Stream deferredTransportMessageStream)
 {
     using (_databaseConnectionFactory.Create(IdempotenceDataSource))
     {
         _databaseGateway.ExecuteUsing(
             IdempotenceDataSource,
             RawQuery.Create(_scriptProvider.GetScript(Script.IdempotenceSendDeferredMessage))
                     .AddParameterValue(IdempotenceColumns.MessageId, processingTransportMessage.MessageId)
                     .AddParameterValue(IdempotenceColumns.MessageBody, deferredTransportMessageStream.ToBytes()));
     }
 }
开发者ID:jessezhao,项目名称:shuttle-esb,代码行数:11,代码来源:IdempotenceService.cs

示例3: DownloadNzb

        public SabnzbdAddResponse DownloadNzb(Stream nzb, string title, string category, int priority, SabnzbdSettings settings)
        {
            var request = new RestRequest(Method.POST);
            var action = String.Format("mode=addfile&cat={0}&priority={1}", category, priority);

            request.AddFile("name", nzb.ToBytes(), title, "application/x-nzb");

            SabnzbdAddResponse response;

            if (!Json.TryDeserialize<SabnzbdAddResponse>(ProcessRequest(request, action, settings), out response))
            {
                response = new SabnzbdAddResponse();
                response.Status = true;
            }

            return response;
        }
开发者ID:Taloth,项目名称:NzbDrone,代码行数:17,代码来源:SabnzbdProxy.cs

示例4: Enqueue

        public void Enqueue(Guid messageId, Stream stream)
        {
            try
            {
                using (databaseConnectionFactory.Create(dataSource))
                {
                    databaseGateway.ExecuteUsing(
                        dataSource,
                        RawQuery.CreateFrom(enqueueQueryStatement)
                                .AddParameterValue(QueueColumns.MessageId, messageId)
                                .AddParameterValue(QueueColumns.MessageBody, stream.ToBytes()));
                }
            }
            catch (Exception ex)
            {
                log.Debug(
                    string.Format(
                        "Could not enqueue message id '{0}' on queue '{1}'.  Exception: {2}", messageId, Uri, ex.Message));

                throw;
            }
        }
开发者ID:nnyamhon,项目名称:shuttle-esb,代码行数:22,代码来源:SqlQueue.cs

示例5: ProcessHeaderStream

        private WebHeaderCollection ProcessHeaderStream(HttpRequest request, CookieContainer cookies, Stream headerStream)
        {
            headerStream.Position = 0;
            var headerData = headerStream.ToBytes();
            var headerString = Encoding.ASCII.GetString(headerData);

            var webHeaderCollection = new WebHeaderCollection();

            // following a redirect we could have two sets of headers, so only process the last one
            foreach (var header in headerString.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Reverse())
            {
                if (!header.Contains(":")) break;
                webHeaderCollection.Add(header);
            }

            var setCookie = webHeaderCollection.Get("Set-Cookie");
            if (setCookie != null && setCookie.Length > 0 && cookies != null)
            {
                try
                {
                    cookies.SetCookies((Uri)request.Url, FixSetCookieHeader(setCookie));
                }
                catch (CookieException ex)
                {
                    _logger.Debug("Rejected cookie {0}: {1}", ex.InnerException.Message, setCookie);
                }
            }

            return webHeaderCollection;
        }
开发者ID:drewfreyling,项目名称:NzbDrone,代码行数:30,代码来源:CurlHttpDispatcher.cs

示例6: Enqueue

        public void Enqueue(Guid messageId, Stream stream)
        {
            try
            {
                using (_databaseConnectionFactory.Create(_dataSource))
                {
                    _databaseGateway.ExecuteUsing(
                        _dataSource,
                        RawQuery.Create(_enqueueQueryStatement)
                                .AddParameterValue(QueueColumns.MessageId, messageId)
                                .AddParameterValue(QueueColumns.MessageBody, stream.ToBytes()));
                }
            }
            catch (Exception ex)
            {
                _log.Error(
                    string.Format(SqlResources.EnqueueError, messageId, Uri, ex.Message));

                throw;
            }
        }
开发者ID:jessezhao,项目名称:shuttle-esb,代码行数:21,代码来源:SqlQueue.cs

示例7: ProcessHeaderStream

        private WebHeaderCollection ProcessHeaderStream(HttpWebRequest webRequest, Stream headerStream)
        {
            headerStream.Position = 0;
            var headerData = headerStream.ToBytes();
            var headerString = Encoding.ASCII.GetString(headerData);

            var webHeaderCollection = new WebHeaderCollection();

            foreach (var header in headerString.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Skip(1))
            {
                webHeaderCollection.Add(header);
            }

            var setCookie = webHeaderCollection.Get("Set-Cookie");
            if (setCookie != null && setCookie.Length > 0 && webRequest.CookieContainer != null)
            {
                webRequest.CookieContainer.SetCookies(webRequest.RequestUri, setCookie);
            }

            return webHeaderCollection;
        }
开发者ID:nnic,项目名称:Sonarr,代码行数:21,代码来源:CurlHttpClient.cs

示例8: Decompress

 public static Stream Decompress(Stream input) {
     return new MemoryStream(Decompress(input.ToBytes()));
 }
开发者ID:debop,项目名称:NFramework,代码行数:3,代码来源:Compressor.cs

示例9: CompressAsync

        /// <summary>
        /// 원본 스트림을 압축하여, 대상 스트림에 씁니다.
        /// </summary>
        /// <param name="sourceStream"></param>
        /// <param name="destinationStream"></param>
        public virtual void CompressAsync(Stream sourceStream, Stream destinationStream) {
            sourceStream.ShouldNotBeNull("sourceStream");
            destinationStream.ShouldNotBeNull("destinationStream");

            var compressedBytes = Compress(sourceStream.ToBytes());
            destinationStream.WriteAsync(compressedBytes, 0, compressedBytes.Length);
        }
开发者ID:debop,项目名称:NFramework,代码行数:12,代码来源:CompressAdapter.cs

示例10: Compress

 /// <summary>
 /// 지정된 스트림을 압축합니다.
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public virtual byte[] Compress(Stream input) {
     input.ShouldNotBeNull("input");
     return Compress(input.ToBytes());
 }
开发者ID:debop,项目名称:NFramework,代码行数:9,代码来源:CompressAdapter.cs

示例11: DecompressAsync

        /// <summary>
        /// 원본 스트림을 압축 해제하여, 대상 스트림에 씁니다.
        /// </summary>
        /// <param name="sourceStream"></param>
        /// <param name="targetStream"></param>
        public virtual void DecompressAsync(Stream sourceStream, Stream targetStream) {
            sourceStream.ShouldNotBeNull("sourceStream");
            targetStream.ShouldNotBeNull("destinationStream");

            var decompresedBytes = Decompress(sourceStream.ToBytes());
            targetStream.WriteAsync(decompresedBytes, 0, decompresedBytes.Length);
            targetStream.SetStreamPosition();
        }
开发者ID:debop,项目名称:NFramework,代码行数:13,代码来源:CompressAdapter.cs

示例12: Store

 public override void Store(Stream stream, FileSystemObject fso)
 {
     SaveToMap(stream.ToBytes(), fso);
 }
开发者ID:derFunk,项目名称:ServiceStack.Aws,代码行数:4,代码来源:InMemoryFileStorageProvider.cs

示例13: PostStream

        /// <summary>
        /// POST 방식으로 서버에 접속하여 응답 Stream을 반환 받는다.
        /// </summary>
        /// <param name="stream">서버에 전달할 내용</param>
        /// <returns></returns>
        protected virtual Stream PostStream(Stream stream) {
            stream.ShouldNotBeNull("stream");

            if(IsDebugEnabled)
                log.Debug("지정된 스트림을 전송합니다.");

            Request.Credentials = GetCredentials();
            Request.Method = WebRequestMethods.Http.Post;
            Request.ContentType = POST_CONTENT_TYPE;

            if(stream == null) {
                Request.ContentLength = 0;
            }
            if(stream != null) {
                byte[] payload = stream.ToBytes();

                using(var requestStream = Request.GetRequestStream())
                using(var bw = new BinaryWriter(requestStream, XmlTool.XmlEncoding)) {
                    bw.Write(payload);
                }
            }

            return IsAsync
                       ? With.TryFunctionAsync(() => Request.GetResponseStreamAsync().Result)
                       : Request.GetResponse().GetResponseStream();
        }
开发者ID:debop,项目名称:NFramework,代码行数:31,代码来源:XmlHttpClient.cs

示例14: SaveBlobAsync

 public Task SaveBlobAsync(string container, string key, Stream bloblStream)
 {
     return PostHttpReqest(container, key, bloblStream.ToBytes());
 }
开发者ID:LykkeCity,项目名称:MarketPlace,代码行数:4,代码来源:AzureBlobLocal.cs

示例15: ExecuteStreamInternal

        /// <summary>
        /// 
        /// </summary>
        /// <param name="requestStream"></param>
        /// <param name="productName"></param>
        /// <param name="serializer"></param>
        /// <returns></returns>
        public static Stream ExecuteStreamInternal(Stream requestStream, string productName, ISerializer serializer) {
            XdsResponseDocument xdsResponse = null;
            MemoryStream result = null;
            try {
                Guard.Assert(requestStream != null && requestStream.Length > 0, "요청 정보가 없습니다.");
                CheckProductExists(productName);

                var xdsRequest = (XdsRequestDocument)serializer.Deserialize(requestStream.ToBytes());
                xdsResponse = XmlDataServiceFacade.Execute(xdsRequest, productName);
            }
            catch(Exception ex) {
                if(log.IsErrorEnabled)
                    log.ErrorException("예외가 발생했습니다.", ex);

                if(xdsResponse == null)
                    xdsResponse = new XdsResponseDocument();
                xdsResponse.ReportError(ex);
            }
            finally {
                result = new MemoryStream(serializer.Serialize(xdsResponse));
            }
            return result;
        }
开发者ID:debop,项目名称:NFramework,代码行数:30,代码来源:XmlDataServiceFacade.cs


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