/// <summary> /// The current version before any override /// </summary> /// <returns>Current version before override</returns> public ItemVersion DefaultCurrentVersion(RouteData rd = null) { if (rd == null) { rd = RequestContextManager.Instance.CurrentContext?.GetRouteData(); } return(new ItemVersion(Versioners.ToDictionary(vnr => vnr.VersionKey, vnr => vnr.CurrentValue(VersioningMode.Current, rd)))); }
private ItemVersion GetCurrentVersion(RouteData rd) { if (Mode != VersioningMode.Current || currentVersionInvalidated || !RequestThreadCache.Current.ContainsKey(CurrentVersionKey + UniqueId)) { ItemVersion iv = null; if (Mode == VersioningMode.All) { iv = new ItemVersion(); } else if (Mode == VersioningMode.Specific) { iv = SpecificVersion; } else if (Mode == VersioningMode.Public) { iv = new ItemVersion(Versioners.ToDictionary(vnr => vnr.VersionKey, vnr => vnr.PublicVersionValue)); } else { iv = DefaultCurrentVersion(rd); var vOver = this.ClientVersionOverride; if (vOver != null && vOver != iv) { var overridden = OverrideVersion(iv, vOver); currentVersionIsOverridden = overridden != null; iv = overridden ?? iv; } else { currentVersionIsOverridden = false; } } if (Mode == VersioningMode.Current) { RequestThreadCache.Current[CurrentVersionKey + UniqueId] = new ItemVersion(iv); } return(iv); } return(new ItemVersion((ItemVersion)RequestThreadCache.Current[CurrentVersionKey + UniqueId])); }
public ItemVersion RulesMask(ItemVersion version) { var iv = new ItemVersion(Versioners.ToDictionary(vnr => vnr.VersionKey, vnr => vnr.NoRules ? version[vnr.VersionKey] : null)); return(iv); }
/// <summary> /// Create an ItemVersion with null values for all the keys applicable to a type /// </summary> /// <param name="type">The type for which to create the ItemVersion</param> /// <returns>ItemVersion with null values for all the keys applicable</returns> public ItemVersion VersionForType(Type type) { var iv = new ItemVersion(Versioners.ToDictionary(vnr => vnr.VersionKey, vnr => (object)null)); return(iv); }