public ItemSort(SortState[] order, SortState defaultState, string storageName) { // Store the order and get the current state from persistent storage SortOrder = order; StorageName = storageName + "sortOrder"; CurrentOrder = ( SortState )Enum.Parse(typeof(SortState), PersistentStorage.GetStringItem(StorageName, defaultState.ToString())); // if this order is not in the allowed states then set the current order to the first item in the states if (Array.Exists(SortOrder, element => (element == CurrentOrder)) == false) { CurrentOrder = SortOrder[0]; } }
public void SetNext() { CurrentOrder = SortOrder[NextIndex()]; PersistentStorage.SetStringItem(StorageName, CurrentOrder.ToString()); }