示例#1
0
 /// <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))));
 }
示例#2
0
        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]));
        }
示例#3
0
        public ItemVersion RulesMask(ItemVersion version)
        {
            var iv = new ItemVersion(Versioners.ToDictionary(vnr => vnr.VersionKey, vnr => vnr.NoRules ? version[vnr.VersionKey] : null));

            return(iv);
        }
示例#4
0
        /// <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);
        }