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


C# ResourcePath.TryCreateLocalResourceAccessor方法代码示例

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


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

示例1: GetChildDirectoriesData

 protected override IEnumerable<ResourcePathMetadata> GetChildDirectoriesData(ResourcePath path)
 {
   IResourceAccessor ra;
   if (path.TryCreateLocalResourceAccessor(out ra))
   {
     using (ra)
     {
       IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor;
       if (fsra == null)
         yield break;
       ICollection<IFileSystemResourceAccessor> res = FileSystemResourceNavigator.GetChildDirectories(fsra, false);
       if (res != null)
         foreach (IFileSystemResourceAccessor childAccessor in res)
           using (childAccessor)
           {
             yield return new ResourcePathMetadata
               {
                   ResourceName = childAccessor.ResourceName,
                   HumanReadablePath = childAccessor.ResourcePathName,
                   ResourcePath = childAccessor.CanonicalLocalResourcePath
               };
           }
     }
   }
   else
     ServiceRegistration.Get<ILogger>().Warn("LocalShares: Cannot access resource path '{0}' for getting child directories", path);
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:27,代码来源:LocalShares.cs

示例2: GetLocalResourcePathDisplayName

 public static string GetLocalResourcePathDisplayName(ResourcePath path)
 {
   if (path == null)
     return string.Empty;
   IResourceAccessor ra;
   if (path.TryCreateLocalResourceAccessor(out ra))
     using (ra)
       return ra.ResourcePathName;
   ServiceRegistration.Get<ILogger>().Warn("LocalShares: Cannot access resource path '{0}' for updating display name", path);
   return string.Empty;
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:11,代码来源:LocalShares.cs

示例3: GetResourceAccessor

 protected IResourceAccessor GetResourceAccessor(ResourcePath resourcePath)
 {
     lock (_syncObj)
     {
         CachedResource resource;
         string resourcePathStr = resourcePath.Serialize();
         if (_resourceAccessorCache.TryGetValue(resourcePathStr, out resource))
             return resource.ResourceAccessor;
         // TODO: Security check. Only deliver resources which are located inside local shares.
         ServiceRegistration.Get<ILogger>().Debug("ResourceAccessModule: Access of resource '{0}'", resourcePathStr);
         IResourceAccessor result;
         if(!resourcePath.TryCreateLocalResourceAccessor(out result))
             ServiceRegistration.Get<ILogger>().Debug("ResourceAccessModule: Unable to access resource path '{0}'", resourcePathStr);
         _resourceAccessorCache[resourcePathStr] = new CachedResource(result);
         return result;
     }
 }
开发者ID:FreakyJ,项目名称:MediaServer-fo-MP2,代码行数:17,代码来源:DlnaResourceAccessModule.cs

示例4: GetFilesData

 protected IEnumerable<ResourcePathMetadata> GetFilesData(ResourcePath path)
 {
   IResourceAccessor ra;
   if (path.TryCreateLocalResourceAccessor(out ra))
   {
     using (ra)
     {
       ICollection<IFileSystemResourceAccessor> res = FileSystemResourceNavigator.GetFiles(ra, ShowSystemResources);
       if (res != null)
         foreach (IFileSystemResourceAccessor fileAccessor in res)
           using(fileAccessor)
           {
             yield return new ResourcePathMetadata
               {
                   ResourceName = fileAccessor.ResourceName,
                   HumanReadablePath = fileAccessor.ResourcePathName,
                   ResourcePath = fileAccessor.CanonicalLocalResourcePath
               };
           }
     }
   }
   else
   {
     ServiceRegistration.Get<ILogger>().Warn("FileBrowserModel: Cannot access resource path '{0}' for getting files", path);
     yield break;
   }
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:27,代码来源:PathBrowserService.cs

示例5: GetResourceAccessor

 protected IFileSystemResourceAccessor GetResourceAccessor(ResourcePath resourcePath)
 {
   lock (_syncObj)
   {
     CachedResource resource;
     string resourcePathStr = resourcePath.Serialize();
     if (_resourceAccessorCache.TryGetValue(resourcePathStr, out resource))
       return resource.ResourceAccessor;
     // TODO: Security check. Only deliver resources which are located inside local shares.
     ServiceRegistration.Get<ILogger>().Debug("ResourceAccessModule: Access of resource '{0}'", resourcePathStr);
     IResourceAccessor ra;
     if (!resourcePath.TryCreateLocalResourceAccessor(out ra))
       throw new ArgumentException("Unable to access resource path '{0}'", resourcePathStr);
     IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor;
     if (fsra == null)
     {
       ra.Dispose();
       throw new ArgumentException("The given resource path '{0}' doesn't denote a file system resource", resourcePathStr);
     }
     _resourceAccessorCache[resourcePathStr] = new CachedResource(fsra);
     return fsra;
   }
 }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:23,代码来源:ResourceAccessModule.cs


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