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