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


C# BaseItem.GetType方法代码示例

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


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

示例1: SetInitialItemValues

        /// <summary>
        /// Sets the initial item values.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="libraryManager">The library manager.</param>
        /// <param name="directoryService">The directory service.</param>
        /// <exception cref="System.ArgumentException">Item must have a path</exception>
        public static void SetInitialItemValues(BaseItem item, Folder parent, IFileSystem fileSystem, ILibraryManager libraryManager, IDirectoryService directoryService)
        {
            // This version of the below method has no ItemResolveArgs, so we have to require the path already being set
            if (string.IsNullOrWhiteSpace(item.Path))
            {
                throw new ArgumentException("Item must have a Path");
            }

            // If the resolver didn't specify this
            if (parent != null)
            {
                item.Parent = parent;
            }

            item.Id = libraryManager.GetNewItemId(item.Path, item.GetType());

            // If the resolver didn't specify this
            if (string.IsNullOrEmpty(item.DisplayMediaType))
            {
                item.DisplayMediaType = item.GetType().Name;
            }

            item.IsLocked = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 ||
                item.Parents.Any(i => i.IsLocked);

            // Make sure DateCreated and DateModified have values
            var fileInfo = directoryService.GetFile(item.Path);
            item.DateModified = fileSystem.GetLastWriteTimeUtc(fileInfo);
            SetDateCreated(item, fileSystem, fileInfo);

            EnsureName(item, fileInfo);
        }
开发者ID:Ceten,项目名称:MediaBrowser,代码行数:41,代码来源:ResolverHelper.cs

示例2: SetInitialItemValues

        /// <summary>
        /// Sets the initial item values.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="args">The args.</param>
        /// <param name="fileSystem">The file system.</param>
        public static void SetInitialItemValues(BaseItem item, ItemResolveArgs args, IFileSystem fileSystem)
        {
            // If the resolver didn't specify this
            if (string.IsNullOrEmpty(item.Path))
            {
                item.Path = args.Path;
            }

            // If the resolver didn't specify this
            if (args.Parent != null)
            {
                item.Parent = args.Parent;
            }

            item.Id = item.Path.GetMBId(item.GetType());

            // If the resolver didn't specify this
            if (string.IsNullOrEmpty(item.DisplayMediaType))
            {
                item.DisplayMediaType = item.GetType().Name;
            }

            // Make sure the item has a name
            EnsureName(item, args);

            item.DontFetchMeta = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 ||
                item.Parents.Any(i => i.IsLocked);

            // Make sure DateCreated and DateModified have values
            EntityResolutionHelper.EnsureDates(fileSystem, item, args, true);
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:37,代码来源:ResolverHelper.cs

示例3: GameItem

 public GameItem(BaseItem item, Texture2D image, Rectangle? source = null)
 {
     _item = item;
     _image = image;
     _sourceRectangle = source;
     _type = item.GetType();
 }
开发者ID:Sharparam,项目名称:DiseasedToast,代码行数:7,代码来源:GameItem.cs

示例4: SetInitialItemValues

        /// <summary>
        /// Sets the initial item values.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="args">The args.</param>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="libraryManager">The library manager.</param>
        public static void SetInitialItemValues(BaseItem item, ItemResolveArgs args, IFileSystem fileSystem, ILibraryManager libraryManager)
        {
            // If the resolver didn't specify this
            if (string.IsNullOrEmpty(item.Path))
            {
                item.Path = args.Path;
            }

            // If the resolver didn't specify this
            if (args.Parent != null)
            {
                item.Parent = args.Parent;
            }

            item.Id = libraryManager.GetNewItemId(item.Path, item.GetType());

            // Make sure the item has a name
            EnsureName(item, args.FileInfo);

            item.IsLocked = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 ||
                item.Parents.Any(i => i.IsLocked);

            // Make sure DateCreated and DateModified have values
            EnsureDates(fileSystem, item, args, true);
        }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:32,代码来源:ResolverHelper.cs

示例5: SaveItem

 /// <summary>
 /// Persists an item script so it'll be retained across scenes
 /// </summary>
 /// <param name="item">The item script to retain. (The original will be deleted when its gameobject is deleted)</param>
 public BaseItem SaveItem(BaseItem item)
 {
     var savedItem = itemScriptHolder.AddComponent(item.GetType()) as BaseItem;
     savedItem = savedItem.GetCopyOf(item);
     savedItem.inventoryTile = item.inventoryTile;
     return savedItem;
 }
开发者ID:DanStout,项目名称:FablesOfSol,代码行数:11,代码来源:GameManager.cs

示例6: GameItem

        public GameItem(BaseItem item, Texture2D texture, Rectangle? source)
        {
            baseItem = item;
            image = texture;
            sourceRectangle = source;

            type = item.GetType();
        }
开发者ID:brollins90,项目名称:eotd,代码行数:8,代码来源:GameItem.cs

示例7: AttachBasicFields


//.........这里部分代码省略.........
                dto.Path = item.Path;
            }

            dto.PremiereDate = item.PremiereDate;
            dto.ProductionYear = item.ProductionYear;

            if (fields.Contains(ItemFields.ProviderIds))
            {
                dto.ProviderIds = item.ProviderIds;
            }

            dto.RunTimeTicks = item.RunTimeTicks;

            if (fields.Contains(ItemFields.SortName))
            {
                dto.SortName = item.SortName;
            }

            if (fields.Contains(ItemFields.CustomRating))
            {
                dto.CustomRating = item.CustomRating;
            }

            if (fields.Contains(ItemFields.Taglines))
            {
                dto.Taglines = item.Taglines;
            }

            if (fields.Contains(ItemFields.RemoteTrailers))
            {
                dto.RemoteTrailers = item.RemoteTrailers;
            }

            dto.Type = item.GetType().Name;
            dto.CommunityRating = item.CommunityRating;

            if (item.IsFolder)
            {
                var folder = (Folder)item;

                if (fields.Contains(ItemFields.IndexOptions))
                {
                    dto.IndexOptions = folder.IndexByOptionStrings.ToArray();
                }
            }

            // Add audio info
            var audio = item as Audio;
            if (audio != null)
            {
                dto.Album = audio.Album;
                dto.AlbumArtist = audio.AlbumArtist;
                dto.Artists = new[] { audio.Artist };

                var albumParent = audio.FindParent<MusicAlbum>();

                if (albumParent != null)
                {
                    dto.AlbumId = GetClientItemId(albumParent);

                    var imagePath = albumParent.PrimaryImagePath;

                    if (!string.IsNullOrEmpty(imagePath))
                    {
                        dto.AlbumPrimaryImageTag = GetImageCacheTag(albumParent, ImageType.Primary, imagePath);
                    }
开发者ID:jordy1955,项目名称:MediaBrowser,代码行数:67,代码来源:DtoBuilder.cs

示例8: MigratePlayState

 private void MigratePlayState(BaseItem item)
 {
     Guid oldID = (item.GetType().FullName + item.Path).GetMD5();
     PlaybackStatus status = Kernel.Instance.ItemRepository.RetrievePlayState(oldID);
     if (status != null)
     {
         Logger.ReportInfo("Migrating playstate for: " + item.Name);
         status.Id = item.Id;
         Kernel.Instance.SavePlayState(item, status);
     }
 }
开发者ID:xantilas,项目名称:videobrowser,代码行数:11,代码来源:MainWindow.xaml.cs

示例9: GetBaseItemInfo

        /// <summary>
        /// Converts a BaseItem to a BaseItemInfo
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>BaseItemInfo.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        public static BaseItemInfo GetBaseItemInfo(BaseItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var info = new BaseItemInfo
            {
                Id = GetClientItemId(item),
                Name = item.Name,
                MediaType = item.MediaType,
                Type = item.GetType().Name,
                IsFolder = item.IsFolder,
                RunTimeTicks = item.RunTimeTicks
            };

            var imagePath = item.PrimaryImagePath;

            if (!string.IsNullOrEmpty(imagePath))
            {
                try
                {
                    info.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Primary, imagePath);
                }
                catch (IOException)
                {
                }
            }

            return info;
        }
开发者ID:jordy1955,项目名称:MediaBrowser,代码行数:38,代码来源:DtoBuilder.cs

示例10: AddChild

        /// <summary>
        /// Adds the child.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        /// <exception cref="System.InvalidOperationException">Unable to add  + item.Name</exception>
        public async Task AddChild(BaseItem item, CancellationToken cancellationToken)
        {
            item.Parent = this;

            if (item.Id == Guid.Empty)
            {
                item.Id = item.Path.GetMBId(item.GetType());
            }

            if (item.DateCreated == DateTime.MinValue)
            {
                item.DateCreated = DateTime.UtcNow;
            }
            if (item.DateModified == DateTime.MinValue)
            {
                item.DateModified = DateTime.UtcNow;
            }

            if (!_children.TryAdd(item.Id, item))
            {
                throw new InvalidOperationException("Unable to add " + item.Name);
            }

            await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);

            await ItemRepository.SaveChildren(Id, _children.Values.ToList().Select(i => i.Id), cancellationToken).ConfigureAwait(false);
        }
开发者ID:0sm0,项目名称:MediaBrowser,代码行数:34,代码来源:Folder.cs

示例11: ExecuteMetadataProviders

        /// <summary>
        /// Runs all metadata providers for an entity, and returns true or false indicating if at least one was refreshed and requires persistence
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
        /// <returns>Task{System.Boolean}.</returns>
        public async Task<ItemUpdateType?> ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false, bool allowSlowProviders = true)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            ItemUpdateType? result = null;

            cancellationToken.ThrowIfCancellationRequested();

            // Run the normal providers sequentially in order of priority
            foreach (var provider in MetadataProviders.Where(p => p.Supports(item)))
            {
                cancellationToken.ThrowIfCancellationRequested();

                // Skip if internet providers are currently disabled
                if (provider.RequiresInternet && !ConfigurationManager.Configuration.EnableInternetProviders)
                {
                    continue;
                }

                // Skip if is slow and we aren't allowing slow ones
                if (provider.IsSlow && !allowSlowProviders)
                {
                    continue;
                }

                // Skip if internet provider and this type is not allowed
                if (provider.RequiresInternet && ConfigurationManager.Configuration.EnableInternetProviders && ConfigurationManager.Configuration.InternetProviderExcludeTypes.Contains(item.GetType().Name, StringComparer.OrdinalIgnoreCase))
                {
                    continue;
                }

                // Put this check below the await because the needs refresh of the next tier of providers may depend on the previous ones running
                //  This is the case for the fan art provider which depends on the movie and tv providers having run before them
                if (provider.RequiresInternet && item.DontFetchMeta)
                {
                    continue;
                }

                try
                {
                    if (!force && !provider.NeedsRefresh(item))
                    {
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error("Error determining NeedsRefresh for {0}", ex, item.Path);
                }

                var updateType = await FetchAsync(provider, item, force, cancellationToken).ConfigureAwait(false);

                if (updateType.HasValue)
                {
                    if (result.HasValue)
                    {
                        result = result.Value | updateType.Value;
                    }
                    else
                    {
                        result = updateType;
                    }
                }
            }

            return result;
        }
开发者ID:squibber46,项目名称:MediaBrowser,代码行数:78,代码来源:ProviderManager.cs

示例12: GetAvailableRemoteImages

        /// <summary>
        /// Gets the available remote images.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="providerName">Name of the provider.</param>
        /// <param name="type">The type.</param>
        /// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
        public async Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(BaseItem item, CancellationToken cancellationToken, string providerName = null, ImageType? type = null)
        {
            var providers = GetImageProviders(item);

            if (!string.IsNullOrEmpty(providerName))
            {
                providers = providers.Where(i => string.Equals(i.Name, providerName, StringComparison.OrdinalIgnoreCase));
            }

            var preferredLanguage = ConfigurationManager.Configuration.PreferredMetadataLanguage;

            var tasks = providers.Select(i => Task.Run(async () =>
            {
                try
                {
                    if (type.HasValue)
                    {
                        var result = await i.GetImages(item, type.Value, cancellationToken).ConfigureAwait(false);

                        return FilterImages(result, preferredLanguage);
                    }
                    else
                    {
                        var result = await i.GetAllImages(item, cancellationToken).ConfigureAwait(false);
                        return FilterImages(result, preferredLanguage);
                    }
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("{0} failed in GetImages for type {1}", ex, i.GetType().Name, item.GetType().Name);
                    return new List<RemoteImageInfo>();
                }

            }, cancellationToken));

            var results = await Task.WhenAll(tasks).ConfigureAwait(false);

            return results.SelectMany(i => i);
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:47,代码来源:ProviderManager.cs

示例13: GetImageProviders

 /// <summary>
 /// Gets the supported image providers.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>IEnumerable{IImageProvider}.</returns>
 public IEnumerable<IImageProvider> GetImageProviders(BaseItem item)
 {
     return ImageProviders.Where(i =>
     {
         try
         {
             return i.Supports(item);
         }
         catch (Exception ex)
         {
             _logger.ErrorException("{0} failed in Supports for type {1}", ex, i.GetType().Name, item.GetType().Name);
             return false;
         }
     });
 }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:20,代码来源:ProviderManager.cs

示例14: AddChild

        /// <summary>
        /// Adds the child.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        /// <exception cref="System.InvalidOperationException">Unable to add  + item.Name</exception>
        public async Task AddChild(BaseItem item, CancellationToken cancellationToken)
        {
            item.Parent = this;

            if (item.Id == Guid.Empty)
            {
                item.Id = LibraryManager.GetNewItemId(item.Path, item.GetType());
            }

            if (ActualChildren.Any(i => i.Id == item.Id))
            {
                throw new ArgumentException(string.Format("A child with the Id {0} already exists.", item.Id));
            }

            if (item.DateCreated == DateTime.MinValue)
            {
                item.DateCreated = DateTime.UtcNow;
            }
            if (item.DateModified == DateTime.MinValue)
            {
                item.DateModified = DateTime.UtcNow;
            }

            AddChildInternal(item);

            await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);

            await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
        }
开发者ID:jabbera,项目名称:MediaBrowser,代码行数:36,代码来源:Folder.cs

示例15: ApplyAdditionalFilters

		/// <summary> Applies the additional filters. </summary>
		/// <param name="request"> The request. </param>
		/// <param name="i"> Zero-based index of the. </param>
		/// <param name="user"> The user. </param>
		/// <param name="isPreFiltered"> true if this object is pre filtered. </param>
		/// <param name="libraryManager"> Manager for library. </param>
		/// <returns> true if it succeeds, false if it fails. </returns>
        private bool ApplyAdditionalFilters(BaseReportRequest request, BaseItem i, User user, bool isPreFiltered, ILibraryManager libraryManager)
		{
			var video = i as Video;

			if (!isPreFiltered)
			{
				var mediaTypes = request.GetMediaTypes();
				if (mediaTypes.Length > 0)
				{
					if (!(!string.IsNullOrEmpty(i.MediaType) && mediaTypes.Contains(i.MediaType, StringComparer.OrdinalIgnoreCase)))
					{
						return false;
					}
				}

				if (request.IsPlayed.HasValue)
				{
					var val = request.IsPlayed.Value;
					if (i.IsPlayed(user) != val)
					{
						return false;
					}
				}

				// Exclude item types
				var excluteItemTypes = request.GetExcludeItemTypes();
				if (excluteItemTypes.Length > 0 && excluteItemTypes.Contains(i.GetType().Name, StringComparer.OrdinalIgnoreCase))
				{
					return false;
				}

				// Include item types
				var includeItemTypes = request.GetIncludeItemTypes();
				if (includeItemTypes.Length > 0 && !includeItemTypes.Contains(i.GetType().Name, StringComparer.OrdinalIgnoreCase))
				{
					return false;
				}

				if (request.IsInBoxSet.HasValue)
				{
					var val = request.IsInBoxSet.Value;
					if (i.Parents.OfType<BoxSet>().Any() != val)
					{
						return false;
					}
				}

				// Filter by Video3DFormat
				if (request.Is3D.HasValue)
				{
					var val = request.Is3D.Value;

					if (video == null || val != video.Video3DFormat.HasValue)
					{
						return false;
					}
				}

				if (request.IsHD.HasValue)
				{
					var val = request.IsHD.Value;

					if (video == null || val != video.IsHD)
					{
						return false;
					}
				}

				if (request.IsUnidentified.HasValue)
				{
					var val = request.IsUnidentified.Value;
					if (i.IsUnidentified != val)
					{
						return false;
					}
				}

				if (request.IsLocked.HasValue)
				{
					var val = request.IsLocked.Value;
					if (i.IsLocked != val)
					{
						return false;
					}
				}

				if (request.HasOverview.HasValue)
				{
					var filterValue = request.HasOverview.Value;

					var hasValue = !string.IsNullOrEmpty(i.Overview);

					if (hasValue != filterValue)
//.........这里部分代码省略.........
开发者ID:redteamcpu,项目名称:Emby,代码行数:101,代码来源:ReportsService.cs


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