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


C# IResourceAccessor类代码示例

本文整理汇总了C#中IResourceAccessor的典型用法代码示例。如果您正苦于以下问题:C# IResourceAccessor类的具体用法?C# IResourceAccessor怎么用?C# IResourceAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MountingDataProxy

 /// <summary>
 /// Creates a new instance of this class which is based on the given <paramref name="baseAccessor"/>.
 /// </summary>
 /// <param name="key">Key which is used for this instance.</param>
 /// <param name="baseAccessor">Resource accessor denoting a filesystem resource.</param>
 public MountingDataProxy(string key, IResourceAccessor baseAccessor)
 {
   _key = key;
   _baseAccessor = baseAccessor;
   if (!MountResource())
     throw new EnvironmentException("Cannot mount resource '{0}' to local file system", baseAccessor);
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:12,代码来源:MountingDataProxy.cs

示例2: TryExtractMetadata

    public override bool TryExtractMetadata(IResourceAccessor mediaItemAccessor, IDictionary<Guid, MediaItemAspect> extractedAspectData, bool forceQuickMode)
    {
      try
      {
        IResourceAccessor metaFileAccessor;
        if (!CanExtract(mediaItemAccessor, extractedAspectData, out metaFileAccessor)) return false;

        Argus.Recording recording;
        using (metaFileAccessor)
        {
          using (Stream metaStream = ((IFileSystemResourceAccessor)metaFileAccessor).OpenRead())
            recording = (Argus.Recording)GetTagsXmlSerializer().Deserialize(metaStream);
        }

        // Handle series information
        SeriesInfo seriesInfo = GetSeriesFromTags(recording);
        if (seriesInfo.IsCompleteMatch)
        {
          if (!forceQuickMode)
            SeriesTvDbMatcher.Instance.FindAndUpdateSeries(seriesInfo);

          seriesInfo.SetMetadata(extractedAspectData);
        }
        return true;
      }
      catch (Exception e)
      {
        // Only log at the info level here - And simply return false. This lets the caller know that we
        // couldn't perform our task here.
        ServiceRegistration.Get<ILogger>().Info("ArgusRecordingSeriesMetadataExtractor: Exception reading resource '{0}' (Text: '{1}')", mediaItemAccessor.CanonicalLocalResourcePath, e.Message);
      }
      return false;
    }
开发者ID:aspik,项目名称:MediaPortal-2,代码行数:33,代码来源:ArgusRecordingMetadataExtractor.cs

示例3: TryCreateResourceAccessor

 public bool TryCreateResourceAccessor(string path, out IResourceAccessor result)
 {
   // TODO: support different ResourceAccessors for either local files (single seat) or network streams (multi seat). Current implementation always uses
   // network streams, even in single seat.
   result = SlimTvResourceAccessor.GetResourceAccessor(path);
   return result != null;
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:7,代码来源:SlimTvResourceProvider.cs

示例4: ResourceAccessorTextureImageSource

 /// <summary>
 /// Constructs a <see cref="ResourceAccessorTextureImageSource"/> for the given data.
 /// </summary>
 /// <param name="resourceAccessor">The resource accessor to load the texture data from.</param>
 /// <param name="rotation">Desired rotation for the given image.</param>
 public ResourceAccessorTextureImageSource(IResourceAccessor resourceAccessor, RightAngledRotation rotation)
 {
   _key = resourceAccessor.CanonicalLocalResourcePath.Serialize();
   _resourceAccessor = resourceAccessor;
   _stream = _resourceAccessor.OpenRead();
   _rotation = rotation;
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:12,代码来源:ResourceAccessorTextureImageSource.cs

示例5: Load

    /// <summary>
    /// Sets the font manager up with the specified <paramref name="resourcesCollection"/>.
    /// This method will load the font defaults (family and size) and the font files from the
    /// resource collection.
    /// </summary>
    public static void Load(IResourceAccessor resourcesCollection)
    {
      Unload();
      string defaultFontFilePath = resourcesCollection.GetResourceFilePath(
          SkinResources.FONTS_DIRECTORY + Path.DirectorySeparatorChar + DEFAULT_FONT_FILE);

      XPathDocument doc = new XPathDocument(defaultFontFilePath);

      XPathNavigator nav = doc.CreateNavigator();
      nav.MoveToChild(XPathNodeType.Element);
      _defaultFontFamily = nav.GetAttribute("FontFamily", string.Empty);
      string defaultFontSize = nav.GetAttribute("FontSize", string.Empty);
      _defaultFontSize = int.Parse(defaultFontSize);

      // Iterate over font family descriptors
      foreach (string descriptorFilePath in resourcesCollection.GetResourceFilePaths(
          "^" + SkinResources.FONTS_DIRECTORY + "\\\\.*\\.desc$").Values)
      {
        doc = new XPathDocument(descriptorFilePath);
        nav = doc.CreateNavigator();
        nav.MoveToChild(XPathNodeType.Element);
        string familyName = nav.GetAttribute("Name", string.Empty);
        if (string.IsNullOrEmpty(familyName))
          throw new ArgumentException("FontManager: Failed to parse family name for font descriptor file '{0}'", descriptorFilePath);
        string ttfFile = nav.GetAttribute("Ttf", string.Empty);
        if (string.IsNullOrEmpty(ttfFile))
          throw new ArgumentException("FontManager: Failed to parse ttf name for font descriptor file '{0}'", descriptorFilePath);

        string fontFilePath = resourcesCollection.GetResourceFilePath(
            SkinResources.FONTS_DIRECTORY + Path.DirectorySeparatorChar + ttfFile);
        FontFamily family = new FontFamily(familyName, fontFilePath);
        _families[familyName] = family;
      }
    }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:39,代码来源:FontManager.cs

示例6: TryCreateResourceAccessor

    public bool TryCreateResourceAccessor(string path, out IResourceAccessor result)
    {
      result = null;
      if (!IsResource(path))
        return false;

      result = new RawUrlResourceAccessor(path);
      return true;
    }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:9,代码来源:RawUrlResourceProvider.cs

示例7: TryCreateResourceAccessor

 public bool TryCreateResourceAccessor(string path, out IResourceAccessor result)
 {
   if (!IsResource(path))
   {
     result = null;
     return false;
   }
   result = new NetworkNeighborhoodResourceAccessor(this, path);
   return true;
 }
开发者ID:jgauffin,项目名称:MediaPortal-2,代码行数:10,代码来源:NetworkNeighborhoodResourceProvider.cs

示例8: AddSourceFilterOverride

 public static void AddSourceFilterOverride(Action fallbackAction, IResourceAccessor resourceAccessor, IGraphBuilder graphBuilder)
 {
   string sourceFilterName = GetSourceFilterName(resourceAccessor.ResourcePathName);
   if (string.IsNullOrEmpty(sourceFilterName))
   {
     fallbackAction();
   }
   else
   {
     AddStreamSourceFilter(sourceFilterName, resourceAccessor, graphBuilder);
   }
 }
开发者ID:aspik,项目名称:MediaPortal-2,代码行数:12,代码来源:PlayerHelpers.cs

示例9: ZipResourceProxy

 public ZipResourceProxy(string key, IResourceAccessor zipFileAccessor)
 {
   _key = key;
   _zipFileResourceAccessor = zipFileAccessor;
   _zipFileStream = _zipFileResourceAccessor.OpenRead(); // Not sure if the ZipFile closes the stream appropriately, so we keep a reference to it
   try
   {
     _zipFile = new ZipFile(_zipFileStream);
   }
   catch
   {
     _zipFileStream.Dispose();
     throw;
   }
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:15,代码来源:ZipResourceProxy.cs

示例10: IsoResourceProxy

    public IsoResourceProxy(string key, IResourceAccessor isoFileResourceAccessor)
    {
      _key = key;
      _isoFileResourceAccessor = isoFileResourceAccessor;

      _underlayingStream = _isoFileResourceAccessor.OpenRead();
      try
      {
        _diskFileSystem = GetFileSystem(_underlayingStream);
      }
      catch
      {
        _underlayingStream.Dispose();
        throw;
      }
    }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:16,代码来源:IsoResourceProxy.cs

示例11: ConnectFile

 public static bool ConnectFile(string nativeSystemId, ResourcePath nativeResourcePath, out IResourceAccessor result)
 {
   IRemoteResourceInformationService rris = ServiceRegistration.Get<IRemoteResourceInformationService>();
   result = null;
   bool isFileSystemResource;
   bool isFile;
   string resourcePathName;
   string resourceName;
   DateTime lastChanged;
   long size;
   if (!rris.GetResourceInformation(nativeSystemId, nativeResourcePath,
       out isFileSystemResource, out isFile, out resourcePathName, out resourceName, out lastChanged, out size) ||
           !isFile)
     return false;
   result = new RemoteFileResourceAccessor(nativeSystemId, nativeResourcePath, resourcePathName, resourceName, lastChanged, size);
   return true;
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:17,代码来源:RemoteFileResourceAccessor.cs

示例12: LocalFsResourceAccessorHelper

    /// <summary>
    /// Creates a new <see cref="LocalFsResourceAccessor"/> instance. The given <paramref name="mediaItemAccessor"/> will be either directly used or
    /// given over to the <see cref="StreamedResourceToLocalFsAccessBridge"/>. The caller must call <see cref="Dispose"/> on the created <see cref="LocalFsResourceAccessorHelper"/>
    /// instance but must not dispose the given <paramref name="mediaItemAccessor"/>.
    /// </summary>
    /// <param name="mediaItemAccessor">IResourceAccessor.</param>
    public LocalFsResourceAccessorHelper(IResourceAccessor mediaItemAccessor)
    {
      _localFsra = mediaItemAccessor as ILocalFsResourceAccessor;
      _disposeLfsra = null;
      if (_localFsra != null)
        return;

      IFileSystemResourceAccessor localFsra = (IFileSystemResourceAccessor) mediaItemAccessor.Clone();
      try
      {
        _localFsra = StreamedResourceToLocalFsAccessBridge.GetLocalFsResourceAccessor(localFsra);
        _disposeLfsra = _localFsra;
      }
      catch (Exception)
      {
        localFsra.Dispose();
        throw;
      }
    }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:25,代码来源:LocalFsResourceAccessorHelper.cs

示例13: AddStreamSourceFilter

    public static void AddStreamSourceFilter(string sourceFilterName, IResourceAccessor resourceAccessor, IGraphBuilder graphBuilder)
    {
      IBaseFilter sourceFilter = null;
      try
      {
        if (sourceFilterName == Utils.FilterName)
        {
          var filterPath = FileUtils.BuildAssemblyRelativePath(@"MPUrlSourceSplitter\MPUrlSourceSplitter.ax");
          sourceFilter = FilterLoader.LoadFilterFromDll(filterPath, new Guid(Utils.FilterCLSID));
          if (sourceFilter != null)
          {
            graphBuilder.AddFilter(sourceFilter, Utils.FilterName);
          }
        }
        else
        {
          sourceFilter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, sourceFilterName);
        }

        if (sourceFilter == null)
          throw new UPnPRendererExceptions(string.Format("Could not create instance of source filter: '{0}'", sourceFilterName));

        string url = resourceAccessor.ResourcePathName;

        var filterStateEx = sourceFilter as OnlineVideos.MPUrlSourceFilter.IFilterStateEx;
        if (filterStateEx != null)
          LoadAndWaitForMPUrlSourceFilter(url, filterStateEx);
        else
        {
          var fileSourceFilter = sourceFilter as IFileSourceFilter;
          if (fileSourceFilter != null)
            Marshal.ThrowExceptionForHR(fileSourceFilter.Load(resourceAccessor.ResourcePathName, null));
          else
            throw new UPnPRendererExceptions(string.Format("'{0}' does not implement IFileSourceFilter", sourceFilterName));
        }

        FilterGraphTools.RenderOutputPins(graphBuilder, sourceFilter);
      }
      finally
      {
        FilterGraphTools.TryRelease(ref sourceFilter);
      }
    }
开发者ID:aspik,项目名称:MediaPortal-2,代码行数:43,代码来源:PlayerHelpers.cs

示例14: TryExtractMetadata

    public bool TryExtractMetadata(IResourceAccessor mediaItemAccessor, IDictionary<Guid, MediaItemAspect> extractedAspectData, bool forceQuickMode)
    {
      try
      {
        if (!(mediaItemAccessor is IFileSystemResourceAccessor))
          return false;

        using (LocalFsResourceAccessorHelper rah = new LocalFsResourceAccessorHelper(mediaItemAccessor))
        {
          ILocalFsResourceAccessor lfsra = rah.LocalFsResourceAccessor;
          if (!lfsra.IsFile && lfsra.ResourceExists("BDMV"))
          {
            IFileSystemResourceAccessor fsraBDMV = lfsra.GetResource("BDMV");
            if (fsraBDMV != null && fsraBDMV.ResourceExists("index.bdmv"))
            {
              // This line is important to keep in, if no VideoAspect is created here, the MediaItems is not detected as Video! 
              MediaItemAspect.GetOrCreateAspect(extractedAspectData, VideoAspect.Metadata);
              MediaItemAspect mediaAspect = MediaItemAspect.GetOrCreateAspect(extractedAspectData, MediaAspect.Metadata);

              mediaAspect.SetAttribute(MediaAspect.ATTR_MIME_TYPE, "video/bluray"); // BluRay disc

              using (lfsra.EnsureLocalFileSystemAccess())
              {
                BDInfoExt bdinfo = new BDInfoExt(lfsra.LocalFileSystemPath);
                string title = bdinfo.GetTitle();
                mediaAspect.SetAttribute(MediaAspect.ATTR_TITLE, title ?? mediaItemAccessor.ResourceName);

                // Check for BD disc thumbs
                FileInfo thumbnail = bdinfo.GetBiggestThumb();
                if (thumbnail != null)
                {
                  try
                  {
                    using (FileStream fileStream = new FileStream(thumbnail.FullName, FileMode.Open, FileAccess.Read))
                    using (MemoryStream resized = (MemoryStream)ImageUtilities.ResizeImage(fileStream, ImageFormat.Jpeg, MAX_COVER_WIDTH, MAX_COVER_HEIGHT))
                    {
                      MediaItemAspect.SetAttribute(extractedAspectData, ThumbnailLargeAspect.ATTR_THUMBNAIL, resized.ToArray());
                    }
                  }
                    // Decoding of invalid image data can fail, but main MediaItem is correct.
                  catch
                  {
                  }
                }
              }
              return true;
            }
          }
        }
        return false;
      }
      catch
      {
        // Only log at the info level here - And simply return false. This makes the importer know that we
        // couldn't perform our task here
        if (mediaItemAccessor != null)
          ServiceRegistration.Get<ILogger>().Info("BluRayMetadataExtractor: Exception reading source '{0}'", mediaItemAccessor.ResourcePathName);
        return false;
      }
    }
开发者ID:pacificIT,项目名称:MediaPortal-2,代码行数:60,代码来源:BluRayMetadataExtractor.cs

示例15: TryExtractMetadata

    public bool TryExtractMetadata(IResourceAccessor mediaItemAccessor, IDictionary<Guid, MediaItemAspect> extractedAspectData, bool forceQuickMode)
    {
      try
      {
        if (forceQuickMode)
          return false;

        if (!(mediaItemAccessor is IFileSystemResourceAccessor))
          return false;
        using (LocalFsResourceAccessorHelper rah = new LocalFsResourceAccessorHelper(mediaItemAccessor))
          return ExtractThumbnail(rah.LocalFsResourceAccessor, extractedAspectData);
      }
      catch (Exception e)
      {
        // Only log at the info level here - And simply return false. This lets the caller know that we
        // couldn't perform our task here.
        ServiceRegistration.Get<ILogger>().Error("VideoThumbnailer: Exception reading resource '{0}' (Text: '{1}')", e, mediaItemAccessor.CanonicalLocalResourcePath, e.Message);
      }
      return false;
    }
开发者ID:jgauffin,项目名称:MediaPortal-2,代码行数:20,代码来源:VideoThumbnailer.cs


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