本文整理汇总了C#中IResource.Open方法的典型用法代码示例。如果您正苦于以下问题:C# IResource.Open方法的具体用法?C# IResource.Open怎么用?C# IResource.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResource
的用法示例。
在下文中一共展示了IResource.Open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public object Deserialize(IResource resource)
{
var serializer = GetSerializer(resource.Extension);
using (var stream = resource.Open())
{
return serializer.Deserialize(stream, null);
}
}
示例2: LoadTexture
Texture2D LoadTexture(IResource resource)
{
using (var stream = resource.Open())
{
var result = Texture2D.FromStream(graphicsDevice, stream);
result.Name = resource.AbsoluteUri;
return result;
}
}
示例3: DotLiquidView
public DotLiquidView(VirtualPath path, IResource resource, IResourceResolver resolver)
{
_path = path;
_resolver = resolver;
using (var stream = resource.Open())
using (var reader = new StreamReader(stream)) {
string tpl = reader.ReadToEnd();
_template = Template.Parse(tpl);
}
}
示例4: NustacheView
public NustacheView(NustacheViewEngine engine, VirtualPath path, IResource resource, IResourceResolver resolver)
{
_engine = engine;
_path = path;
_resolver = resolver;
using (var stream = resource.Open())
using (var reader = new StreamReader(stream)) {
Template = new Template();
Template.Load(reader);
}
}
示例5: ToStream
public static Stream ToStream(IResource resource)
{
if (resource == null)
throw new ArgumentNullException("resource");
// This is a hack for performance reasons. When the resource
// represents a file, there really is no reason why we can't just
// go to disk ourselves instead of going over AppDomain boundaries.
string fileName = resource.FileName;
if (fileName != null && File.Exists(fileName))
return File.OpenRead(fileName);
IStream stream;
ErrorUtil.ThrowOnFailure(resource.Open(out stream));
if (stream == null)
return null;
return ToStream(stream);
}