コード例 #1
0
        /// <summary>
        /// A string representation of this object.
        /// </summary>
        /// <returns>A string representation of this object.</returns>
        public override string ToString()
        {
            var results = new StringBuilder();

            // entry types
            if (EntryTypes.Count() > 0)
            {
                AddTitle("EntryTypes");
                foreach (var item in EntryTypes)
                {
                    AddItem(item.ToString());
                }
            }
            // sources
            if (Sources.Count() > 0)
            {
                AddTitle("Sources");
                foreach (var item in Sources)
                {
                    AddItem(item);
                }
            }
            // event ids
            if (EventIds.Count() > 0)
            {
                AddTitle("EventIds");
                foreach (var item in EventIds)
                {
                    AddItem(item.ToString());
                }
            }
            // categories
            if (Categories.Count() > 0)
            {
                AddTitle("Categories");
                foreach (var item in Categories)
                {
                    AddItem(item.ToString());
                }
            }
            // from date
            AddTitle("FromDate");
            AddItem(FromDate.ToString());
            // to date
            AddTitle("ToDate");
            AddItem(ToDate.ToString());
            //
            return(results.ToString());

            // ---------------- internal functions

            void AddTitle(string title)
            {
                if (results.Length > 0)
                {
                    results.Append("; ");
                }
                results.Append(title + "=");
            }

            void AddItem(string item)
            {
                if ((results.Length > 0) && (results[results.Length - 1] != '='))
                {
                    results.Append(", ");
                }
                results.Append(item);
            }
        }