當前位置: 首頁>>代碼示例>>C#>>正文


C# Member.FireBeforeAddToCache方法代碼示例

本文整理匯總了C#中umbraco.cms.businesslogic.member.Member.FireBeforeAddToCache方法的典型用法代碼示例。如果您正苦於以下問題:C# Member.FireBeforeAddToCache方法的具體用法?C# Member.FireBeforeAddToCache怎麽用?C# Member.FireBeforeAddToCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在umbraco.cms.businesslogic.member.Member的用法示例。


在下文中一共展示了Member.FireBeforeAddToCache方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddMemberToCache

        /// <summary>
        /// Method is used when logging a member in.
        /// 
        /// Adds the member to the cache of logged in members
        /// 
        /// Uses cookiebased recognition
        /// 
        /// Can be used in the runtime
        /// </summary>
        /// <param name="m">The member to log in</param>
        public static void AddMemberToCache(Member m)
        {

            if (m != null)
            {
                AddToCacheEventArgs e = new AddToCacheEventArgs();
                m.FireBeforeAddToCache(e);

                if (!e.Cancel)
                {
                    // Add cookie with member-id, guid and loginname
                    // zb-00035 #29931 : cleanup member state management
                    // NH 4.7.1: We'll no longer use legacy cookies to handle Umbraco Members
                    //SetMemberState(m);

                    FormsAuthentication.SetAuthCookie(m.LoginName, true);

                    //cache the member
                    var cachedMember = Cache.GetCacheItem<Member>(GetCacheKey(m.Id), m_Locker,
                        TimeSpan.FromMinutes(30),
                        delegate
                        {
                            // Debug information
                            HttpContext.Current.Trace.Write("member",
                                string.Format("Member added to cache: {0}/{1} ({2})",
                                    m.Text, m.LoginName, m.Id));

                            return m;
                        });

                    m.FireAfterAddToCache(e);
                }
            }

        }
開發者ID:phaniarveti,項目名稱:Experiments,代碼行數:45,代碼來源:Member.cs

示例2: AddMemberToCache

        public static void AddMemberToCache(Member m, bool UseSession, TimeSpan TimespanForCookie)
        {
            if (m != null)
            {
                var e = new AddToCacheEventArgs();
                m.FireBeforeAddToCache(e);

                if (!e.Cancel)
                {
                    // zb-00035 #29931 : cleanup member state management
                    // NH 4.7.1: We'll no longer use Umbraco legacy cookies to handle members
                    //SetMemberState(m, UseSession, TimespanForCookie.TotalDays);

                    FormsAuthentication.SetAuthCookie(m.LoginName, !UseSession);

                    //cache the member
                    var cachedMember = ApplicationContext.Current.ApplicationCache.GetCacheItem(
                        GetCacheKey(m.Id),
                        TimeSpan.FromMinutes(30),
                        () =>
                            {
                                // Debug information
                                HttpContext.Current.Trace.Write("member",
                                                                string.Format("Member added to cache: {0}/{1} ({2})",
                                                                              m.Text, m.LoginName, m.Id));

                                return m;
                            });

                    m.FireAfterAddToCache(e);
                }

            }
        }
開發者ID:phaniarveti,項目名稱:Experiments,代碼行數:34,代碼來源:Member.cs


注:本文中的umbraco.cms.businesslogic.member.Member.FireBeforeAddToCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。