Esempio n. 1
0
 private int CompareSyncItemsByOrderNo(SyncItem item1, SyncItem item2)
 {
     if (item1.OrderNo < item2.OrderNo)
     {
         return(-1);
     }
     if (item1.OrderNo > item2.OrderNo)
     {
         return(1);
     }
     return(0);
 }
Esempio n. 2
0
        /// <summary>
        /// Put all properties of SyncItemType into a list for the sack of query. Items are sorted according OrderNo
        /// </summary>
        /// <returns>A list of items. If no one, the list is empty but not null.</returns>
        public IList <SyncItem> GetSyncItems()
        {
            Type            typeOfSyncItem = typeof(SyncItem);
            List <SyncItem> items          = new List <SyncItem>();

            foreach (SettingsPropertyValue propertyValue in PropertyValues)
            {
                if (typeOfSyncItem.IsAssignableFrom(propertyValue.Property.PropertyType))
                {
                    SyncItem syncItem = propertyValue.PropertyValue as SyncItem;
                    System.Diagnostics.Debug.Assert(syncItem != null, "What syncitem?");
                    items.Add(syncItem);
                }
            }
            //PropertyValues does not give syncItems as they appear in the Settings object
            //so I have to sort it with SyncItem.OrderNo.
            items.Sort(CompareSyncItemsByOrderNo);
            return(items);
        }