public static void RecordProductViews(string bvin, MerchantTribeApplication app) { if (WebAppSettings.LastProductsViewedCookieName != string.Empty) { string SavedProductIDs = SessionManager.GetCookieString(WebAppSettings.LastProductsViewedCookieName, app.CurrentStore); if (SavedProductIDs != string.Empty) { string[] AllIDs = SavedProductIDs.Split(','); System.Collections.Generic.Queue<string> q = new System.Collections.Generic.Queue<string>(); q.Enqueue(bvin); foreach (string id in AllIDs) { if (q.Count < 10) { if (!q.Contains(id)) { q.Enqueue(id); } } } SessionManager.SetCookieString(WebAppSettings.LastProductsViewedCookieName, string.Join(",", q.ToArray()), app.CurrentStore); } else { SessionManager.SetCookieString(WebAppSettings.LastProductsViewedCookieName, bvin, app.CurrentStore); } } }
/// <summary> /// store a list to file and refresh list /// </summary> /// <param name="path"></param> private void SaveRecentFile(string path) { recentToolStripMenuItem.DropDownItems.Clear(); //clear all recent list from menu LoadRecentList(); //load list from file if (!(MRUlist.Contains(path))) //prevent duplication on recent list { MRUlist.Enqueue(path); //insert given path into list } while (MRUlist.Count > MRUnumber) //keep list number not exceeded given value { MRUlist.Dequeue(); } foreach (string item in MRUlist) { ToolStripMenuItem fileRecent = new ToolStripMenuItem(item, null, RecentFile_click); //create new menu for each item in list recentToolStripMenuItem.DropDownItems.Add(fileRecent); //add the menu to "recent" menu } //writing menu list to file StreamWriter stringToWrite = new StreamWriter(System.Environment.CurrentDirectory + "\\Recent.txt"); //create file called "Recent.txt" located on app folder foreach (string item in MRUlist) { stringToWrite.WriteLine(item); //write list to stream } stringToWrite.Flush(); //write stream to file stringToWrite.Close(); //close the stream and reclaim memory }
/// <summary> /// 异步加载AB /// </summary> /// <param name="abPath"></param> public void LoadAssetBundleAsyn(string abPath) { CMAssetBundle cmAB = null; if (!m_dicAssetBundleDatas.TryGetValue(abPath, out cmAB)) { cmAB = CMAssetBundle.Create(abPath); m_dicAssetBundleDatas.Add(abPath, cmAB); } if (cmAB.GetTaskState() != CMABTaskState.CMTaskState_None) { //已经在加载了 return; } string[] dependenciesPath = GetABAllDependencies(cmAB.ABPath); if (null != dependenciesPath) { for (int i = 0, max = dependenciesPath.Length; i < max; i++) { if (!waitingABPath.Contains(dependenciesPath[i])) { waitingABPath.Enqueue(dependenciesPath[i]); } } } waitingABPath.Enqueue(abPath); cmAB.OnWaitingStart(); //DoNextABLoad(); ProcessABLoadAsyn(); }
public static void RecordProductViews(string bvin, MerchantTribeApplication app) { if (WebAppSettings.LastProductsViewedCookieName != string.Empty) { string SavedProductIDs = SessionManager.GetCookieString(WebAppSettings.LastProductsViewedCookieName, app.CurrentStore); if (SavedProductIDs != string.Empty) { string[] AllIDs = SavedProductIDs.Split(','); System.Collections.Generic.Queue <string> q = new System.Collections.Generic.Queue <string>(); q.Enqueue(bvin); foreach (string id in AllIDs) { if (q.Count < 10) { if (!q.Contains(id)) { q.Enqueue(id); } } } SessionManager.SetCookieString(WebAppSettings.LastProductsViewedCookieName, string.Join(",", q.ToArray()), app.CurrentStore); } else { SessionManager.SetCookieString(WebAppSettings.LastProductsViewedCookieName, bvin, app.CurrentStore); } } }
public void OnAfterDeserialize() { queue.Clear(); for (var i = 0; i < values.Count && i < values.Count; i++) { if (!queue.Contains(values[i])) { queue.Enqueue(values[i]); } } }
public bool Contains(IValue val) { return(_queue.Contains(val)); }