/// <summary> /// Adds a named item to the current queue collection /// </summary> /// <param name="value">The item to add</param> /// <param name="name">The name of the item</param> public void AddItemToCacheQueue <TItemType>(TItemType value, string name) { // Check if the item is valid QueueCollectionHelpers.CheckItem(value, mCycle, Length, mQueueCapacity); // Add item and it's name to queue collection mCollection.Add($"/{ name }:{ value }@{ value.GetType().Name }"); }
public void AddCollectionToCacheQueue <TQueueCollectionType>(IEnumerable <TQueueCollectionType> collection, string name) { // Check if collection is valid QueueCollectionHelpers.CheckItem(collection, mCycle, Length, mQueueCapacity); // Start cache string string cacheCollection = $"/${ name }"; Parallel.ForEach(collection, (data) => { // Add all items in collection to cached collection cacheCollection += $"{ data },"; }); // Write collection item type cacheCollection += $"@{ typeof(TQueueCollectionType).Name }"; // Add collection to queue collection mCollection.Add(cacheCollection); }
/// <summary> /// Adds a named object to the current queue collection /// </summary> /// <param name="obj">The object to add</param> /// <param name="name">The name of the object</param> public void AddObjectToCacheQueue <TObjType>(TObjType obj, string name) where TObjType : class { // Check if object is valid QueueCollectionHelpers.CheckItem(obj, mCycle, Length, mQueueCapacity); // Start cache string string cacheObject = $"/*{ name }:"; Parallel.ForEach(typeof(TObjType).GetProperties(), (property) => { // Add all property names and it's values to cached object cacheObject += $"{ property.Name }={ property.GetValue(obj) },"; }); // Write object class type cacheObject += $"@{ obj.GetType().Name }"; // Add object to queue collection mCollection.Add(cacheObject); }