本文整理汇总了C#中IAsset.OpenStream方法的典型用法代码示例。如果您正苦于以下问题:C# IAsset.OpenStream方法的具体用法?C# IAsset.OpenStream怎么用?C# IAsset.OpenStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAsset
的用法示例。
在下文中一共展示了IAsset.OpenStream方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendAsset
void SendAsset(Bundle bundle, IAsset asset)
{
response.ContentType = bundle.ContentType;
var actualETag = "\"" + asset.Hash.ToHexString() + "\"";
if(request.RawUrl.Contains(asset.Hash.ToHexString())) {
HttpResponseUtil.CacheLongTime(response, actualETag);
}
else {
HttpResponseUtil.NoCache(response);
}
var givenETag = request.Headers["If-None-Match"];
if (givenETag == actualETag)
{
HttpResponseUtil.SendNotModified(response);
}
else
{
HttpResponseUtil.EncodeStreamAndAppendResponseHeaders(request, response);
using (var stream = asset.OpenStream())
{
stream.CopyTo(response.OutputStream);
}
}
}
示例2: SendAsset
void SendAsset(HttpRequestBase request, HttpResponseBase response, Bundle bundle, IAsset asset)
{
response.ContentType = bundle.ContentType;
var actualETag = "\"" + asset.Hash.ToHexString() + "\"";
CacheLongTime(response, actualETag);
var givenETag = request.Headers["If-None-Match"];
if (givenETag == actualETag)
{
SendNotModified(response);
}
else
{
using (var stream = asset.OpenStream())
{
stream.CopyTo(response.OutputStream);
}
}
}
示例3: WriteAsset
void WriteAsset(IAsset asset, StreamWriter writer)
{
using (var reader = new StreamReader(asset.OpenStream()))
{
var isFirstLine = true;
string line;
while ((line = reader.ReadLine()) != null)
{
if (isFirstLine)
{
isFirstLine = false;
}
else
{
writer.WriteLine();
}
writer.Write(line);
}
}
}
示例4: ParseJavaScript
static Block ParseJavaScript(IAsset asset)
{
var source = asset.OpenStream().ReadToEnd();
var parser = new JSParser(source);
return parser.Parse(new CodeSettings());
}