/// <summary>Adds a specific <see cref="ExcelPoolItem"/> object into the <see cref="ExcelPool"/>. /// </summary> /// <param name="tryCreateExcelPoolItem">A delegate for creating a <see cref="ExcelPoolItem"/> object via <paramref name="inputExcelDataQueries"/>.</param> /// <param name="inputExcelDataQueries">A collection of <see cref="IExcelDataQuery"/> objects used as input to construct a <see cref="ExcelPoolItem"/> object.</param> /// <returns>A <see cref="System.String"/> representation which contains a error message or the name of the object to insert together with some time stamp.</returns> public static string InsertObject(TryCreateExcelPoolItem tryCreateExcelPoolItem, IIdentifierStringDictionary <IExcelDataQuery> inputExcelDataQueries) { ExcelPoolItem value; string errorMessage; if (tryCreateExcelPoolItem(inputExcelDataQueries, out value, out errorMessage) == false) { return(errorMessage); } if (InsertObject(value) == ItemAddedState.Rejected) { return("Error! Object rejected, i.e. not added to the [Excel] pool."); } return(value.GetObjectNameWithTimeStamp()); }
/// <summary>Initializes a new instance of the <see cref="ExcelPoolItemCreator"/> struct. /// </summary> /// <param name="excelPoolItemType">The type of the object to create in its <see cref="ExcelPoolItemType"/> representation.</param> /// <param name="excelPoolItemCreatingFunction">The creating function.</param> /// <exception cref="ArgumentNullException">Thrown, if one of the arguments is <c>null</c>.</exception> /// <remarks>Use the <see cref="ExcelPoolItemCreator.Initialize"/> event to store the <see cref="ExcelPoolItemCreator"/> instance.</remarks> public ExcelPoolItemCreator(ExcelPoolItemType excelPoolItemType, TryCreateExcelPoolItem excelPoolItemCreatingFunction) { if (excelPoolItemType == null) { throw new ArgumentNullException("excelPoolItemType"); } ObjectType = excelPoolItemType; if (excelPoolItemCreatingFunction == null) { throw new ArgumentNullException("excelPoolItemCreatingFunction"); } CreatingFunction = (IIdentifierStringDictionary <IExcelDataQuery> excelDataQueries, out IEnumerable <ExcelPoolItem> values, out string errorMessage) => { ExcelPoolItem value; if (excelPoolItemCreatingFunction(excelDataQueries, out value, out errorMessage) == false) { values = null; return(false); } values = GetAsEnumerable(value); return(true); }; }