本文整理汇总了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);
}
}
}
示例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);
}
}
}