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


C# IResource.Open方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:willcraftia,项目名称:TestBlocks,代码行数:8,代码来源:DefinitionSerializer.cs

示例2: LoadTexture

 Texture2D LoadTexture(IResource resource)
 {
     using (var stream = resource.Open())
     {
         var result = Texture2D.FromStream(graphicsDevice, stream);
         result.Name = resource.AbsoluteUri;
         return result;
     }
 }
开发者ID:willcraftia,项目名称:TestBlocks,代码行数:9,代码来源:Image2DLoader.cs

示例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);
     }
 }
开发者ID:jammycakes,项目名称:dolstagis.web,代码行数:10,代码来源:DotLiquidView.cs

示例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);
     }
 }
开发者ID:jammycakes,项目名称:dolstagis.web,代码行数:11,代码来源:NustacheView.cs

示例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);
        }
开发者ID:netide,项目名称:netide,代码行数:22,代码来源:StreamUtil.cs


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