コード例 #1
0
        public void ListMergeTest()
        {
            PFList <string> list1 = new PFList <string>();
            PFList <string> list2 = new PFList <string>();
            PFList <string> list3 = new PFList <string>();


            try
            {
                _msg.Length = 0;
                _msg.Append("ListMergeTest started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                list1.Add("First");
                list1.Add("Second");
                list1.Add("Third");

                list2.Add("fourth");
                list2.Add("fifth");
                list2.Add("sixth");

                list3.Add("Seventh");
                list3.Add("Eighth");
                list3.Add("Ninth");
                list3.Add("Tenth");

                PFList <string>[]         listArray   = { list1, list2, list3 };
                PFList <PFList <string> > listOfLists = new PFList <PFList <string> >();
                listOfLists.Add(list1);
                listOfLists.Add(list2);
                listOfLists.Add(list3);

                PFList <string> concatListFromArray = PFList <string> .ConcatenateLists(listArray);

                _msg.Length = 0;
                _msg.Append(Environment.NewLine);
                _msg.Append("Concatenated list from Array");
                _msg.Append(Environment.NewLine);
                _msg.Append(concatListFromArray.ToXmlString());
                Program._messageLog.WriteLine(_msg.ToString());


                PFList <string> concatListFromList = PFList <string> .ConcatenateLists(listOfLists);

                _msg.Length = 0;
                _msg.Append(Environment.NewLine);
                _msg.Append("Concatenated list from List");
                _msg.Append(Environment.NewLine);
                _msg.Append(concatListFromList.ToXmlString());
                Program._messageLog.WriteLine(_msg.ToString());

                PFList <string> mergedList = list1.Merge(list2);
                _msg.Length = 0;
                _msg.Append(Environment.NewLine);
                _msg.Append("Merged list");
                _msg.Append(Environment.NewLine);
                _msg.Append(mergedList.ToXmlString());
                Program._messageLog.WriteLine(_msg.ToString());

                mergedList.Clear();
                mergedList = list3.Merge(new PFList <string>[2] {
                    list1, list2
                });
                _msg.Length = 0;
                _msg.Append(Environment.NewLine);
                _msg.Append("Merged list from Array");
                _msg.Append(Environment.NewLine);
                _msg.Append(mergedList.ToXmlString());
                Program._messageLog.WriteLine(_msg.ToString());

                mergedList.Clear();
                mergedList = list3.Merge(new PFList <PFList <string> > {
                    list2, list1
                });
                _msg.Length = 0;
                _msg.Append(Environment.NewLine);
                _msg.Append("Merged list from List");
                _msg.Append(Environment.NewLine);
                _msg.Append(mergedList.ToXmlString());
                Program._messageLog.WriteLine(_msg.ToString());
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... ListMergeTest finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }