E:\Devel\PlayniteDiagTool\PlayniteDiagTool\bin\Debug\temp\PlayniteSDK\Database\IItemCollection.cs e:\Devel\Playnite\source\PlayniteSDK\Database\IItemCollection.cs
using Playnite.SDK.Models; using Playnite.SDK.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
   
namespace Playnite.SDK namespace Playnite.SDK
{ {
   /// <summary>    /// <summary>
   /// Represents event occuring when database are permanetly updated in database.    /// Represents event occuring when database are permanetly updated in database.
   /// </summary>    /// </summary>
   /// <typeparam name="TItem"></typeparam>    /// <typeparam name="TItem"></typeparam>
   public class ItemUpdateEvent<TItem> where TItem : DatabaseObject    public class ItemUpdateEvent<TItem> where TItem : DatabaseObject
   {    {
       /// <summary>        /// <summary>
       /// Gets or sets old item state.        /// Gets or sets old item state.
       /// </summary>        /// </summary>
       public TItem OldData        public TItem OldData
       {        {
           get; set;            get; set;
       }        }
   
       /// <summary>        /// <summary>
       /// Gets or sets new item state.        /// Gets or sets new item state.
       /// </summary>        /// </summary>
       public TItem NewData        public TItem NewData
       {        {
           get; set;            get; set;
       }        }
   
       /// <summary>        /// <summary>
       /// Creates new instance of ItemUpdateEvent.        /// Creates new instance of ItemUpdateEvent.
       /// </summary>        /// </summary>
       /// <param name="oldData">Old state.</param>        /// <param name="oldData">Old state.</param>
       /// <param name="newData">New state.</param>        /// <param name="newData">New state.</param>
       public ItemUpdateEvent(TItem oldData, TItem newData)        public ItemUpdateEvent(TItem oldData, TItem newData)
       {        {
           OldData = oldData;            OldData = oldData;
           NewData = newData;            NewData = newData;
       }        }
   }    }
   
   /// <summary>    /// <summary>
   /// Represents arguments for collection update events.    /// Represents arguments for collection update events.
   /// </summary>    /// </summary>
   /// <typeparam name="TItem"></typeparam>    /// <typeparam name="TItem"></typeparam>
   public class ItemUpdatedEventArgs<TItem> : EventArgs where TItem : DatabaseObject    public class ItemUpdatedEventArgs<TItem> : EventArgs where TItem : DatabaseObject
   {    {
       /// <summary>        /// <summary>
       /// Gets or sets list of update events.        /// Gets or sets list of update events.
       /// </summary>        /// </summary>
       public List<ItemUpdateEvent<TItem>> UpdatedItems        public List<ItemUpdateEvent<TItem>> UpdatedItems
       {        {
           get; set;            get; set;
       }        }
   
       /// <summary>        /// <summary>
       /// Creates new instance of ItemUpdatedEventArgs.        /// Creates new instance of ItemUpdatedEventArgs.
       /// </summary>        /// </summary>
       /// <param name="oldData">Old item state.</param>        /// <param name="oldData">Old item state.</param>
       /// <param name="newData">New item state.</param>        /// <param name="newData">New item state.</param>
       public ItemUpdatedEventArgs(TItem oldData, TItem newData)        public ItemUpdatedEventArgs(TItem oldData, TItem newData)
       {        {
           UpdatedItems = new List<ItemUpdateEvent<TItem>>() { new ItemUpdateEvent<TItem>(oldData, newData) };            UpdatedItems = new List<ItemUpdateEvent<TItem>>() { new ItemUpdateEvent<TItem>(oldData, newData) };
       }        }
   
       /// <summary>        /// <summary>
       /// Creates new instance of ItemUpdatedEventArgs.        /// Creates new instance of ItemUpdatedEventArgs.
       /// </summary>        /// </summary>
       /// <param name="updatedItems">Update events list.</param>        /// <param name="updatedItems">Update events list.</param>
       public ItemUpdatedEventArgs(IEnumerable<ItemUpdateEvent<TItem>> updatedItems)        public ItemUpdatedEventArgs(IEnumerable<ItemUpdateEvent<TItem>> updatedItems)
       {        {
           UpdatedItems = updatedItems.ToList();            UpdatedItems = updatedItems.ToList();
       }        }
   }    }
   
   /// <summary>    /// <summary>
   /// Represents arguments for collection change events.    /// Represents arguments for collection change events.
   /// </summary>    /// </summary>
   /// <typeparam name="TItem"></typeparam>    /// <typeparam name="TItem"></typeparam>
   public class ItemCollectionChangedEventArgs<TItem> : EventArgs where TItem : DatabaseObject    public class ItemCollectionChangedEventArgs<TItem> : EventArgs where TItem : DatabaseObject
   {    {
       /// <summary>        /// <summary>
       /// Gets or sets list of added items.        /// Gets or sets list of added items.
       /// </summary>        /// </summary>
       public List<TItem> AddedItems        public List<TItem> AddedItems
       {        {
           get; set;            get; set;
       }        }
   
       /// <summary>        /// <summary>
       /// Gets or sets list of removed items.        /// Gets or sets list of removed items.
       /// </summary>        /// </summary>
       public List<TItem> RemovedItems        public List<TItem> RemovedItems
       {        {
           get; set;            get; set;
       }        }
   
       /// <summary>        /// <summary>
       /// Creates new instance of ItemCollectionChangedEventArgs.        /// Creates new instance of ItemCollectionChangedEventArgs.
       /// </summary>        /// </summary>
       /// <param name="addedItems">List of added items.</param>        /// <param name="addedItems">List of added items.</param>
       /// <param name="removedItems">List of removed items.</param>        /// <param name="removedItems">List of removed items.</param>
       public ItemCollectionChangedEventArgs(List<TItem> addedItems, List<TItem> removedItems)        public ItemCollectionChangedEventArgs(List<TItem> addedItems, List<TItem> removedItems)
       {        {
           AddedItems = addedItems;            AddedItems = addedItems;
           RemovedItems = removedItems;            RemovedItems = removedItems;
       }        }
   }    }
   
   /// <summary>    /// <summary>
   /// Describes collection of items for game database.    /// Describes collection of items for game database.
   /// </summary>    /// </summary>
.    public interface IItemCollection     public interface IItemCollection : IDisposable 
   {    {
       /// <summary>        /// <summary>
       /// Gets item collection type.        /// Gets item collection type.
       /// </summary>        /// </summary>
       GameDatabaseCollection CollectionType { get; }        GameDatabaseCollection CollectionType { get; }
   
       /// <summary>        /// <summary>
       /// Check if an item is in the collection.        /// Check if an item is in the collection.
       /// </summary>        /// </summary>
       /// <param name="id"></param>        /// <param name="id"></param>
       /// <returns></returns>        /// <returns></returns>
       bool ContainsItem(Guid id);        bool ContainsItem(Guid id);
   }    }
   
   /// <summary>    /// <summary>
   /// Describes collection of items for game database.    /// Describes collection of items for game database.
   /// </summary>    /// </summary>
   /// <typeparam name="TItem"></typeparam>    /// <typeparam name="TItem"></typeparam>
   public interface IItemCollection<TItem> : IItemCollection, ICollection<TItem> where TItem : DatabaseObject    public interface IItemCollection<TItem> : IItemCollection, ICollection<TItem> where TItem : DatabaseObject
   {    {
       /// <summary>        /// <summary>
       /// Gets or sets item from collection.        /// Gets or sets item from collection.
       /// </summary>        /// </summary>
       /// <param name="id">Id of an item.</param>        /// <param name="id">Id of an item.</param>
       /// <returns><c>null</c> if no item is found otherwise item represents by specified id.</returns>        /// <returns><c>null</c> if no item is found otherwise item represents by specified id.</returns>
       TItem this[Guid id] { get; set; }        TItem this[Guid id] { get; set; }
   
       /// <summary>        /// <summary>
       /// Gets item from collection.        /// Gets item from collection.
       /// </summary>        /// </summary>
       /// <param name="id">Id of an item.</param>        /// <param name="id">Id of an item.</param>
       /// <returns><c>null</c> if no item is found otherwise item represents by specified id.</returns>        /// <returns><c>null</c> if no item is found otherwise item represents by specified id.</returns>
       TItem Get(Guid id);        TItem Get(Guid id);
   
       /// <summary>        /// <summary>
       /// Gets items from collection.        /// Gets items from collection.
       /// </summary>        /// </summary>
       /// <param name="ids">Id of items.</param>        /// <param name="ids">Id of items.</param>
       /// <returns>List of items from collection.</returns>        /// <returns>List of items from collection.</returns>
       List<TItem> Get(IList<Guid> ids);        List<TItem> Get(IList<Guid> ids);
   
       /// <summary>        /// <summary>
       /// Adds new item into collection.        /// Adds new item into collection.
       /// </summary>        /// </summary>
       /// <param name="itemName">Name of new item.</param>        /// <param name="itemName">Name of new item.</param>
       /// <returns>Newly added item or existing item if one is present with the same name.</returns>        /// <returns>Newly added item or existing item if one is present with the same name.</returns>
       TItem Add(string itemName);        TItem Add(string itemName);
   
       /// <summary>        /// <summary>
       /// Adds new item into collection.        /// Adds new item into collection.
       /// </summary>        /// </summary>
       /// <param name="itemName">Name of new item.</param>        /// <param name="itemName">Name of new item.</param>
       /// <param name="existingComparer">Method to detect existing item from database compared to new item.</param>        /// <param name="existingComparer">Method to detect existing item from database compared to new item.</param>
       /// <returns>Newly added item or existing item if one is present with the same name.</returns>        /// <returns>Newly added item or existing item if one is present with the same name.</returns>
       TItem Add(string itemName, Func<TItem, string, bool> existingComparer);        TItem Add(string itemName, Func<TItem, string, bool> existingComparer);
   
       /// <summary>        /// <summary>
       /// Adds new items into collection.        /// Adds new items into collection.
       /// </summary>        /// </summary>
       /// <param name="items">Names of items to be added.</param>        /// <param name="items">Names of items to be added.</param>
       /// <returns>Newly added items or existing items if there are some present with the same names.</returns>        /// <returns>Newly added items or existing items if there are some present with the same names.</returns>
       IEnumerable<TItem> Add(List<string> items);        IEnumerable<TItem> Add(List<string> items);
.   
         /// <summary>
         ///
         /// </summary>
         /// <param name="property"></param>
         /// <returns></returns>
         TItem Add(MetadataProperty property);
   
         /// <summary>
         ///
         /// </summary>
         /// <param name="properties"></param>
         /// <returns></returns>
         IEnumerable<TItem> Add(IEnumerable<MetadataProperty> properties);
   
       /// <summary>        /// <summary>
       /// Adds new items into collection.        /// Adds new items into collection.
       /// </summary>        /// </summary>
       /// <param name="items">Names of items to be added.</param>        /// <param name="items">Names of items to be added.</param>
       /// <param name="existingComparer">Method to detect existing item from database compared to new item.</param>        /// <param name="existingComparer">Method to detect existing item from database compared to new item.</param>
       /// <returns></returns>        /// <returns></returns>
       IEnumerable<TItem> Add(List<string> items, Func<TItem, string, bool> existingComparer);        IEnumerable<TItem> Add(List<string> items, Func<TItem, string, bool> existingComparer);
   
       /// <summary>        /// <summary>
       /// Adds itemss to into collection.        /// Adds itemss to into collection.
       /// </summary>        /// </summary>
       /// <param name="items">Item to be added.</param>        /// <param name="items">Item to be added.</param>
       void Add(IEnumerable<TItem> items);        void Add(IEnumerable<TItem> items);
   
       /// <summary>        /// <summary>
       /// Removes item from collection.        /// Removes item from collection.
       /// </summary>        /// </summary>
       /// <param name="id">Id of an item to be removed.</param>        /// <param name="id">Id of an item to be removed.</param>
       /// <returns></returns>        /// <returns></returns>
       bool Remove(Guid id);        bool Remove(Guid id);
   
       /// <summary>        /// <summary>
       /// Removes items from collection.        /// Removes items from collection.
       /// </summary>        /// </summary>
       /// <param name="items">List of items to be removed.</param>        /// <param name="items">List of items to be removed.</param>
       /// <returns></returns>        /// <returns></returns>
       bool Remove(IEnumerable<TItem> items);        bool Remove(IEnumerable<TItem> items);
   
       /// <summary>        /// <summary>
       /// Updates state of item in collection.        /// Updates state of item in collection.
       /// </summary>        /// </summary>
       /// <param name="item">New state of an object.</param>        /// <param name="item">New state of an object.</param>
       void Update(TItem item);        void Update(TItem item);
   
       /// <summary>        /// <summary>
       /// Updates states of items in collection.        /// Updates states of items in collection.
       /// </summary>        /// </summary>
       /// <param name="items">New states of items.</param>        /// <param name="items">New states of items.</param>
       void Update(IEnumerable<TItem> items);        void Update(IEnumerable<TItem> items);
   
       /// <summary>        /// <summary>
       /// Sets collection into buffered update state.        /// Sets collection into buffered update state.
       /// </summary>        /// </summary>
       void BeginBufferUpdate();        void BeginBufferUpdate();
   
       /// <summary>        /// <summary>
       /// Sets collection from buffered update state.        /// Sets collection from buffered update state.
       /// </summary>        /// </summary>
       void EndBufferUpdate();        void EndBufferUpdate();
   
       /// <summary>        /// <summary>
       /// Gets clone of an collection.        /// Gets clone of an collection.
       /// </summary>        /// </summary>
       /// <returns></returns>        /// <returns></returns>
       IEnumerable<TItem> GetClone();        IEnumerable<TItem> GetClone();
   
       /// <summary>        /// <summary>
       /// Occurs when items are added or removed.        /// Occurs when items are added or removed.
       /// </summary>        /// </summary>
       event EventHandler<ItemCollectionChangedEventArgs<TItem>> ItemCollectionChanged;        event EventHandler<ItemCollectionChangedEventArgs<TItem>> ItemCollectionChanged;
   
       /// <summary>        /// <summary>
       /// Occurs when items are updated.        /// Occurs when items are updated.
       /// </summary>        /// </summary>
       event EventHandler<ItemUpdatedEventArgs<TItem>> ItemUpdated;        event EventHandler<ItemUpdatedEventArgs<TItem>> ItemUpdated;
   }    }
} }