public XmlFormatSerializationDataItem(IFormatDataItem formatDataItem) { Debug.Assert(formatDataItem != null, $"Can't init {nameof(XmlFormatSerializationDataItem)} ctor with null"); Date = formatDataItem.Date; BrandName = formatDataItem.BrandName; Price = formatDataItem.Price; }
public BinaryFormatSerializationDataItem(IFormatDataItem formatDataItem) { Debug.Assert(formatDataItem != null, $"Can't init binary {nameof(BinaryFormatSerializationDataItem)} constructor with null"); Day = (short)formatDataItem.Day; Month = (short)formatDataItem.Month; Year = formatDataItem.Year; BrandName = formatDataItem.BrandName; Price = formatDataItem.Price; }
/// <summary> /// Adds the data item. By default, item is cloned before adding to prevent entwined dependencies. /// </summary> /// <param name="dataItem"></param> /// <param name="cloneInputDataItem">If set to true (by default), item will be cloned before adding to prevent entwined dependencies.</param> /// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.InvalidOperationException"></exception> public void AddDataItem(IFormatDataItem dataItem, bool cloneInputDataItem = true) { CheckCacheException(); if (dataItem == null) { throw new ArgumentNullException($"{nameof(IFormatDataItem)} instance is null and can't be added"); } if (_dataCollection.Contains(dataItem) && !cloneInputDataItem) { throw new InvalidOperationException($"{nameof(IFormatDataItem)} instance is already in {nameof(Data)} collection. Please, use clone option to make a copy if that was your intention."); } var itemToAdd = cloneInputDataItem ? (dataItem.Clone() as IFormatDataItem) : dataItem; _dataCollection.Add(itemToAdd); }
public bool RemoveDataItem(IFormatDataItem dataItem) { CheckCacheException(); bool result = false; if (dataItem == null) { Console.WriteLine("Can't remove null-valued data item"); } else if (!_dataCollection.Contains(dataItem)) { Console.WriteLine("Can't remove data item that's not in the collection"); } else { _dataCollection.Remove(dataItem); result = true; } return(result); }