Пример #1
0
        /// <summary>
        /// Is invoked when an instance of <see cref="TdilUnitWriter"/> is disposed that has being created by calling
        /// <see cref="CreateUnit(string)"/>.
        /// </summary>
        /// <param name="sender">Event dispatcher</param>
        /// <param name="eventArgs">Event arguments</param>
        private void OnUnitWriterDisposing(object sender, EventArgs eventArgs)
        {
            TdilUnitWriter unitWriter = (TdilUnitWriter)sender;

            unitWriter.Disposing -= OnUnitWriterDisposing;

            string unitText = unitWriter.WriteToString();

            AppendLine(unitText);
        }
Пример #2
0
        /// <summary>
        /// Creates a new instance of <see cref="TdilUnitWriter"/>. The content of this writer is being appended to the
        /// file writer when it's being disposed.
        /// </summary>
        /// <param name="unitName">Name of the unit</param>
        /// <param name="unitParamNames">Name of unit parameters</param>
        /// <returns>Instance of <see cref="TdilUnitWriter"/></returns>
        /// <exception cref="ArgumentNullException">If <paramref name="unitName"/> is NULL or empty</exception>
        public TdilUnitWriter CreateUnit(string unitName, string[] unitParamNames)
        {
            if (string.IsNullOrEmpty(unitName))
            {
                throw new ArgumentNullException("unitName", "Must not be NULL or empty!");
            }

            if (unitParamNames == null)
            {
                unitParamNames = new string[0];
            }

            EnsureHeaderWritten();
            AppendLine();

            TdilUnitWriter unitWriter = new TdilUnitWriter(unitName, unitParamNames);

            unitWriter.Disposing += OnUnitWriterDisposing;
            return(unitWriter);
        }