当前位置: 首页>>代码示例>>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;未经允许,请勿转载。