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


C# IFileSystemResourceAccessor.Dispose方法代码示例

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


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

示例1: GetLocalFsResourceAccessor

    /// <summary>
    /// Returns a resource accessor instance of interface <see cref="ILocalFsResourceAccessor"/>. This instance will return the
    /// given <paramref name="baseResourceAccessor"/>, casted to <see cref="ILocalFsResourceAccessor"/> if possible, or
    /// a new instance of <see cref="StreamedResourceToLocalFsAccessBridge"/> to provide the <see cref="ILocalFsResourceAccessor"/>
    /// instance.
    /// </summary>
    /// <remarks>
    /// The ownership of the given <paramref name="baseResourceAccessor"/> is transferred from the caller to the returned
    /// result value. That means, if this method succeeds, the caller must dispose the result value, it must not dispose
    /// the given <paramref name="baseResourceAccessor"/> any more.
    /// </remarks>
    /// <param name="baseResourceAccessor">Resource accessor which is used to provide the resource contents.</param>
    /// <param name="path">Relative path based on the given baseResourceAccessor.</param>
    /// <returns>Resource accessor which implements <see cref="ILocalFsResourceAccessor"/>.</returns>
    public static ILocalFsResourceAccessor GetLocalFsResourceAccessor(IFileSystemResourceAccessor baseResourceAccessor, string path)
    {
      // Try to get an ILocalFsResourceAccessor
      ILocalFsResourceAccessor result = baseResourceAccessor as ILocalFsResourceAccessor;
      if (result != null)
          // Simple case: The media item is located in the local file system or the resource provider returns
          // an ILocalFsResourceAccessor from elsewhere - simply return it
        return result;

      // Set up a resource bridge mapping the remote or complex resource to a local file or directory
      string key = baseResourceAccessor.CanonicalLocalResourcePath.Serialize();
      MountingDataProxy md;
      bool dispose = false;
      lock (_syncObj)
      {
        if (_activeMounts.TryGetValue(key, out md))
            // Base accessor not needed - we use our cached accessor
          dispose = true;
        else
          _activeMounts.Add(key, md = CreateMountingDataProxy(key, baseResourceAccessor));
      }
      if (dispose)
        baseResourceAccessor.Dispose();
      return new StreamedResourceToLocalFsAccessBridge(md, path);
    }
开发者ID:HeinA,项目名称:MediaPortal-2,代码行数:39,代码来源:StreamedResourceToLocalFsAccessBridge.cs


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