Esempio n. 1
0
 private void ReadMenu()
 {
     if (Settings.Default.RecentUseMenu.Trim().Length > 0)
     {
         try
         {
             Dictionary <string, string> dictionary = SerializableHelper.DeSerialize <Dictionary <string, string> >(Settings.Default.RecentUseMenu);
             if ((dictionary != null) && dictionary.ContainsKey(Variable.sUserId))
             {
                 Action <RecentUseMenuCollection> action = null;
                 string fi = dictionary[Variable.sUserId];
                 RecentUseMenuCollection temp = SerializableHelper.DeSerialize <RecentUseMenuCollection>(fi);
                 if (temp != null)
                 {
                     if ((this._allowUseMenu == null) || (this._allowUseMenu.Count == 0))
                     {
                         temp.Clear();
                     }
                     else
                     {
                         List <RecentUseMenuCollection> list = new List <RecentUseMenuCollection>();
                         foreach (RecentUseMenuCollection menus in temp)
                         {
                             if (!this._allowUseMenu.ContainsKey(menus.MenuKey.ToLower() + "1"))
                             {
                                 list.Add(menus);
                             }
                         }
                         if (action == null)
                         {
                             action = obj => temp.Remove(obj);
                         }
                         list.ForEach(action);
                     }
                     this._menulist = temp;
                 }
             }
         }
         catch
         {
         }
     }
 }
Esempio n. 2
0
 public void SaveMenu()
 {
     if (this._menulist != null)
     {
         Dictionary <string, string> t = null;
         if (Settings.Default.RecentUseMenu.Trim().Length > 0)
         {
             try
             {
                 t = SerializableHelper.DeSerialize <Dictionary <string, string> >(Settings.Default.RecentUseMenu);
             }
             catch
             {
             }
         }
         if (t == null)
         {
             t = new Dictionary <string, string>();
         }
         t[Variable.sUserId]            = SerializableHelper.SerializeToString <RecentUseMenuCollection>(this._menulist);
         Settings.Default.RecentUseMenu = SerializableHelper.SerializeToString <Dictionary <string, string> >(t);
         Settings.Default.Save();
     }
 }