Flatwhite.Provider.DefaultCacheKeyProvider.GetRevalidateKey C# (CSharp) Method

GetRevalidateKey() public method

Build the revalidation key from provided keyFormat
public GetRevalidateKey ( _IInvocation invocation, string keyFormat ) : string
invocation _IInvocation
keyFormat string
return string
        public virtual string GetRevalidateKey(_IInvocation invocation, string keyFormat)
        {
            var parameters = invocation.Method.GetParameters().ToList();
            var placeholders = Regex.Matches(keyFormat, "{(?<Argument>[\\w\\d_]+)}", RegexOptions.Compiled | RegexOptions.Singleline);
            
            var key = new StringBuilder(keyFormat);
            for (var i = 0; i < placeholders.Count; i++)
            {
                var match = placeholders[i].Groups["Argument"].Value;
                var index = parameters.FindIndex(p => p.Name == match);
                if (index >= 0)
                {
                    var arg = invocation.GetArgumentValue(index);
                    var argKey = _hashCodeGeneratorProvider.GetForType(parameters[index].ParameterType).GetCode(arg);
                    key = key.Replace($"{{{match}}}", argKey);
                }
            }

            return key.ToString();
        }
    }