/// <summary> /// Creates a cache item policy using the information obtained from the specified cache item policy configuration item. /// </summary> /// <param name="configurationItem">The cache item policy configuration item.</param> /// <returns> /// A new instance of <see cref="CacheItemPolicy"/> or null is the specified configuration is disabled. /// </returns> /// <exception cref="System.ArgumentNullException">configurationItem</exception> public static CacheItemPolicy CreateCacheItemPolicy(ICacheItemPolicyConfigurationItem configurationItem) { if (null == configurationItem) { throw new ArgumentNullException("configurationItem"); } if (false == configurationItem.Enabled) { return(null); } var policy = new CacheItemPolicy(); // Determine if an absolute or sliding expiration should be set. if (configurationItem.SlidingExpiration == ObjectCache.NoSlidingExpiration) { // An absolute expiration is configured and will be set in the policy. policy.AbsoluteExpiration = configurationItem.AbsoluteExpiration; } else { // A sliding expiration is configured and will be set in the policy. policy.SlidingExpiration = configurationItem.SlidingExpiration; } return(policy); }
/// <summary> /// Determines the index of a specific item in the <see cref="T:System.Collections.Generic.IList`1" />. /// </summary> /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.IList`1" />.</param> /// <returns> /// The index of <paramref name="item" /> if found in the list; otherwise, -1. /// </returns> /// <exception cref="System.InvalidOperationException"></exception> public int IndexOf(ICacheItemPolicyConfigurationItem item) { var element = item as CacheItemPolicyConfigurationElement; if (null != element) { return(BaseIndexOf(element)); } throw new InvalidOperationException(string.Format("The item must be an instance of the {0} type.", typeof(CacheItemPolicyConfigurationElement).FullName)); }
/// <summary> /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1" />. /// </summary> /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1" />.</param> /// <exception cref="System.InvalidOperationException"></exception> public void Add(ICacheItemPolicyConfigurationItem item) { var element = item as CacheItemPolicyConfigurationElement; if (null != element) { BaseAdd(element); } else { throw new InvalidOperationException(string.Format("The item must be an instance of the {0} type.", typeof(CacheItemPolicyConfigurationElement).FullName)); } }
/// <summary> /// Creates a cache item policy using the information obtained from the specified cache item policy configuration item. /// </summary> /// <param name="configurationItem">The cache item policy configuration item.</param> /// <returns> /// A new instance of <see cref="CacheItemPolicy"/> or null is the specified configuration is disabled. /// </returns> /// <exception cref="System.ArgumentNullException">configurationItem</exception> public static CacheItemPolicy CreateCacheItemPolicy(ICacheItemPolicyConfigurationItem configurationItem) { if (null == configurationItem) throw new ArgumentNullException("configurationItem"); if (false == configurationItem.Enabled) return null; var policy = new CacheItemPolicy(); // Determine if an absolute or sliding expiration should be set. if (configurationItem.SlidingExpiration == ObjectCache.NoSlidingExpiration) { // An absolute expiration is configured and will be set in the policy. policy.AbsoluteExpiration = configurationItem.AbsoluteExpiration; } else { // A sliding expiration is configured and will be set in the policy. policy.SlidingExpiration = configurationItem.SlidingExpiration; } return policy; }
/// <summary> /// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1" /> at the specified index. /// </summary> /// <param name="index">The zero-based index at which <paramref name="item" /> should be inserted.</param> /// <param name="item">The object to insert into the <see cref="T:System.Collections.Generic.IList`1" />.</param> /// <exception cref="System.NotImplementedException"></exception> public void Insert(int index, ICacheItemPolicyConfigurationItem item) { // This member is intentionally not implemented. throw new NotImplementedException(); }
/// <summary> /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1" />. /// </summary> /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1" />.</param> /// <returns> /// true if <paramref name="item" /> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false. This method also returns false if <paramref name="item" /> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1" />. /// </returns> /// <exception cref="System.NotImplementedException"></exception> public bool Remove(ICacheItemPolicyConfigurationItem item) { // This member is intentionally not implemented. throw new NotImplementedException(); }