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


C# BaseItem类代码示例

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


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

示例1: Save

        /// <summary>
        /// Saves the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        public void Save(BaseItem item, CancellationToken cancellationToken)
        {
            var builder = new StringBuilder();

            builder.Append("<Item>");

            XmlSaverHelpers.AddCommonNodes(item, builder);

            if (item.ProductionLocations.Count > 0)
            {
                builder.Append("<PlaceOfBirth>" + SecurityElement.Escape(item.ProductionLocations[0]) + "</PlaceOfBirth>");
            }

            builder.Append("</Item>");

            var xmlFilePath = GetSavePath(item);

            XmlSaverHelpers.Save(builder, xmlFilePath, new[]
                {
                    "PlaceOfBirth"
                });

            // Set last refreshed so that the provider doesn't trigger after the file save
            PersonProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow);
        }
开发者ID:0sm0,项目名称:MediaBrowser,代码行数:31,代码来源:PersonXmlSaver.cs

示例2: 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());

            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:jrags56,项目名称:MediaBrowser,代码行数:35,代码来源:ResolverHelper.cs

示例3: FetchAsync

        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            var releaseId = item.GetProviderId(MetadataProviders.Musicbrainz);
            var releaseGroupId = item.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);

            if (string.IsNullOrEmpty(releaseId))
            {
                var result = await GetReleaseResult((MusicAlbum)item, cancellationToken).ConfigureAwait(false);

                if (!string.IsNullOrEmpty(result.ReleaseId))
                {
                    releaseId = result.ReleaseId;
                    item.SetProviderId(MetadataProviders.Musicbrainz, releaseId);
                }

                if (!string.IsNullOrEmpty(result.ReleaseGroupId))
                {
                    releaseGroupId = result.ReleaseGroupId;
                    item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, releaseGroupId);
                }
            }

            // If we have a release Id but not a release group Id...
            if (!string.IsNullOrEmpty(releaseId) && string.IsNullOrEmpty(releaseGroupId))
            {
                releaseGroupId = await GetReleaseGroupId(releaseId, cancellationToken).ConfigureAwait(false);

                item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, releaseGroupId);
            }

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
            return true;
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:33,代码来源:MusicBrainzAlbumProvider.cs

示例4: IsEnabledFor

        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            if (!(item is Folder))
            {
                return false;
            }

            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
            
            // If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
            if ((_config.Configuration.SaveLocalMeta && wasMetadataDownloaded) || wasMetadataEdited)
            {
                if (!(item is Series) && !(item is BoxSet) && !(item is MusicArtist) && !(item is MusicAlbum) &&
                    !(item is Season))
                {
                    return true;
                }
            }

            // If new metadata has been downloaded or metadata was manually edited, proceed
            if (wasMetadataDownloaded || wasMetadataEdited)
            {
                if (item is AggregateFolder || item is UserRootFolder || item is CollectionFolder)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:0sm0,项目名称:MediaBrowser,代码行数:37,代码来源:FolderXmlSaver.cs

示例5: Fetch

        /// <summary>
        /// Fetches the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        private async Task<bool> Fetch(BaseItem item, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            
            var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "movie.xml"));

            if (metadataFile != null)
            {
                var path = metadataFile.FullName;
                var boxset = item as BoxSet;

                await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

                try
                {
                    if (boxset != null)
                    {
                        new BaseItemXmlParser<BoxSet>(Logger).Fetch(boxset, path, cancellationToken);
                    }
                    else
                    {
                        new BaseItemXmlParser<Movie>(Logger).Fetch((Movie)item, path, cancellationToken);
                    }
                }
                finally
                {
                    XmlParsingResourcePool.Release();
                }

                SetLastRefreshed(item, DateTime.UtcNow);
                return true;
            }

            return false;
        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:41,代码来源:MovieProviderFromXml.cs

示例6: BaseEquipment

 public BaseEquipment(BaseItem item)
     : base(item)
 {
     subType = ((BaseEquipment)item).subType;
     Stats = new EquipmentStatCollection();
     Stats.AddStat<LinkableStat>(StatType.ARMOR, item.Stats.GetStat(StatType.ARMOR).BaseValue);
 }
开发者ID:RAWeber,项目名称:Unity,代码行数:7,代码来源:BaseEquipment.cs

示例7: Assign

 internal override void Assign(BaseItem baseItem ) { 
     base.Assign(baseItem);
     folder = (Folder)baseItem;
     folderChildren.Assign(this, FireChildrenChangedEvents);
     folder.QuickListChanged += QuickListChanged;
     folder.UnwatchedCountChanged += AdjustUnwatched;
 }
开发者ID:neil18,项目名称:MediaBrowser.Classic,代码行数:7,代码来源:FolderModel.cs

示例8: Start

 // Use this for initialization
 void Start()
 {
     Physics.IgnoreCollision(GameControl.player.GetComponent<Collider>(), this.GetComponent<Collider>());
     try
     {
         switch (ItemDatabase.itemDatabase[itemName].Type)
         {
             case BaseItem.ItemType.WEAPON:
                 item = new BaseWeapon((BaseWeapon)ItemDatabase.itemDatabase[itemName]);
                 break;
             case BaseItem.ItemType.EQUIPMENT:
                 item = new BaseEquipment(ItemDatabase.itemDatabase[itemName]);
                 break;
             case BaseItem.ItemType.RELIC:
                 item = new BaseRelic(ItemDatabase.itemDatabase[itemName]);
                 for (int i = 0; i < UnityEngine.Random.Range(1, 3); i++)
                 {
                     int randStat = UnityEngine.Random.Range((int)StatType.STRENGTH, (int)StatType.DEFENSE+1);
                     item.Stats.AddStat<ModifiableStat>((StatType)randStat, UnityEngine.Random.Range(1, 11));
                 }
                 break;
             case BaseItem.ItemType.CONSUMABLE:
                 item = new BaseConsumable(ItemDatabase.itemDatabase[itemName]);
                 break;
         }
     }
     catch (Exception)
     {
         Debug.Log("No item of name "+itemName+" within itemDatabase");
     }
 }
开发者ID:RAWeber,项目名称:Unity,代码行数:32,代码来源:GameItem.cs

示例9: FetchAsync

        /// <summary>
        /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var path = MovieXmlSaver.GetMovieSavePath(item);

            if (File.Exists(path))
            {
                await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

                try
                {
                    var video = (Video)item;

                    await new MovieXmlParser(Logger, _itemRepo).FetchAsync(video, path, cancellationToken).ConfigureAwait(false);
                }
                finally
                {
                    XmlParsingResourcePool.Release();
                }
            }

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);

            return true;
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:33,代码来源:MovieProviderFromXml.cs

示例10: FindId

        /// <summary>
        /// Finds the id.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.String}.</returns>
        private async Task<string> FindId(BaseItem item, CancellationToken cancellationToken)
        {
            if (item is Artist)
            {
                // Since MusicArtists are refreshed first, try to find it from one of them
                var id = FindIdFromMusicArtistEntity(item);

                if (!string.IsNullOrEmpty(id))
                {
                    return id;
                }
            }

            try
            {
                // If we don't get anything, go directly to music brainz
                return await FindIdFromMusicBrainz(item, cancellationToken).ConfigureAwait(false);
            }
            catch (HttpException e)
            {
                if (e.StatusCode.HasValue && e.StatusCode.Value == HttpStatusCode.BadRequest)
                {
                    // They didn't like a character in the name. Handle the exception so that the provider doesn't keep retrying over and over
                    return null;
                }

                throw;
            }
        }
开发者ID:Jon-theHTPC,项目名称:MediaBrowser,代码行数:35,代码来源:LastfmArtistProvider.cs

示例11: GetValue

        private string GetValue(BaseItem item)
        {
            Series series = null;

            var season = item as Season;

            if (season != null)
            {
                series = season.Series;
            }

            var episode = item as Episode;

            if (episode != null)
            {
                series = episode.Series;
            }

            if (series == null)
            {
                series = item as Series;
            }

            return series != null ? series.SortName : null;
        }
开发者ID:paul-777,项目名称:Emby,代码行数:25,代码来源:SeriesSortNameComparer.cs

示例12: GetFileSystemStamp

        protected override Guid GetFileSystemStamp(BaseItem item)
        {
            var location = GetLocation(item);

            try
            {
                var files = new DirectoryInfo(location)
                    .EnumerateFiles("*", SearchOption.TopDirectoryOnly)
                    .Where(i =>
                    {
                        var ext = i.Extension;

                        return !string.IsNullOrEmpty(ext) &&
                            BaseItem.SupportedImageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
                    })
                    .ToList();

                return GetFileSystemStamp(files);
            }
            catch (DirectoryNotFoundException)
            {
                // User doesn't have the folder. No need to log or blow up

                return Guid.Empty;
            }
        }
开发者ID:Jon-theHTPC,项目名称:MediaBrowser,代码行数:26,代码来源:ImagesByNameProvider.cs

示例13: FetchAsync

        /// <summary>
        /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="providerInfo">The provider information.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));

            if (metadataFile != null)
            {
                var path = metadataFile.FullName;

                await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

                try
                {
                    new BaseItemXmlParser<Folder>(Logger).Fetch((Folder)item, path, cancellationToken);
                }
                finally
                {
                    XmlParsingResourcePool.Release();
                }
            }

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
            return true;
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:33,代码来源:FolderProviderFromXml.cs

示例14: DeleteItem

 public static Task DeleteItem(this ILibraryManager manager, BaseItem item)
 {
     return manager.DeleteItem(item, new DeleteOptions
     {
         DeleteFileLocation = true
     });
 }
开发者ID:rezafouladian,项目名称:Emby,代码行数:7,代码来源:LibraryManagerExtensions.cs

示例15: AssignItem

 public void AssignItem(BaseItem item)
 {
     ItemScript = item;
     spriteImage.sprite = ItemScript.inventoryTile;
     UpdateQuantity(item.Quantity);
     ItemScript.onQuantityChanged += ItemScript_onQuantityChanged;
 }
开发者ID:DanStout,项目名称:FablesOfSol,代码行数:7,代码来源:InventoryButton.cs


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